xfs-don-t-drop-errno-values-when-we-fail-to-ficlone-the-entire-range.patch
xfs-return-a-64-bit-block-count-from-xfs_btree_count_blocks.patch
xfs-fix-null-bno_hint-handling-in-xfs_rtallocate_rtg.patch
+xfs-return-from-xfs_symlink_verify-early-on-v4-filesystems.patch
+xfs-fix-scrub-tracepoints-when-inode-rooted-btrees-are-involved.patch
+xfs-only-run-precommits-once-per-transaction-object.patch
+xfs-unlock-inodes-when-erroring-out-of-xfs_trans_alloc_dir.patch
--- /dev/null
+From ffc3ea4f3c1cc83a86b7497b0c4b0aee7de5480d Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <djwong@kernel.org>
+Date: Mon, 2 Dec 2024 10:57:32 -0800
+Subject: xfs: fix scrub tracepoints when inode-rooted btrees are involved
+
+From: Darrick J. Wong <djwong@kernel.org>
+
+commit ffc3ea4f3c1cc83a86b7497b0c4b0aee7de5480d upstream.
+
+Fix a minor mistakes in the scrub tracepoints that can manifest when
+inode-rooted btrees are enabled. The existing code worked fine for bmap
+btrees, but we should tighten the code up to be less sloppy.
+
+Cc: <stable@vger.kernel.org> # v5.7
+Fixes: 92219c292af8dd ("xfs: convert btree cursor inode-private member names")
+Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/xfs/scrub/trace.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/xfs/scrub/trace.h
++++ b/fs/xfs/scrub/trace.h
+@@ -601,7 +601,7 @@ TRACE_EVENT(xchk_ifork_btree_op_error,
+ TP_fast_assign(
+ xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
+ __entry->dev = sc->mp->m_super->s_dev;
+- __entry->ino = sc->ip->i_ino;
++ __entry->ino = cur->bc_ino.ip->i_ino;
+ __entry->whichfork = cur->bc_ino.whichfork;
+ __entry->type = sc->sm->sm_type;
+ __assign_str(name);
--- /dev/null
+From 44d9b07e52db25035680713c3428016cadcd2ea1 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <djwong@kernel.org>
+Date: Mon, 2 Dec 2024 10:57:33 -0800
+Subject: xfs: only run precommits once per transaction object
+
+From: Darrick J. Wong <djwong@kernel.org>
+
+commit 44d9b07e52db25035680713c3428016cadcd2ea1 upstream.
+
+Committing a transaction tx0 with a defer ops chain of (A, B, C)
+creates a chain of transactions that looks like this:
+
+tx0 -> txA -> txB -> txC
+
+Prior to commit cb042117488dbf, __xfs_trans_commit would run precommits
+on tx0, then call xfs_defer_finish_noroll to convert A-C to tx[A-C].
+Unfortunately, after the finish_noroll loop we forgot to run precommits
+on txC. That was fixed by adding the second precommit call.
+
+Unfortunately, none of us remembered that xfs_defer_finish_noroll
+calls __xfs_trans_commit a second time to commit tx0 before finishing
+work A in txA and committing that. In other words, we run precommits
+twice on tx0:
+
+xfs_trans_commit(tx0)
+ __xfs_trans_commit(tx0, false)
+ xfs_trans_run_precommits(tx0)
+ xfs_defer_finish_noroll(tx0)
+ xfs_trans_roll(tx0)
+ txA = xfs_trans_dup(tx0)
+ __xfs_trans_commit(tx0, true)
+ xfs_trans_run_precommits(tx0)
+
+This currently isn't an issue because the inode item precommit is
+idempotent; the iunlink item precommit deletes itself so it can't be
+called again; and the buffer/dquot item precommits only check the incore
+objects for corruption. However, it doesn't make sense to run
+precommits twice.
+
+Fix this situation by only running precommits after finish_noroll.
+
+Cc: <stable@vger.kernel.org> # v6.4
+Fixes: cb042117488dbf ("xfs: defered work could create precommits")
+Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/xfs/xfs_trans.c | 16 ++++------------
+ 1 file changed, 4 insertions(+), 12 deletions(-)
+
+--- a/fs/xfs/xfs_trans.c
++++ b/fs/xfs/xfs_trans.c
+@@ -834,13 +834,6 @@ __xfs_trans_commit(
+
+ trace_xfs_trans_commit(tp, _RET_IP_);
+
+- error = xfs_trans_run_precommits(tp);
+- if (error) {
+- if (tp->t_flags & XFS_TRANS_PERM_LOG_RES)
+- xfs_defer_cancel(tp);
+- goto out_unreserve;
+- }
+-
+ /*
+ * Finish deferred items on final commit. Only permanent transactions
+ * should ever have deferred ops.
+@@ -851,13 +844,12 @@ __xfs_trans_commit(
+ error = xfs_defer_finish_noroll(&tp);
+ if (error)
+ goto out_unreserve;
+-
+- /* Run precommits from final tx in defer chain. */
+- error = xfs_trans_run_precommits(tp);
+- if (error)
+- goto out_unreserve;
+ }
+
++ error = xfs_trans_run_precommits(tp);
++ if (error)
++ goto out_unreserve;
++
+ /*
+ * If there is nothing to be logged by the transaction,
+ * then unlock all of the items associated with the
--- /dev/null
+From 7f8b718c58783f3ff0810b39e2f62f50ba2549f6 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <djwong@kernel.org>
+Date: Mon, 2 Dec 2024 10:57:43 -0800
+Subject: xfs: return from xfs_symlink_verify early on V4 filesystems
+
+From: Darrick J. Wong <djwong@kernel.org>
+
+commit 7f8b718c58783f3ff0810b39e2f62f50ba2549f6 upstream.
+
+V4 symlink blocks didn't have headers, so return early if this is a V4
+filesystem.
+
+Cc: <stable@vger.kernel.org> # v5.1
+Fixes: 39708c20ab5133 ("xfs: miscellaneous verifier magic value fixups")
+Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/xfs/libxfs/xfs_symlink_remote.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/fs/xfs/libxfs/xfs_symlink_remote.c
++++ b/fs/xfs/libxfs/xfs_symlink_remote.c
+@@ -92,8 +92,10 @@ xfs_symlink_verify(
+ struct xfs_mount *mp = bp->b_mount;
+ struct xfs_dsymlink_hdr *dsl = bp->b_addr;
+
++ /* no verification of non-crc buffers */
+ if (!xfs_has_crc(mp))
+- return __this_address;
++ return NULL;
++
+ if (!xfs_verify_magic(bp, dsl->sl_magic))
+ return __this_address;
+ if (!uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid))
--- /dev/null
+From 53b001a21c9dff73b64e8c909c41991f01d5d00f Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <djwong@kernel.org>
+Date: Mon, 2 Dec 2024 10:57:33 -0800
+Subject: xfs: unlock inodes when erroring out of xfs_trans_alloc_dir
+
+From: Darrick J. Wong <djwong@kernel.org>
+
+commit 53b001a21c9dff73b64e8c909c41991f01d5d00f upstream.
+
+Debugging a filesystem patch with generic/475 caused the system to hang
+after observing the following sequences in dmesg:
+
+ XFS (dm-0): metadata I/O error in "xfs_imap_to_bp+0x61/0xe0 [xfs]" at daddr 0x491520 len 32 error 5
+ XFS (dm-0): metadata I/O error in "xfs_btree_read_buf_block+0xba/0x160 [xfs]" at daddr 0x3445608 len 8 error 5
+ XFS (dm-0): metadata I/O error in "xfs_imap_to_bp+0x61/0xe0 [xfs]" at daddr 0x138e1c0 len 32 error 5
+ XFS (dm-0): log I/O error -5
+ XFS (dm-0): Metadata I/O Error (0x1) detected at xfs_trans_read_buf_map+0x1ea/0x4b0 [xfs] (fs/xfs/xfs_trans_buf.c:311). Shutting down filesystem.
+ XFS (dm-0): Please unmount the filesystem and rectify the problem(s)
+ XFS (dm-0): Internal error dqp->q_ino.reserved < dqp->q_ino.count at line 869 of file fs/xfs/xfs_trans_dquot.c. Caller xfs_trans_dqresv+0x236/0x440 [xfs]
+ XFS (dm-0): Corruption detected. Unmount and run xfs_repair
+ XFS (dm-0): Unmounting Filesystem be6bcbcc-9921-4deb-8d16-7cc94e335fa7
+
+The system is stuck in unmount trying to lock a couple of inodes so that
+they can be purged. The dquot corruption notice above is a clue to what
+happened -- a link() call tried to set up a transaction to link a child
+into a directory. Quota reservation for the transaction failed after IO
+errors shut down the filesystem, but then we forgot to unlock the inodes
+on our way out. Fix that.
+
+Cc: <stable@vger.kernel.org> # v6.10
+Fixes: bd5562111d5839 ("xfs: Hold inode locks in xfs_trans_alloc_dir")
+Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/xfs/xfs_trans.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/fs/xfs/xfs_trans.c
++++ b/fs/xfs/xfs_trans.c
+@@ -1374,5 +1374,8 @@ done:
+
+ out_cancel:
+ xfs_trans_cancel(tp);
++ xfs_iunlock(dp, XFS_ILOCK_EXCL);
++ if (dp != ip)
++ xfs_iunlock(ip, XFS_ILOCK_EXCL);
+ return error;
+ }