Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill
@ 2026-06-23  2:41 jiazhenyuan
  2026-06-24 17:08 ` Darrick J. Wong
  2026-07-01 12:50 ` Carlos Maiolino
  0 siblings, 2 replies; 3+ messages in thread
From: jiazhenyuan @ 2026-06-23  2:41 UTC (permalink / raw)
  To: cem, djwong, kees, linux-xfs, hch; +Cc: linux-kernel, kernel

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@uniontech.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill
  2026-06-23  2:41 [PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill jiazhenyuan
@ 2026-06-24 17:08 ` Darrick J. Wong
  2026-07-01 12:50 ` Carlos Maiolino
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2026-06-24 17:08 UTC (permalink / raw)
  To: jiazhenyuan; +Cc: cem, kees, linux-xfs, hch, linux-kernel, kernel

On Tue, Jun 23, 2026 at 10:41:53AM +0800, jiazhenyuan wrote:
> 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.

I have a stack of bugfixes waiting for the 7.2-rc rebase, and this
is one of them.  But since you posted first, I no longer have to seek
approval for it. :)

With this added,

Cc: <stable@vger.kernel.org> # v6.6
Fixes: 014ad53732d2ba ("xfs: use per-AG bitmaps to reap unused AG metadata blocks during repair")

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D



> Signed-off-by: jiazhenyuan <jiazhenyuan@uniontech.com>
> ---
>  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
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill
  2026-06-23  2:41 [PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill jiazhenyuan
  2026-06-24 17:08 ` Darrick J. Wong
@ 2026-07-01 12:50 ` Carlos Maiolino
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos Maiolino @ 2026-07-01 12:50 UTC (permalink / raw)
  To: djwong, kees, linux-xfs, hch, jiazhenyuan; +Cc: linux-kernel, kernel

On Tue, 23 Jun 2026 10:41:53 +0800, jiazhenyuan wrote:
> 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.
> 
> [...]

Applied to for-next, thanks!

[1/1] xfs: fix AGFL extent count calculation in xrep_agfl_fill
      commit: 7f53bf79bdbac36b644b9fe7a77516baf8de5109

Best regards,
-- 
Carlos Maiolino <cem@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-01 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23  2:41 [PATCH] xfs: fix AGFL extent count calculation in xrep_agfl_fill jiazhenyuan
2026-06-24 17:08 ` Darrick J. Wong
2026-07-01 12:50 ` Carlos Maiolino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox