Commit e0f7422f authored by Omar Sandoval's avatar Omar Sandoval Committed by Darrick J. Wong

xfs: don't look for end of extent further than necessary in xfs_rtallocate_extent_near()

As explained in the previous commit, xfs_rtallocate_extent_near() looks
for the end of a free extent when searching backwards from the target
bitmap block. Since the previous commit, it searches from the last
bitmap block it checked to the bitmap block containing the start of the
extent.

This may still be more than necessary, since the free extent may not be
that long. We know the maximum size of the free extent from the realtime
summary. Use that to compute how many bitmap blocks we actually need to
check.
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 85fa2c77
...@@ -527,13 +527,30 @@ xfs_rtallocate_extent_near( ...@@ -527,13 +527,30 @@ xfs_rtallocate_extent_near(
* On the negative side of the starting location. * On the negative side of the starting location.
*/ */
else { /* i < 0 */ else { /* i < 0 */
int maxblocks;
/*
* Loop backwards to find the end of the extent
* we found in the realtime summary.
*
* maxblocks is the maximum possible number of
* bitmap blocks from the start of the extent
* to the end of the extent.
*/
if (maxlog == 0)
maxblocks = 0;
else if (maxlog < mp->m_blkbit_log)
maxblocks = 1;
else
maxblocks = 2 << (maxlog - mp->m_blkbit_log);
/* /*
* Loop backwards through the bitmap blocks * We need to check bbno + i + maxblocks down to
* from where we last checked down to where we * bbno + i. We already checked bbno down to
* are now. There should be an extent which * bbno + j + 1, so we don't need to check those
* ends in this bitmap block and is long * again.
* enough.
*/ */
j = min(i + maxblocks, j);
for (; j >= i; j--) { for (; j >= i; j--) {
error = xfs_rtallocate_extent_block(args, error = xfs_rtallocate_extent_block(args,
bbno + j, minlen, bbno + j, minlen,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment