From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBDB91DF244; Tue, 29 Apr 2025 07:35:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745912142; cv=none; b=uQKvm8gk0NM9XDD/yDI35ASahwV1qhlgmIM/NDZsm3I0/iQrXFSfijBwfTzpTtxVxxOHzHfbXghAthbYiBLukf07IFbh3ymxiboc9tBgJHysH5QwkJO87v1I/1xizeA5mRxFqrzZY3eGf4fAxfdPr0ztQx2uz5OKuI7vb7syaUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745912142; c=relaxed/simple; bh=Td/OW0PocctK9+HU5VmVxGwigIpRm7mGMXPMj1Fm61A=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=t69tKlaDTF9y9rQnBO8E5ILpiwyfJigRiyM8tVx4uVKkd43inoDXdyd1myNPJ/l/Tj8qLEdELO0U8Z3mFmqB0h5Xk1hWWM4Uje+xPLdEayWEtKvysqhOhKpVOyG1jxw5/sySzmzcHoHHO213YL1cbPydZJtC0HprHmfAuFpYe6U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CNaxnoXN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CNaxnoXN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D19FAC4CEE3; Tue, 29 Apr 2025 07:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745912142; bh=Td/OW0PocctK9+HU5VmVxGwigIpRm7mGMXPMj1Fm61A=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=CNaxnoXNa1Fn23kTcpL5DF3aobKYl4SVJ9nS1jOSZ+5LtF25rKn2vvbSF9Y+Sknoc aocfHWhAGvIj1ZxMn357cN1MAokvavVAxcQRABwbopleKBQrP/NIvYv8MGsAEmy54E l5muDwOFkjX1fIsUVifJnXRUjfGD0U480pyH0Qxw= Subject: Patch "xfs: flush inodegc before swapon" has been added to the 6.12-stable tree To: cem@kernel.org,dchinner@redhat.com,djwong@kernel.org,gregkh@linuxfoundation.org,hch@lst.de,xfs-stable@lists.linux.dev Cc: From: Date: Tue, 29 Apr 2025 09:35:13 +0200 In-Reply-To: <174586545460.480536.4621928282923794223.stgit@frogsfrogsfrogs> Message-ID: <2025042913-silenced-outfit-ecfb@gregkh> Precedence: bulk X-Mailing-List: xfs-stable@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled xfs: flush inodegc before swapon to the 6.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-flush-inodegc-before-swapon.patch and it can be found in the queue-6.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-136941-greg=kroah.com@vger.kernel.org Mon Apr 28 20:40:13 2025 From: "Darrick J. Wong" Date: Mon, 28 Apr 2025 11:40:06 -0700 Subject: xfs: flush inodegc before swapon To: djwong@kernel.org, xfs-stable@lists.linux.dev Cc: cem@kernel.org, dchinner@redhat.com, hch@lst.de, stable@vger.kernel.org Message-ID: <174586545460.480536.4621928282923794223.stgit@frogsfrogsfrogs> From: Christoph Hellwig Commit 2d873efd174bae9005776937d5ac6a96050266db upstream Fix the brand new xfstest that tries to swapon on a recently unshared file and use the chance to document the other bit of magic in this function. The big comment is taken from a mailinglist post by Dave Chinner. Fixes: 5e672cd69f0a53 ("xfs: introduce xfs_inodegc_push()") Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_aops.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -19,6 +19,7 @@ #include "xfs_reflink.h" #include "xfs_errortag.h" #include "xfs_error.h" +#include "xfs_icache.h" struct xfs_writepage_ctx { struct iomap_writepage_ctx ctx; @@ -533,7 +534,39 @@ xfs_vm_swap_activate( struct file *swap_file, sector_t *span) { - sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev; + struct xfs_inode *ip = XFS_I(file_inode(swap_file)); + + /* + * Swap file activation can race against concurrent shared extent + * removal in files that have been cloned. If this happens, + * iomap_swapfile_iter() can fail because it encountered a shared + * extent even though an operation is in progress to remove those + * shared extents. + * + * This race becomes problematic when we defer extent removal + * operations beyond the end of a syscall (i.e. use async background + * processing algorithms). Users think the extents are no longer + * shared, but iomap_swapfile_iter() still sees them as shared + * because the refcountbt entries for the extents being removed have + * not yet been updated. Hence the swapon call fails unexpectedly. + * + * The race condition is currently most obvious from the unlink() + * operation as extent removal is deferred until after the last + * reference to the inode goes away. We then process the extent + * removal asynchronously, hence triggers the "syscall completed but + * work not done" condition mentioned above. To close this race + * window, we need to flush any pending inodegc operations to ensure + * they have updated the refcountbt records before we try to map the + * swapfile. + */ + xfs_inodegc_flush(ip->i_mount); + + /* + * Direct the swap code to the correct block device when this file + * sits on the RT device. + */ + sis->bdev = xfs_inode_buftarg(ip)->bt_bdev; + return iomap_swapfile_activate(sis, swap_file, span, &xfs_read_iomap_ops); } Patches currently in stable-queue which might be from djwong@kernel.org are queue-6.12/xfs-do-not-check-needsrepair-if-ro-norecovery-mount.patch queue-6.12/xfs-do-not-allow-norecovery-mount-with-quotacheck.patch queue-6.12/iomap-skip-unnecessary-ifs_block_is_uptodate-check.patch queue-6.12/xfs-flush-inodegc-before-swapon.patch queue-6.12/xfs-rename-xfs_iomap_swapfile_activate-to-xfs_vm_swap_activate.patch