Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1497772pxb; Tue, 8 Feb 2022 20:10:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwz3AXNHs3G4pZHIwiuV+HKhyga6mdGJMQOdybcjiJxvkrBQ0ZxvQ5EEYFDkWi7zLDImN5W X-Received: by 2002:a17:90a:c291:: with SMTP id f17mr1355619pjt.172.1644379801028; Tue, 08 Feb 2022 20:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644379801; cv=none; d=google.com; s=arc-20160816; b=OFAHpi1tGkm948gHIWhNgXG7jm7rsOeVhW8xtsYTjfQJMyYnXkGeMl7EKukeAvBFwA 1i+9T1AbDwDP5NHWN/81A4af6e+ibTV9OMoLGf9n5yB20sxt0sl9Fom1DHZREf33ccy3 UetIzZ0/lQknimB3j5JFWFLI2BQu/cH6VlqkuVfS012eTOcMY1AysidOlkZdeoXdgLws uyliXOT6KpclUg1B/fa3WNG9PoABiaompAiA+a2gq41m3Y+hiQ+bcNu8dXm1Z8k3wKKE xgh7VqRpbOJq9XbKk4Af3EoWKkP4EaLJ2fjRBMBG0MgZ10M0h5qkWoo5/2EXQjbE3XGB PRJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=MLq8cIoheOmhzxM6Ogb6L1iI5r135ThxZduFj4O+MX4=; b=ng25TiNU0BCio7VeG3SdGxmAjgzZtAH1t7eFyzuc9YAenn+XIDt1wFjTCLhfdmo4j2 PnMqmQ28nWg166Dtye/FJJJnrLlB4uoeOWfk9IQGJvrsZ3qIFbA2ZmZVN5ehWdz0JmdE lba6sh4nnV1/0X6lKIEld1iWWZE/1sPN+84tpwWggpjX7Klb4KNYqREm6WhZF40AEGpW PkORRWZDHQbs2lSeHgEXw681aS0T4+mgW3Cup3ITlIU3f0o5jOeqsbwcVnw+EtkROM64 7gRT0Ytdo92UM/NxoSPVS99SpAWN7eb9foMM0EQiEiKytmBgJJE/gUul20sko1Yp7KY2 mRcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=D2LJ2F3G; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=trZTPFVC; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mr13si3607153pjb.104.2022.02.08.20.09.36; Tue, 08 Feb 2022 20:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=D2LJ2F3G; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=trZTPFVC; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243990AbiBGGPq (ORCPT + 99 others); Mon, 7 Feb 2022 01:15:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352065AbiBGErl (ORCPT ); Sun, 6 Feb 2022 23:47:41 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF8E3C043181; Sun, 6 Feb 2022 20:47:39 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3BE93210E8; Mon, 7 Feb 2022 04:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644209258; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MLq8cIoheOmhzxM6Ogb6L1iI5r135ThxZduFj4O+MX4=; b=D2LJ2F3Giw8Z3g8Jq66FT5PmWfId4gWMlLSJ/X14eKARqcftkNZxOXTxYGm2yhzRkclci1 fHWl82Xfq3kypIZq6aCrJ5GU9hFH7j0Jqr8d+VVURaLxgfVGG4fXidTdV7OqLLApPrdJU/ DrZ+j1X1gf128OjcUfPkxU3ugD0Qb+0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644209258; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MLq8cIoheOmhzxM6Ogb6L1iI5r135ThxZduFj4O+MX4=; b=trZTPFVCVLG9BmJczeFmm71FNWRYNUZc9dSVWJRIrsVe/dkNvh5YjKSMi4JX8yychFxHJX cwdN8/N3rc5yVSAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 579E31330E; Mon, 7 Feb 2022 04:47:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lFytBWekAGI7NQAAMHmgww (envelope-from ); Mon, 07 Feb 2022 04:47:35 +0000 Subject: [PATCH 07/21] DOC: update documentation for swap_activate and swap_rw From: NeilBrown To: Trond Myklebust , Anna Schumaker , Chuck Lever , Andrew Morton , Mark Hemment , Christoph Hellwig , David Howells Cc: linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 07 Feb 2022 15:46:01 +1100 Message-ID: <164420916116.29374.15552732854261345798.stgit@noble.brown> In-Reply-To: <164420889455.29374.17958998143835612560.stgit@noble.brown> References: <164420889455.29374.17958998143835612560.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This documentation for ->swap_activate() has been out-of-date for a long time. This patch updates it to match recent changes, and adds documentation for the associated ->swap_rw() Reviewed-by: Christoph Hellwig Signed-off-by: NeilBrown --- Documentation/filesystems/locking.rst | 18 ++++++++++++------ Documentation/filesystems/vfs.rst | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst index 3f9b1497ebb8..fbb10378d5ee 100644 --- a/Documentation/filesystems/locking.rst +++ b/Documentation/filesystems/locking.rst @@ -260,8 +260,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_activate)(struct swap_info_struct *sis, struct file *f, sector_t *span) int (*swap_deactivate)(struct file *); + int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter); locking rules: All except set_page_dirty and freepage may block @@ -290,6 +291,7 @@ is_partially_uptodate: yes error_remove_page: yes swap_activate: no swap_deactivate: no +swap_rw: yes, unlocks ====================== ======================== ========= =============== ->write_begin(), ->write_end() and ->readpage() may be called from @@ -392,15 +394,19 @@ 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() will be called to prepare the given file for swap. It +should perform any validation and preparation necessary to ensure that +writes can be performed with minimal memory allocation. It should call +add_swap_extent(), or the helper iomap_swapfile_activate(), and return +the number of extents added. If IO should be submitted through +->swap_rw(), it should set SWP_FS_OPS, otherwise IO will be submitted +directly to the block device ``sis->bdev``. ->swap_deactivate() will be called in the sys_swapoff() path after ->swap_activate() returned success. +->swap_rw will be called for swap IO if SWP_FS_OPS was set by ->swap_activate(). + file_lock_operations ==================== diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst index bf5c48066fac..779d23fc7954 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst @@ -751,8 +751,9 @@ cache in your filesystem. The following members are defined: 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_activate)(struct swap_info_struct *sis, struct file *f, sector_t *span) int (*swap_deactivate)(struct file *); + int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter); }; ``writepage`` @@ -959,15 +960,21 @@ cache in your filesystem. The following members are defined: unless you have them locked or reference counts increased. ``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. + + Called to prepare the given file for swap. It should perform + any validation and preparation necessary to ensure that writes + can be performed with minimal memory allocation. It should call + add_swap_extent(), or the helper iomap_swapfile_activate(), and + return the number of extents added. If IO should be submitted + through ->swap_rw(), it should set SWP_FS_OPS, otherwise IO will + be submitted directly to the block device ``sis->bdev``. ``swap_deactivate`` Called during swapoff on files where swap_activate was successful. +``swap_rw`` + Called to read or write swap pages when SWP_FS_OPS is set. The File Object ===============