* [PATCH 1/6] xfs: fix xfs_rtrmapbt_mem_cursor for non-rmap filesystems
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
@ 2026-09-02 5:43 ` Darrick J. Wong
2026-09-02 5:43 ` [PATCH 2/6] xfs: preserve owner on in-memory btree creation Darrick J. Wong
` (5 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2026-09-02 5:43 UTC (permalink / raw)
To: cem, hch, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
It's possible to construct an in-memory rtrmap btree for filesystems
that don't have the rmap feature enabled. The kernel doesn't do this,
but xfs_repair will, if asked to reindex a filesystem that has rtreflink
enabled but not rtrmap. Therefore, we must create the cursor with
enough levels to handle a maximally sized btree possible.
Note that the rtrmapbt btree cursor slab creates objects large enough to
handle xfs_rtrmap_maxlevels_ondisk() levels, so setting bc_nlevels to
the same value isn't costing us any extra memory.
Cc: <stable@vger.kernel.org> # v6.14
Fixes: 4a61f12eb11958 ("xfs: create a shadow rmap btree during realtime rmap repair")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_rtrmap_btree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_rtrmap_btree.c b/fs/xfs/libxfs/xfs_rtrmap_btree.c
index 0cb2113d5b4045..a15e460a1ec7f4 100644
--- a/fs/xfs/libxfs/xfs_rtrmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rtrmap_btree.c
@@ -618,7 +618,7 @@ xfs_rtrmapbt_mem_cursor(
struct xfs_btree_cur *cur;
cur = xfs_btree_alloc_cursor(mp, tp, &xfs_rtrmapbt_mem_ops,
- mp->m_rtrmap_maxlevels, xfs_rtrmapbt_cur_cache);
+ xfs_rtrmapbt_maxlevels_ondisk(), xfs_rtrmapbt_cur_cache);
cur->bc_mem.xfbtree = xfbt;
cur->bc_nlevels = xfbt->nlevels;
cur->bc_group = xfs_group_hold(rtg_group(rtg));
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 2/6] xfs: preserve owner on in-memory btree creation
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
2026-09-02 5:43 ` [PATCH 1/6] xfs: fix xfs_rtrmapbt_mem_cursor for non-rmap filesystems Darrick J. Wong
@ 2026-09-02 5:43 ` Darrick J. Wong
2026-09-02 5:44 ` [PATCH 3/6] xfs: don't leak new_bp if xfs_btree_bload_drop_buf fails Darrick J. Wong
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2026-09-02 5:43 UTC (permalink / raw)
To: cem, hch, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM points out a minor bug where a higher level function creating an
in-memory btree is required to pass in an owner number, but the creation
function erases that. In-memory btrees are ephemeral so this really
doesn't matter except for debugging. But let's fix this papercut.
Cc: <stable@vger.kernel.org> # v6.9
Fixes: a095686a238352 ("xfs: support in-memory btrees")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_btree_mem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_btree_mem.c b/fs/xfs/libxfs/xfs_btree_mem.c
index 37136a70e56d66..1d83a4251ceeb6 100644
--- a/fs/xfs/libxfs/xfs_btree_mem.c
+++ b/fs/xfs/libxfs/xfs_btree_mem.c
@@ -117,6 +117,7 @@ xfbtree_init(
struct xfs_buftarg *btp,
const struct xfs_btree_ops *ops)
{
+ unsigned long long owner = xfbt->owner;
unsigned int blocklen = xfbtree_rec_bytes(mp, ops);
unsigned int keyptr_len;
int error;
@@ -133,6 +134,7 @@ xfbtree_init(
memset(xfbt, 0, sizeof(*xfbt));
xfbt->target = btp;
+ xfbt->owner = owner;
/* Set up min/maxrecs for this btree. */
keyptr_len = ops->key_len + sizeof(__be64);
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 3/6] xfs: don't leak new_bp if xfs_btree_bload_drop_buf fails
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
2026-09-02 5:43 ` [PATCH 1/6] xfs: fix xfs_rtrmapbt_mem_cursor for non-rmap filesystems Darrick J. Wong
2026-09-02 5:43 ` [PATCH 2/6] xfs: preserve owner on in-memory btree creation Darrick J. Wong
@ 2026-09-02 5:44 ` Darrick J. Wong
2026-09-02 5:44 ` [PATCH 4/6] xfs: actually recover intended file sizes in xfs_xmi_item_recover_intent Darrick J. Wong
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2026-09-02 5:44 UTC (permalink / raw)
To: cem, hch, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM observes that in xfs_btree_bload_prep_block,
xfs_btree_bload_drop_buf can hit an IO error if writing the delwri
buffer list to disk fails. In this case, we fail to release new_bp,
which means we lose a locked buffer. Fix that.
Cc: <stable@vger.kernel.org> # v6.8
Fixes: e069d549705e49 ("xfs: constrain dirty buffers while formatting a staged btree")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_btree_staging.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_btree_staging.c b/fs/xfs/libxfs/xfs_btree_staging.c
index 7314dab4bcfbc6..561fd2c2e95055 100644
--- a/fs/xfs/libxfs/xfs_btree_staging.c
+++ b/fs/xfs/libxfs/xfs_btree_staging.c
@@ -336,8 +336,10 @@ xfs_btree_bload_prep_block(
xfs_btree_set_sibling(cur, *blockp, &new_ptr, XFS_BB_RIGHTSIB);
ret = xfs_btree_bload_drop_buf(bbl, buffers_list, bpp);
- if (ret)
+ if (ret) {
+ xfs_buf_relse(new_bp);
return ret;
+ }
/* Initialize the new btree block. */
xfs_btree_init_block_cur(cur, new_bp, level, nr_this_block);
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 4/6] xfs: actually recover intended file sizes in xfs_xmi_item_recover_intent
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
` (2 preceding siblings ...)
2026-09-02 5:44 ` [PATCH 3/6] xfs: don't leak new_bp if xfs_btree_bload_drop_buf fails Darrick J. Wong
@ 2026-09-02 5:44 ` Darrick J. Wong
2026-09-02 5:44 ` [PATCH 5/6] xfs: don't modify file attributes or poke fsnotify for dry runs Darrick J. Wong
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2026-09-02 5:44 UTC (permalink / raw)
To: cem, hch, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM points out that xfs_xmi_item_recover_intent doesn't actually
restore the isize1 and isize2 fields that were recovered from an
unfinished exchmaps log intent item. Instead, xfs_exchmaps_init_intent
sets the wrong isize values from the recovered inodes, with the result
that the file sizes are not set correctly when item recovery finishes.
Fix this by restoring isize[12] from the log item.
Cc: <stable@vger.kernel.org> # v6.10
Fixes: 966ceafc7a4371 ("xfs: create deferred log items for file mapping exchanges")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_exchmaps_item.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c
index c3745d33e54ea2..dd5d92ca1010fe 100644
--- a/fs/xfs/xfs_exchmaps_item.c
+++ b/fs/xfs/xfs_exchmaps_item.c
@@ -344,7 +344,17 @@ xfs_xmi_validate(
if (!xfs_verify_fileext(mp, xlf->xmi_startoff1, xlf->xmi_blockcount))
return false;
- return xfs_verify_fileext(mp, xlf->xmi_startoff2, xlf->xmi_blockcount);
+ if (!xfs_verify_fileext(mp, xlf->xmi_startoff2, xlf->xmi_blockcount))
+ return false;
+
+ if (xlf->xmi_flags & XFS_EXCHMAPS_SET_SIZES) {
+ if ((int64_t)xlf->xmi_isize1 < 0)
+ return false;
+ if ((int64_t)xlf->xmi_isize2 < 0)
+ return false;
+ }
+
+ return true;
}
/*
@@ -403,6 +413,13 @@ xfs_xmi_item_recover_intent(
*ipp1 = ip1;
*ipp2 = ip2;
xmi = xfs_exchmaps_init_intent(req);
+
+ /* Restore intended file sizes from recovered logged item */
+ if (req->flags & XFS_EXCHMAPS_SET_SIZES) {
+ xmi->xmi_isize1 = xlf->xmi_isize1;
+ xmi->xmi_isize2 = xlf->xmi_isize2;
+ }
+
xfs_defer_add_item(dfp, &xmi->xmi_list);
return xmi;
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 5/6] xfs: don't modify file attributes or poke fsnotify for dry runs
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
` (3 preceding siblings ...)
2026-09-02 5:44 ` [PATCH 4/6] xfs: actually recover intended file sizes in xfs_xmi_item_recover_intent Darrick J. Wong
@ 2026-09-02 5:44 ` Darrick J. Wong
2026-09-02 7:13 ` Christoph Hellwig
2026-09-02 5:44 ` [PATCH 6/6] xfs: fix bnobt repair space reservation disposal failure Darrick J. Wong
2026-09-07 6:30 ` [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Carlos Maiolino
6 siblings, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2026-09-02 5:44 UTC (permalink / raw)
To: cem, hch, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
I noticed that we shouldn't be removing file privileges when doing a dry
run of an exchange-range operation. LOLLM also points out that a dry
run shouldn't poke fsnotify because we don't actually change the files.
Fix both by gating them on !DRY_RUN.
Cc: <stable@vger.kernel.org> # v6.10
Fixes: 42672471f938cd ("xfs: bind together the front and back ends of the file range exchange code")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
---
fs/xfs/xfs_exchrange.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c
index 94965a6c2187ff..c69ecd6a19de4f 100644
--- a/fs/xfs/xfs_exchrange.c
+++ b/fs/xfs/xfs_exchrange.c
@@ -504,6 +504,9 @@ xfs_exchange_range_finish(
{
int error;
+ if (fxr->flags & XFS_EXCHANGE_RANGE_DRY_RUN)
+ return 0;
+
error = file_remove_privs(fxr->file1);
if (error)
return error;
@@ -783,9 +786,12 @@ xfs_exchange_range(
if (ret)
return ret;
- fsnotify_modify(fxr->file1);
- if (fxr->file2 != fxr->file1)
- fsnotify_modify(fxr->file2);
+ if (!(fxr->flags & XFS_EXCHANGE_RANGE_DRY_RUN)) {
+ fsnotify_modify(fxr->file1);
+ if (fxr->file2 != fxr->file1)
+ fsnotify_modify(fxr->file2);
+ }
+
return 0;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 6/6] xfs: fix bnobt repair space reservation disposal failure
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
` (4 preceding siblings ...)
2026-09-02 5:44 ` [PATCH 5/6] xfs: don't modify file attributes or poke fsnotify for dry runs Darrick J. Wong
@ 2026-09-02 5:44 ` Darrick J. Wong
2026-09-07 6:30 ` [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Carlos Maiolino
6 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2026-09-02 5:44 UTC (permalink / raw)
To: cem, hch, djwong; +Cc: stable, linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
LOLLM complains that we don't bubble failures from xrep_abt_dispose_one
upwards in the callstack. A failure to clean up the space used (or
reserved but not used) by the new bnobt/cntbt should be reported.
Cc: <stable@vger.kernel.org> # v6.8
Fixes: 4bdfd7d15747b1 ("xfs: repair free space btrees")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/scrub/alloc_repair.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/scrub/alloc_repair.c b/fs/xfs/scrub/alloc_repair.c
index dce6ab0429dcfe..95e318e4f3a6c7 100644
--- a/fs/xfs/scrub/alloc_repair.c
+++ b/fs/xfs/scrub/alloc_repair.c
@@ -571,7 +571,7 @@ xrep_abt_dispose_one(
* allocation, and blocks that didn't get used can be freed via the usual
* (deferred) means.
*/
-STATIC void
+STATIC int
xrep_abt_dispose_reservations(
struct xrep_abt *ra,
int error)
@@ -582,9 +582,13 @@ xrep_abt_dispose_reservations(
goto junkit;
list_for_each_entry_safe(resv, n, &ra->new_bnobt.resv_list, list) {
- error = xrep_abt_dispose_one(ra, resv);
- if (error)
+ int error2 = xrep_abt_dispose_one(ra, resv);
+
+ if (error2) {
+ if (!error)
+ error = error2;
goto junkit;
+ }
}
junkit:
@@ -596,6 +600,7 @@ xrep_abt_dispose_reservations(
xrep_newbt_cancel(&ra->new_bnobt);
xrep_newbt_cancel(&ra->new_cntbt);
+ return error;
}
/* Retrieve free space data for bulk load. */
@@ -801,7 +806,9 @@ xrep_abt_build_new_trees(
goto err_newbt;
/* Dispose of any unused blocks and the accounting information. */
- xrep_abt_dispose_reservations(ra, error);
+ error = xrep_abt_dispose_reservations(ra, error);
+ if (error)
+ return error;
return xrep_roll_ag_trans(sc);
@@ -812,8 +819,7 @@ xrep_abt_build_new_trees(
xfs_btree_del_cursor(cnt_cur, error);
xfs_btree_del_cursor(bno_cur, error);
err_newbt:
- xrep_abt_dispose_reservations(ra, error);
- return error;
+ return xrep_abt_dispose_reservations(ra, error);
}
/*
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6
2026-09-02 5:41 [PATCHSET v2 2/5] xfs: LLM-inspired bug fixes, part 6 Darrick J. Wong
` (5 preceding siblings ...)
2026-09-02 5:44 ` [PATCH 6/6] xfs: fix bnobt repair space reservation disposal failure Darrick J. Wong
@ 2026-09-07 6:30 ` Carlos Maiolino
6 siblings, 0 replies; 12+ messages in thread
From: Carlos Maiolino @ 2026-09-07 6:30 UTC (permalink / raw)
To: hch, Darrick J. Wong; +Cc: stable, linux-xfs
On Tue, 01 Sep 2026 22:41:37 -0700, Darrick J. Wong wrote:
> Here's a sixth batch of xfs fixes resulting from a LLaMma. Mwa mwa
> mwa...
>
> v2: add RVBs, address some review comments
>
> If you're going to start using this code, I strongly recommend pulling
> from my git trees, which are linked below.
>
> [...]
Applied to for-next, thanks!
[1/6] xfs: fix xfs_rtrmapbt_mem_cursor for non-rmap filesystems
commit: 022d5f5fce7f0b6125d404eb74044e6238aef369
[2/6] xfs: preserve owner on in-memory btree creation
commit: 5287e56cba3be4a64bff9f73bce5964fda2590dc
[3/6] xfs: don't leak new_bp if xfs_btree_bload_drop_buf fails
commit: f1930bc578095409c2dcfca6e4e898b24f0f0de6
[4/6] xfs: actually recover intended file sizes in xfs_xmi_item_recover_intent
commit: b71ae66863e4320a3b7313b53bb4d65f1718d58b
[5/6] xfs: don't modify file attributes or poke fsnotify for dry runs
commit: 365fe37e10ea75840165f13322aa8481ea11dfef
[6/6] xfs: fix bnobt repair space reservation disposal failure
commit: c83d1ef97ee3b0b92797d4b4932a3a813ba05b86
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread