From patchwork Fri Sep 7 07:39:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10591793 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 B064813AC for ; Fri, 7 Sep 2018 07:39:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A295F2A630 for ; Fri, 7 Sep 2018 07:39:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9634A2A64E; Fri, 7 Sep 2018 07:39:47 +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=unavailable 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 1F3E02A630 for ; Fri, 7 Sep 2018 07:39:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D6C36B7D2F; Fri, 7 Sep 2018 03:39:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7626B6B7D31; Fri, 7 Sep 2018 03:39:41 -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 5B1DD6B7D32; Fri, 7 Sep 2018 03:39:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 13C6B6B7D2F for ; Fri, 7 Sep 2018 03:39:41 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id n4-v6so6708394plk.7 for ; Fri, 07 Sep 2018 00:39:41 -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=fGeS/RA0COb/MAZJABuUvj60bIdFSG2mdhyplz+1P03e68caGFcGBwSjXftcW7Hk7U 4NJBipLdKGDDXsJ/OGJphyGdRpMUHVgUgSu+hMMycsvSSFj6yp34Rpci11S4tMHOWBv8 o+4otGNPdtZibdi6ROJMaUCznHs6bJnm4zy72znCoj5c6fSSjU+vPANdqeo74+s3gKiv WtP62LEQFYyfAkmvUfXbW0p5HtWqvg/T9YmniQ7UJCTemmq3g9sIvU1a4bPYvOBGmEMT aQOKP9Bp8kvAfQpn3kQcLmRLzpnv57gs9LLMA3wiQfT+4q2qBd71W0jfN6aAw0PXdVdV xMAQ== X-Gm-Message-State: APzg51BXVOTnD8on9C+iUYMWuoDcGT4RuD7lKKDGeJJHk0g4U9FcYzzl KHLXpDJwlag6Dn69bGs9a7Kfs6mtA/AypNIhqtDNsmounXgA10d4olsmGYMypiempgJO5uVtfJT Ojnya4stQVBYpzxkVpBOgP1j2KHS9s06fhKfyTcDOQQW8DLCEU3bKIp+n0V3qTZ5sQiZdZGVPBZ MM1AT7qXyVqgW1gZd+84Am8j58cw1Jw2qRA3Clr7xBwxqmpuYGW+ROORwYnxjgSrxfbMFJDu6Qg UsHwN5iIolXu1z4Z1JfO15fBNM75toJNF9Id/RN8s1P66LUrPJA1DVE8kJSNz3rf1PG1l5dtjVx 7o3U2zHTiPWeaZEDQSG1i60totLQhCrb14E/G+aYFY5bpE3Csty1vCADym6rRHpdfP4zbeLC4me e X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr6632213pld.312.1536305980696; Fri, 07 Sep 2018 00:39:40 -0700 (PDT) X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr6632163pld.312.1536305979482; Fri, 07 Sep 2018 00:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536305979; cv=none; d=google.com; s=arc-20160816; b=svxT8v8ylGP5gFBIUpKmsFxNbs+YP3du7/K8PhysIvmpmtXwfbZpBwuZ58fesd0neU 46GrUJTdQY6eO2oOv8vZ4JmEiV+9yVuPthWvreylHIZf1XfWNSM20AiCSdFDxgh6rylr rlUpXyzTqRL/65AYlv/aAqBaV/Abje1DvIO8KTgGBM+uocnbgRdpHWsisXWmipZrNV3v /2SNyYqGdBP88++kQTu/GpWzLAn8vPCKhVof0Xt1VN8dWPMe+kBkq7qpa/i0rMnsAE1c MR/xVqPFzB+ghZvmuMe0WHLUsG18HKiFYw8S67DFnUz595L8jL/5CY6Z0dp1w5/QBtMn pZXA== 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=Nbn4OtRkx+92hBjmQMOnLcnI2jt4v9tLFY43db5b7dC1EKqCuxOpjrwWrfrgcacALl 2mNd7VwxLr1jcvVCurry76D6tMm3db4FWqV9JtnTiRnQPUqKkbERtFfIlPdJtbrjbvWh A0Nei8BskPhWbWxNhKNJhOFVCx2PWNAOLGmy5Sg6RmX/pUxHbisGv4+/EpNGDWjCtFkA AF1UrIqn7wvKvAQKlpQM7O6v/4QDb3eu+dEkedad41xTweyqrzrChO4j3BrNsDfZ+xib 6Em2dxszDMetiFTL1xzjEuGqzjf8r0qmD4fws46teNCp1JWJiP9JUV0NBEFyXPjYDFM8 zrgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=RoRVEPPU; 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 q2-v6sor1652825plh.47.2018.09.07.00.39.39 for (Google Transport Security); Fri, 07 Sep 2018 00:39:39 -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=RoRVEPPU; 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=RoRVEPPUOEAvIxvPOl1OeAmw+mD7pTOuntBHzO1lpPqrDvJQsF3KRI/e1/FUjbZB5O uSqocwN93MugyqZWn5O0oU04KisGpZMrOHIbmM52LZH2GQBYPy0qezGr2WyB46+/mG4E 0TAcmH1I3YOuDLIDs4mEjc+UTumEvLQ1ncSn0epdzMIUDqTf+xvNw+UjbsAvmQxUxXBN BnemE0viWHvbslOX5s2xeblL+HXMVBU0o83U920zUAjS1PhEHKiY7DFwjJQPUA5YhhKk 3KJ+dGJnUdNblfLQQx1pMktUO/kD3PDkuqdEsgfjODwZjcw9aSeftE4ZcRAzZP64up4W banw== X-Google-Smtp-Source: ANB0VdbxxlwkXZ1lCGauNltUS/aaH8hbS2nFbc42eL3HhyOtujug8aQckD4zqeYM2kBTMquVV2NvVA== X-Received: by 2002:a17:902:7587:: with SMTP id j7-v6mr6707161pll.256.1536305978927; Fri, 07 Sep 2018 00:39:38 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:904c]) by smtp.gmail.com with ESMTPSA id i65-v6sm16276914pfk.43.2018.09.07.00.39.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 00:39:38 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, linux-mm@kvack.org Subject: [PATCH v6 3/6] vfs: update swap_{,de}activate documentation Date: Fri, 7 Sep 2018 00:39:17 -0700 Message-Id: <1cb226723bbec23a8a8d4c05368188b3c16522da.1536305017.git.osandov@fb.com> 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.