Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1568012pxp; Sun, 6 Mar 2022 19:26:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJZG8gi57f/uoaybO+98XHRlmd0SuLhTKiq9J2QzvwQyZmp0gESbcGbMsmBPwYnQiuI+td X-Received: by 2002:a17:906:7316:b0:6d7:16be:b584 with SMTP id di22-20020a170906731600b006d716beb584mr7565496ejc.759.1646623584472; Sun, 06 Mar 2022 19:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646623584; cv=none; d=google.com; s=arc-20160816; b=gs2UYsXaUO7GUfpMXsr2CyX5QihtdXH+7LDRvFpWN3eEuO8+9do+5eBOGLPnorVhiw TnEXXFNUAi+0x9zQvsZWxW40ADGQxm2T1yotJZLq7FqFz/vLBV6zvhvWMX3ThdzUO4+x EKPvulfDHf8A7jnMUzXW0ukiuaZ2ns+4yYCGBHnc93Qwh3dfY7gvLGqLJixGAeLjUyaV cnk4PhLyEl/BEXsMIjOaLSDVvBxwnEyqoG07U/h5Q7kR6D6GgwVWJfHm3s4uol4myuTV 6WCyZSMHFYMWwHXg6HEhDUIJJHnPEBQtvLFiSd1Ql/3cuQke0R5iSvDMxjK2IiT3DxrU MdGw== 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=iBQh8g2Z0/gpIu2xpFaovCRMpIaLf7qMUkrtPz3h8/4gZ2DoeIi9OCQ1jyvx0XDJjV kZf8TYJcfzsk1k4hiPWd+KiN5VfyK9imLZN6CZJH8wUvqkgbP90uw+gwDciwHgnt2WZa ekUVKerHS9nM+Dx8jg0PT1kp8P3YYTTqJDCVtcmvsgRWpQyd+BnQ0fGfFjYR1PVdwSco +dAgqjDqJ7HPkpcY5dfBAMftB2ZNERAEd/r3he7ZuglKoebTb9Uq3d55ZRttPTVMTMIM agJ+PoBY7zmWyLVELjdKWorjJd5Q/AY0VRoTbBmRqsTcb2pw+zhUKnpwWDkSVwypQJ0I qVHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YjZepQF0; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd40-20020a17090796a800b006a66824a4a4si6802655ejc.47.2022.03.06.19.26.02; Sun, 06 Mar 2022 19:26:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YjZepQF0; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S234531AbiCFXwG (ORCPT + 99 others); Sun, 6 Mar 2022 18:52:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234530AbiCFXwE (ORCPT ); Sun, 6 Mar 2022 18:52:04 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7334D636; Sun, 6 Mar 2022 15:51:11 -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 E3C31210FC; Sun, 6 Mar 2022 23:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646610669; 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=YjZepQF061lFQtMDYuxKgzjComcvQmjzk5sJbR1sNgpEb8aIqLPULAB9jhDE4yUDqLLKKG hzSERVx6pOC0p9P9EXFPYeMp1kCMJpflHDxX0VSF+U1llI1/7YAQfd4wPG7hbcE853O16x SR13P73eLt/8pnFlAB53rm1Y8O8gtwc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646610669; 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=Sa/zBX2QGO3pFaQuJxKcwvuCXk1rUQElIyIaYWcGidna/4i1vza1nI/z+zVCKcUSjHZcwi V/mTUlDB+c/3TwDQ== 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 15DCA134CD; Sun, 6 Mar 2022 23:51:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id N5aGMetIJWJiWgAAMHmgww (envelope-from ); Sun, 06 Mar 2022 23:51:07 +0000 Subject: [PATCH 07/10] DOC: update documentation for swap_activate and swap_rw From: NeilBrown To: Andrew Morton Cc: Christoph Hellwig , David Howells , linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 07 Mar 2022 10:49:38 +1100 Message-ID: <164661057807.13454.668679646256601324.stgit@noble.brown> In-Reply-To: <164661047081.13454.11679636335222534920.stgit@noble.brown> References: <164661047081.13454.11679636335222534920.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=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-kernel@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 ===============