mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xfs: keep successful near rt allocations
@ 2026-11-04 15:01 Rik van Riel
  2026-11-04 15:45 ` Carlos Maiolino
  0 siblings, 1 reply; 2+ messages in thread
From: Rik van Riel @ 2026-11-04 15:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-xfs, Carlos Maiolino, Darrick J. Wong, Christoph Hellwig,
	kernel-team, Christian Andres Saide

XFS realtime allocations first attempt to allocate space near where
other parts of a file already are. If that allocation succeeds, it
does not have to do a global search for free space.

Unfortunately, a code cleanup a while ago causes xfs_rtallocate_rtg
to unconditionally do the global search, even when the search for a
nearby extent has succeeded.

Fix it by running the global search only when the near search did
not find available space.

Found by noticing higher kernel CPU use and examining the profile.

Fixes: fd048a1bb391d ("xfs: rework the rtalloc fallback handling")
Cc: stable@vger.kernel.org # v6.12
Reported-by: Christian Andres Saide <csaide@meta.com>
Signed-off-by: Rik van Riel <riel@surriel.com>
---
 fs/xfs/xfs_rtalloc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 84efe5a8fb11..31d90828b4e9 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1997,10 +1997,14 @@ xfs_rtallocate_rtg(
 		if (error == -ENOSPC) {
 			xfs_rtbuf_cache_relse(&args);
 			error = 0;
+			start = 0;
 		}
 	}
 
-	if (!error) {
+	/*
+	 * Global search, runs when the near search did not find space.
+	 */
+	if (!error && !start) {
 		error = xfs_rtallocate_extent_size(&args, minlen, maxlen, &len,
 				prod, &rtx);
 	}
-- 
2.56.0



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

* Re: [PATCH] xfs: keep successful near rt allocations
  2026-11-04 15:01 [PATCH] xfs: keep successful near rt allocations Rik van Riel
@ 2026-11-04 15:45 ` Carlos Maiolino
  0 siblings, 0 replies; 2+ messages in thread
From: Carlos Maiolino @ 2026-11-04 15:45 UTC (permalink / raw)
  To: Rik van Riel
  Cc: linux-kernel, linux-xfs, Darrick J. Wong, Christoph Hellwig,
	kernel-team, Christian Andres Saide

On Wed, Nov 04, 2026 at 10:01:15AM -0500, Rik van Riel wrote:
> XFS realtime allocations first attempt to allocate space near where
> other parts of a file already are. If that allocation succeeds, it
> does not have to do a global search for free space.
> 
> Unfortunately, a code cleanup a while ago causes xfs_rtallocate_rtg
> to unconditionally do the global search, even when the search for a
> nearby extent has succeeded.
> 
> Fix it by running the global search only when the near search did
> not find available space.
> 
> Found by noticing higher kernel CPU use and examining the profile.
> 
> Fixes: fd048a1bb391d ("xfs: rework the rtalloc fallback handling")
> Cc: stable@vger.kernel.org # v6.12
> Reported-by: Christian Andres Saide <csaide@meta.com>
> Signed-off-by: Rik van Riel <riel@surriel.com>

This sounds correct yes.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>


> ---
>  fs/xfs/xfs_rtalloc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 84efe5a8fb11..31d90828b4e9 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1997,10 +1997,14 @@ xfs_rtallocate_rtg(
>  		if (error == -ENOSPC) {
>  			xfs_rtbuf_cache_relse(&args);
>  			error = 0;
> +			start = 0;
>  		}
>  	}
>  
> -	if (!error) {
> +	/*
> +	 * Global search, runs when the near search did not find space.
> +	 */
> +	if (!error && !start) {
>  		error = xfs_rtallocate_extent_size(&args, minlen, maxlen, &len,
>  				prod, &rtx);
>  	}
> -- 
> 2.56.0
> 
> 

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

end of thread, other threads:[~2026-11-04 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 15:01 [PATCH] xfs: keep successful near rt allocations Rik van Riel
2026-11-04 15:45 ` Carlos Maiolino

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

all inboxes | Powered by JetHome®