Commit 9ade45b0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: reflow the tail end of xfs_rtallocate_extent_block

Change polarity of a check so that the successful case of being able to
allocate an extent is in the main path of the function and error handling
is on a branch.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent f3e509dd
...@@ -289,36 +289,38 @@ xfs_rtallocate_extent_block( ...@@ -289,36 +289,38 @@ xfs_rtallocate_extent_block(
if (error) if (error)
return error; return error;
} }
/* /*
* Searched the whole thing & didn't find a maxlen free extent. * Searched the whole thing & didn't find a maxlen free extent.
*/ */
if (minlen <= maxlen && besti != -1) { if (minlen > maxlen || besti == -1) {
xfs_rtxlen_t p; /* amount to trim length by */
/* /*
* If size should be a multiple of prod, make that so. * Allocation failed. Set *nextp to the next block to try.
*/ */
if (prod > 1) { *nextp = next;
div_u64_rem(bestlen, prod, &p); return -ENOSPC;
if (p) }
bestlen -= p;
}
/* /*
* Allocate besti for bestlen & return that. * If size should be a multiple of prod, make that so.
*/ */
error = xfs_rtallocate_range(args, besti, bestlen); if (prod > 1) {
if (error) xfs_rtxlen_t p; /* amount to trim length by */
return error;
*len = bestlen; div_u64_rem(bestlen, prod, &p);
*rtx = besti; if (p)
return 0; bestlen -= p;
} }
/* /*
* Allocation failed. Set *nextp to the next block to try. * Allocate besti for bestlen & return that.
*/ */
*nextp = next; error = xfs_rtallocate_range(args, besti, bestlen);
return -ENOSPC; if (error)
return error;
*len = bestlen;
*rtx = besti;
return 0;
} }
/* /*
......
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