Skip to content

Commit 1b5d639

Browse files
osandovDarrick J. Wong
authored andcommitted
xfs: return maximum free size from xfs_rtany_summary()
Instead of only returning whether there is any free space, return the maximum size, which is fast thanks to the previous commit. This will be used by two upcoming optimizations. Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent e23aaf4 commit 1b5d639

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ xfs_rtany_summary(
4747
int low, /* low log2 extent size */
4848
int high, /* high log2 extent size */
4949
xfs_fileoff_t bbno, /* bitmap block number */
50-
int *stat) /* out: any good extents here? */
50+
int *maxlog) /* out: max log2 extent size free */
5151
{
5252
struct xfs_mount *mp = args->mp;
5353
int error;
@@ -58,7 +58,7 @@ xfs_rtany_summary(
5858
if (mp->m_rsum_cache) {
5959
high = min(high, mp->m_rsum_cache[bbno] - 1);
6060
if (low > high) {
61-
*stat = 0;
61+
*maxlog = -1;
6262
return 0;
6363
}
6464
}
@@ -78,14 +78,14 @@ xfs_rtany_summary(
7878
* If there are any, return success.
7979
*/
8080
if (sum) {
81-
*stat = 1;
81+
*maxlog = log;
8282
goto out;
8383
}
8484
}
8585
/*
8686
* Found nothing, return failure.
8787
*/
88-
*stat = 0;
88+
*maxlog = -1;
8989
out:
9090
/* There were no extents at levels > log. */
9191
if (mp->m_rsum_cache && log + 1 < mp->m_rsum_cache[bbno])
@@ -434,7 +434,7 @@ xfs_rtallocate_extent_near(
434434
xfs_rtxnum_t *rtx) /* out: start rtext allocated */
435435
{
436436
struct xfs_mount *mp = args->mp;
437-
int any; /* any useful extents from summary */
437+
int maxlog; /* max useful extent from summary */
438438
xfs_fileoff_t bbno; /* bitmap block number */
439439
int error;
440440
int i; /* bitmap block offset (loop control) */
@@ -488,15 +488,15 @@ xfs_rtallocate_extent_near(
488488
* starting in this bitmap block.
489489
*/
490490
error = xfs_rtany_summary(args, log2len, mp->m_rsumlevels - 1,
491-
bbno + i, &any);
491+
bbno + i, &maxlog);
492492
if (error) {
493493
return error;
494494
}
495495
/*
496496
* If there are any useful extents starting here, try
497497
* allocating one.
498498
*/
499-
if (any) {
499+
if (maxlog >= 0) {
500500
/*
501501
* On the positive side of the starting location.
502502
*/
@@ -537,7 +537,7 @@ xfs_rtallocate_extent_near(
537537
error = xfs_rtany_summary(args,
538538
log2len,
539539
mp->m_rsumlevels - 1,
540-
bbno + j, &any);
540+
bbno + j, &maxlog);
541541
if (error) {
542542
return error;
543543
}
@@ -549,7 +549,7 @@ xfs_rtallocate_extent_near(
549549
* extent given, we've already tried
550550
* that allocation, don't do it again.
551551
*/
552-
if (any)
552+
if (maxlog >= 0)
553553
continue;
554554
error = xfs_rtallocate_extent_block(args,
555555
bbno + j, minlen,

0 commit comments

Comments
 (0)