[PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill

From: jiazhenyuan

Date: Mon Jun 22 2026 - 22:43:08 EST


In xrep_agfl_fill(), the call to xagb_bitmap_set() passes
'agbno - 1' as the length argument. However, xagb_bitmap_set()
expects a length (number of blocks), not an end block number.
Passing 'agbno - 1' causes used_extents to record an incorrect
range.

Fix this by calculating the correct length as 'agbno - start',
which represents the actual number of blocks filled into the AGFL.

Signed-off-by: jiazhenyuan <jiazhenyuan@xxxxxxxxxxxxx>
---
fs/xfs/scrub/agheader_repair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
index ae9ed5f280d0..b0ffd37afb45 100644
--- a/fs/xfs/scrub/agheader_repair.c
+++ b/fs/xfs/scrub/agheader_repair.c
@@ -652,7 +652,7 @@ xrep_agfl_fill(
while (agbno < start + len && af->fl_off < af->flcount)
af->agfl_bno[af->fl_off++] = cpu_to_be32(agbno++);

- error = xagb_bitmap_set(&af->used_extents, start, agbno - 1);
+ error = xagb_bitmap_set(&af->used_extents, start, agbno - start);
if (error)
return error;

--
2.20.1