From patchwork Tue Sep 11 22:34:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10596429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5663614E0 for ; Tue, 11 Sep 2018 22:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46CD229C45 for ; Tue, 11 Sep 2018 22:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B32429DEA; Tue, 11 Sep 2018 22:35:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A69F329C45 for ; Tue, 11 Sep 2018 22:35:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 517DC8E0015; Tue, 11 Sep 2018 18:35:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A3338E0001; Tue, 11 Sep 2018 18:35:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F42C8E0015; Tue, 11 Sep 2018 18:35:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id D9AA78E0001 for ; Tue, 11 Sep 2018 18:35:17 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r20-v6so12999008pgv.20 for ; Tue, 11 Sep 2018 15:35:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=XfhD1s+oXIFOuIlVNDkhy1zo7dmofYMPh5tHBE+eOHA=; b=hrBytV4HYpbilIpWLVP4GkesOqezdaCMBY1HX+2NIvQDlLAkaxojtU3LiNH311qSaB 7U5zca0LimxWi2t81ynv2PDesKj58UWk41/1Lvu2DXKl/EZcip+J2cBX99dh+SIZNl9T AJ1MEpngdbWL7qf7wf6MJlyMQ6ceS4e09OG94f7/KvghfBwXJduofWZGum47oX/2H3+b XXqtwmVwRvRX3bOvKBzObpE6TL7Xb9lQmODA45C6URh8RFsZvY0+8h6c6bDSWXvl0MQO g9nuhq21mVDZYN+MH0cTJH5ia5xBdlo21gHeJXn4gbwz9yROV8Z92rXAWCsyCis0Bji6 WyVw== X-Gm-Message-State: APzg51BZBXUUyS0oC/NqxerEGcuKeABSsPHEgpMe9CRTqu8dJC1ty01z kuVGmUw2vZZmsl8LwdUjfiqMLAhShzlsQc4SRN6HplJ8txXTbyZgnFMVSbOidRFJWZRHDXniIX2 Ia9TA/eh0k3DhiVMgISLu5U56v7TwWiQm7VQ4PDTjbzQHv2+HYj1gB3+vHv1+4pr4d2hHWiQpwG vfMGRR3QG1VhEAlDsDnZWKzJStlBPWk9r+AksvPJDNIqIMpY6GItiEgSZ4bmfZX7T5EgtWF81SW ilPB43q9vAt6n2CiNS+SBjbraIOPQgD2sXeAZ82e/5UrCA0dTxIdkwb3gyk2BThhCxfBahAm+mP t+ZkRRrxo7Cq6+M9ZLVACA4bX8Kd1ch0fAzj9fBSHfZIiqBKnC7HqFpp+k4teO5iA92+77mrJyx F X-Received: by 2002:a17:902:b58a:: with SMTP id a10-v6mr29955782pls.306.1536705317560; Tue, 11 Sep 2018 15:35:17 -0700 (PDT) X-Received: by 2002:a17:902:b58a:: with SMTP id a10-v6mr29955705pls.306.1536705316207; Tue, 11 Sep 2018 15:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536705316; cv=none; d=google.com; s=arc-20160816; b=WACvl0cxtzkeJcgwdLhYhVW/FxOXkeCOv84J0zy1JC7rzTKrTj94TfcSg7pPlZOGU1 xwvxRG5FTCqOZwwUaj5RqrLasrDIEGP6K3iRjTTdF4SHCW+fM29nGXnvKb9reRYhlLEX lsRQGc2zk5p7PccftsaQXmmCFQgzBWTHmn7kcS3M96yXsEINs5tV/a9G9Z1NhAqUS+DU olHYE5E7jOAYCV63E2QBdU5tj4AvVKhV08WWZ7DyWwZxzqF6/qtUVlJVPfZbvt55oaZe Bqj02FvKY2oGvw4tOP0MmeBgZci4ht4H8Hauquk532PQf9gQ4zr5dSZLkRveOpWAqBpE p8NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XfhD1s+oXIFOuIlVNDkhy1zo7dmofYMPh5tHBE+eOHA=; b=dDsBlyOeiXDLyyL466jV6/+AN3pt2CGXPvT4kHJ18EizarC5bSNo8jTr3amBwCeOQ9 lH9zQqP3BhdyrtBPYHnvweiCoAjX0wRQ+jz/TTlRC1mosBAA/tp0OyMv0hVf6YIGVj2c IspTL82E3B/jzAy8PD+44HQorGUEy2mjto1h3eMwsxfAWvOhADZeDr5w8M3KsVfml1cf 9qqJv4ajGgbSOEUYoKpEUz4Zk6av1Dt5DHFLKvBttmKH8Re2VREuJ5eSgTFapwowxaz9 5eLtWiHMlQ+MwazDkR9mkT+7u5niEoCI6BnoH/7jf+DwOC4fJHX0ZhpBrM13+IOxEN9t 1Ovw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=nVkLNSX9; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of osandov@osandov.com) smtp.mailfrom=osandov@osandov.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u14-v6sor3797123pfa.18.2018.09.11.15.35.16 for (Google Transport Security); Tue, 11 Sep 2018 15:35:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of osandov@osandov.com) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=nVkLNSX9; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of osandov@osandov.com) smtp.mailfrom=osandov@osandov.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XfhD1s+oXIFOuIlVNDkhy1zo7dmofYMPh5tHBE+eOHA=; b=nVkLNSX9fRLZ1hzsn8SLpu3zAva7jVS84VE+Xq03vzGZJq+c4Y0ic9FobvTbOiV/e4 Pxa3nv5CkePSM2AbZllqQzDNtu9tYlY+h7Ztvoqpk8QclgjWIZTKU6hbgqSL25IivY3l uJNMvpd+gg7Ihja1NERjPErMoADVgMMO4/QHyeQ84V22HPXF3R+6VDF7Pa6QtT4XbShF JIivYZpM/HqX3XKY4tVx/bslIjMv5lrsvp7SWuqq+1RgeGN7567iq0bFQai+pZpktuUz r7dyOGMnRiYCNaHEH1VWT6rFLHR50UntCnhy3B0WcBw0M7zMb+iTeTc/oX2jREJJsCNb 18dA== X-Google-Smtp-Source: ANB0VdZaPliu05bWLgw/zF77UuAbpoGICYqiLQFjGGnZY02Tf3QOvFVXd9u1vMeHQhaFVsQ8Z+JWXw== X-Received: by 2002:a63:706:: with SMTP id 6-v6mr29990412pgh.137.1536705315598; Tue, 11 Sep 2018 15:35:15 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::7:13b4]) by smtp.gmail.com with ESMTPSA id 186-v6sm18710176pgg.56.2018.09.11.15.35.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 15:35:14 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, linux-mm@kvack.org Subject: [PATCH v7 3/6] vfs: update swap_{,de}activate documentation Date: Tue, 11 Sep 2018 15:34:46 -0700 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval The documentation for these functions is wrong in several ways: - swap_activate() is called with the inode locked - swap_activate() takes a swap_info_struct * and a sector_t * - swap_activate() can also return a positive number of extents it added itself - swap_deactivate() does not return anything Reviewed-by: Nikolay Borisov Signed-off-by: Omar Sandoval --- Documentation/filesystems/Locking | 17 +++++++---------- Documentation/filesystems/vfs.txt | 12 ++++++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index efea228ccd8a..b970c8c2ee22 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -210,8 +210,9 @@ prototypes: int (*launder_page)(struct page *); int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long); int (*error_remove_page)(struct address_space *, struct page *); - int (*swap_activate)(struct file *); - int (*swap_deactivate)(struct file *); + int (*swap_activate)(struct swap_info_struct *, struct file *, + sector_t *); + void (*swap_deactivate)(struct file *); locking rules: All except set_page_dirty and freepage may block @@ -235,8 +236,8 @@ putback_page: yes launder_page: yes is_partially_uptodate: yes error_remove_page: yes -swap_activate: no -swap_deactivate: no +swap_activate: yes +swap_deactivate: no ->write_begin(), ->write_end() and ->readpage() may be called from the request handler (/dev/loop). @@ -333,14 +334,10 @@ cleaned, or an error value if not. Note that in order to prevent the page getting mapped back in and redirtied, it needs to be kept locked across the entire operation. - ->swap_activate will be called with a non-zero argument on -files backing (non block device backed) swapfiles. A return value -of zero indicates success, in which case this file can be used for -backing swapspace. The swapspace operations will be proxied to the -address space operations. + ->swap_activate is called from sys_swapon() with the inode locked. ->swap_deactivate() will be called in the sys_swapoff() -path after ->swap_activate() returned success. +path after ->swap_activate() returned success. The inode is not locked. ----------------------- file_lock_operations ------------------------------ prototypes: diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 4b2084d0f1fb..40d6d6d4b76b 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -652,8 +652,9 @@ struct address_space_operations { unsigned long); void (*is_dirty_writeback) (struct page *, bool *, bool *); int (*error_remove_page) (struct mapping *mapping, struct page *page); - int (*swap_activate)(struct file *); - int (*swap_deactivate)(struct file *); + int (*swap_activate)(struct swap_info_struct *, struct file *, + sector_t *); + void (*swap_deactivate)(struct file *); }; writepage: called by the VM to write a dirty page to backing store. @@ -830,8 +831,11 @@ struct address_space_operations { swap_activate: Called when swapon is used on a file to allocate space if necessary and pin the block lookup information in - memory. A return value of zero indicates success, - in which case this file can be used to back swapspace. + memory. If this returns zero, the swap system will call the address + space operations ->readpage() and ->direct_IO(). Alternatively, this + may call add_swap_extent() and return the number of extents added, in + which case the swap system will use the provided blocks directly + instead of going through the filesystem. swap_deactivate: Called during swapoff on files where swap_activate was successful.