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
  2026-11-05  7:52 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2026-11-05  7:52 UTC | newest]

Thread overview: 3+ 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
2026-11-05  7:52 ` Christoph Hellwig

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®