From patchwork Thu Sep 20 05:02:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10606851 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 A87FB6CB for ; Thu, 20 Sep 2018 05:02:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 982162CD2D for ; Thu, 20 Sep 2018 05:02:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C35E2CE79; Thu, 20 Sep 2018 05:02:31 +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 1D2182CD2D for ; Thu, 20 Sep 2018 05:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731285AbeITKn7 (ORCPT ); Thu, 20 Sep 2018 06:43:59 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35173 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbeITKn7 (ORCPT ); Thu, 20 Sep 2018 06:43:59 -0400 Received: by mail-pg1-f194.google.com with SMTP id 205-v6so2876395pgd.2 for ; Wed, 19 Sep 2018 22:02:29 -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 :mime-version:content-transfer-encoding; bh=tTGFZl5XrN6nvN60a68opbFt4xKvl5IlRpnLTTt+nzw=; b=qt2UsafEyyjdqbaQDfFCBb+OMXiKY5wvEWZfjTGj63kM/eQTJDfAs8oypCPl9U8Ex7 nBRKYohdRXOjKOaDKT1pNalgHKur71ivlYg7+I7ujT0OU1DNP/kHBIw3q2bTPJtx0JMP RTvK4EdZgaxgDgAJOxcn24RKBptOewhrIkuKttFqxJ7l4e7ONLSFxWCTVXMdTx3jlwkM sK+oSsBJd6a/SnXvjd7lp5/dv8FGydX0Kg9XgwUbQ0e5d0jDU5cxc8lyiXGVDbFQOvNm IsVY7VbAEUnmlfNadlmIJfNS0EHZ2TgTL4oyc1m5RzqM6QBIrAUHxf469nTtw8lT3quo gW6A== 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:mime-version:content-transfer-encoding; bh=tTGFZl5XrN6nvN60a68opbFt4xKvl5IlRpnLTTt+nzw=; b=iJ35ZrrBe2/hDDh7wxJG5Biwv+o6VoORuIMEJJIKRGETWdCh/5CNsHzSbLkduobMTd lyPbibvmtAp5YbwZdatGS1LCwtUYsNTF3IAZujkmQFPdRQjOYPmT6lscVr2mSWdYhLPv vEUWpTYRYFU2fN7eLallD2/IuH7/JPwROc96i0vBAs0N4p0/lO90TziExdliU6JY3znL D2d0JO8nuv5IyoJA7j5Rk95irmmuPhPsiI073yLTkMKHFw6sdvZtd/dYILhK1/JlFITC efwdjuvqxsh0WNR4HL269XhB8HAAw/zZvKj9w/8hrIFaokZz+fOPfpI5dzP24V+819Hp jnDQ== X-Gm-Message-State: APzg51D2KGMZCRHHCkw7FIqPntJ/6P1RR4jJ26oysbfnB0zUQ9Wvi7G2 /rAELYmS+TXE540uqXVLbhjfWTUcKho= X-Google-Smtp-Source: ANB0VdZHWf23yppXidpuaPFjzNN3khV+S1X17cNrQcQXncDnrQSmWG2xY4D3WFC6jg8D2D3QqSW5VQ== X-Received: by 2002:a62:5d89:: with SMTP id n9-v6mr39402737pfj.102.1537419748728; Wed, 19 Sep 2018 22:02:28 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:7ae9]) by smtp.gmail.com with ESMTPSA id q6-v6sm27024885pgq.19.2018.09.19.22.02.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 22:02:28 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, David Sterba Subject: [PATCH v8 3/6] vfs: update swap_{,de}activate documentation Date: Wed, 19 Sep 2018 22:02:14 -0700 Message-Id: <13267d4822d3b868624770ddfff6c3f85316ba89.1537419652.git.osandov@fb.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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 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 a6c6a8af48a2..6e14db053eaa 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.