From patchwork Thu May 24 21:41:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10425579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D55516019D for ; Thu, 24 May 2018 21:41:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C74E4295BC for ; Thu, 24 May 2018 21:41:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5EE9295E2; Thu, 24 May 2018 21:41:51 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ED11295C9 for ; Thu, 24 May 2018 21:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161473AbeEXVlt (ORCPT ); Thu, 24 May 2018 17:41:49 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34966 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966227AbeEXVlm (ORCPT ); Thu, 24 May 2018 17:41:42 -0400 Received: by mail-pl0-f65.google.com with SMTP id i5-v6so1836982plt.2 for ; Thu, 24 May 2018 14:41:42 -0700 (PDT) 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 :in-reply-to:references; bh=XkSd90YfxXqXAfEC5SDCVTZaQ8PT2W0f1drRk39ASZU=; b=ncE0ggmm+8w3eorJ6K7Tlyctbl6CMYv8YAv8i4QGZ83hcy/U7dtwUiTSqAJCkYKH6z drRPSEm3JhGgj4veVD2+cLaOQGemFJUCVFJFMyDXXLiD+H9WHTXo6sFSF9bpK+07WPgy UuYg6GQOvgzXS7bCTud13DulOuzdhb58LKTK/VYCNf82T1HQ+Lu5Ak2eIy7Rvnd525ah WoKbsX0s0uJ/mFrJGLDgw9UaW1LrRyoTf8TDRa9Ek1B9ehmCRAJ4SguYhER4KHVw7f/Z I8PRzrHdTfOcmlACKrBthYpbvfQL0pu7MudpSbD/MV1LOnw0kYh39FN9H1n4n5Rs6dh9 VZcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=XkSd90YfxXqXAfEC5SDCVTZaQ8PT2W0f1drRk39ASZU=; b=WoqS8ZP7Kp0IbZpcqQuojPAC7ub0NmBwZ1EfbjELZmH+v/THrSB6Cs9rC2r9EHHivP YNPX5z6EWh5OfH/8oe7qrV/1p4T1PvG1/tACrjrA9s+vCBMPuSALIOfXgZUXJn+7XqsS w7sB29K3UMnhtD/MhN3ydUWJ0TcYmCcfOn4soX2nu2l04xyIc4BjpEUW9xnPoEMlq0RU 1leQGzqaWe0QO4PnJigZdLbImzgY3N19Aw2qf8ddjAzqIILl6l0RbKv627K7W6OoPN1T nsU4wnlLWicC4twhCEUj4Gdmat4sBj6zlU+Y6fUJjIV+9SvbfAX5KMkZAmmIh9juLKC8 l/sw== X-Gm-Message-State: ALKqPweUu/nsUyMwX//m9b8pnGGb/+CUidoqNcO6lt9EG4KTDy3KO4cw ufPA9O995AtD1fQB09yCXR1HdA== X-Google-Smtp-Source: AB8JxZq98IjQUMdD9aAslJqEl/c4X+gVFim2V2FAYcOr5XC+MW/MRpdFE6AEnsUr/4Bh9zOSLydhEw== X-Received: by 2002:a17:902:b58e:: with SMTP id a14-v6mr9170700pls.261.1527198101851; Thu, 24 May 2018 14:41:41 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::6:a0b5]) by smtp.gmail.com with ESMTPSA id g68-v6sm37388994pfk.53.2018.05.24.14.41.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 14:41:41 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, linux-fsdevel@vger.kernel.org, Tejun Heo Subject: [RFC PATCH v4 2/6] vfs: update swap_{,de}activate documentation Date: Thu, 24 May 2018 14:41:26 -0700 Message-Id: <4578bf3c7543f6f9a95b14a0523f2066f58ad43d.1527197312.git.osandov@fb.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 Signed-off-by: Omar Sandoval Reviewed-by: Nikolay Borisov --- 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 75d2d57e2c44..7f009e98fa3c 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -211,8 +211,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 @@ -236,8 +237,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). @@ -334,14 +335,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 5fd325df59e2..0149109d94d1 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -650,8 +650,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. @@ -828,8 +829,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.