From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382745; b=N1C7eSgCYz/XKpCDOwENtrnfC5qVrjUCIP0O5rQdrnhO41OjCgfZvQrhBfjwSRJZau8s GA4LPGsF6srrpm+oS7EE2vlepaWO8S84LQ+oeQ1UX58nt/VJrwzFVgSbUSXIqhFHCYoHI qe7L39NYHhqkgZozx4gS1tmF/pFOEIcw6hEVqQNcKY0XMpwzCKtbkah1aE1yP/lIaQ2ja rbzGUimrc+Y3zpp4Pvl9ka5bGdyFpFfFyfeyhppxUSHPzG0flL+bgIKFz4mpBynyQ7ITl uaQp/3z89K2ZT6zaNTL8S1BFv1bBuMGHeOy4OpmPbTId9/YOPsLk9YcB6jN3JTCLE2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382745; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=vaf3goedc0dOJHYi8/xiXcPgbiMt+HouSWaWXb4XC48=; b=MCYVjyR1vjRQP2xCbjV1lk0k4D8cfx4H/TlDpkdspnP4mUc8bTD9Avvv4eMDRXFWKn0O aJO9I/NLAgLU+eVj47qp9ujIyUpPX9ID1A6PL/XO6O9rScWmf3axyuY157OrIy3aQdTEd 2PJ3qlvWOVxQW9e1VF4tT6SfWmXFmGeSQpC6o8MiD3Y0v7CYTHuQMVrD58XgP45OWfd1U q+ylEgLwUiMU3gYUImtuGpZ+KbDUwaTnCk0+gbtoiKV64UrMVFM5ovoP25k4+mtMvhpO2 gsGc997M0HtWbx5PJoj/1FMDkciowZ9JIlk9fF7uOzFjSli9ysKcMMFjxTKJaXKsmJw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ypDbLSSv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FFE9606A336; Fri, 4 Dec 2026 11:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ypDbLSSv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B83A1F000CE; Fri, 4 Dec 2026 11:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382744; bh=vaf3goedc0dOJHYi8/xiXcPgbiMt+HouSWaWXb4XC48=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ypDbLSSvl1dhZV6NGZObJ+9pXBvcL0WrerWQLaqF7NjO5TJ004+GAvVgUYwn4/K7K PYC6M9SvB1a1sKVLVw2SQFJKY0iF0qvgkI3Rzrk+PPOkiLusAqGZ/ovmHDaN2EqiLP Hl21PLAUNWYa+wD9PrfXWKb14GzegDasOW08pghQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daejun Park , Christoph Hellwig , Carlos Maiolino Subject: [PATCH 6.18 545/703] xfs: break layouts before swapping extents Date: Fri, 4 Dec 2026 19:07:24 +0900 Message-ID: <20261204100642.279681453@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daejun Park commit 0d8026c7ac0c79a8ebe2942a3c3114c06aced734 upstream. XFS_IOC_SWAPEXT does not break pNFS layouts. A client can keep writing to blocks that the swap moved to the temporary file. xfs_fsr frees those blocks when it closes that file. The writes then land in whatever reuses them. Lock with xfs_ilock2_io_mmap(), as the exchange-range ioctls do. Fixes: 781355c6e5ae ("xfs: recall pNFS layouts on conflicting access") Cc: stable@vger.kernel.org Signed-off-by: Daejun Park Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_bmap_util.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1524,9 +1524,9 @@ xfs_swap_extents( * page cache safely. Once we have done this we can take the ilocks and * do the rest of the checks. */ - lock_two_nondirectories(VFS_I(ip), VFS_I(tip)); - filemap_invalidate_lock_two(VFS_I(ip)->i_mapping, - VFS_I(tip)->i_mapping); + error = xfs_ilock2_io_mmap(ip, tip); + if (error) + return error; /* Verify that both files have the same format */ if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) { @@ -1732,9 +1732,7 @@ out_unlock_ilock: xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(tip, XFS_ILOCK_EXCL); out_unlock: - filemap_invalidate_unlock_two(VFS_I(ip)->i_mapping, - VFS_I(tip)->i_mapping); - unlock_two_nondirectories(VFS_I(ip), VFS_I(tip)); + xfs_iunlock2_io_mmap(ip, tip); return error; out_trans_cancel: