Skip to contentSkip to conversation

xfs: keep successful near rt allocations

PATCH Applied Rik van Riel 3 participants 4 messages Nov 4 – Nov 9 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: keep successful near rt allocations

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")
---
 fs/xfs/xfs_rtalloc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/xfs/xfs_rtalloc.c +5 -1
index 84efe5a8fb11..31d90828b4e9 100644
@@ -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);
 	}
Signature · 1 line
2.56.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Rik van Riel

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.

Quoted 6 lines

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

Fixes fd048a1bb391d ("xfs: rework the rtalloc fallback handling")

This sounds correct yes.

Quoted 28 lines
---
 fs/xfs/xfs_rtalloc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/xfs/xfs_rtalloc.c +5 -1
index 84efe5a8fb11..31d90828b4e9 100644
@@ -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);
 	}
Signature · 1 line
2.56.0
maintainer Applied
#3 lore raw
In reply to Rik van Riel
Quoted 9 lines · Rik van Riel

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.

[...]

Applied to for-next, thanks!

[1/1] xfs: keep successful near rt allocations

      commit: 0a2b9af9bd5f2f3be9d4339205d62616c0e0eb08

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>