xfs: keep successful near rt allocations
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.
--- fs/xfs/xfs_rtalloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/xfs/xfs_rtalloc.c +5 -1
@@ -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
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_rtgto 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")Cc [email protected] # v6.12Reported-by Christian Andres Saide <[email protected]>Signed-off-by Rik van Riel <[email protected]>
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@@ -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
Looks good:
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_rtgto 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]>