mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
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: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
This commit is contained in:
parent
f3e509dd45
commit
9ade45b08a
@ -289,36 +289,38 @@ xfs_rtallocate_extent_block(
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Searched the whole thing & didn't find a maxlen free extent.
|
||||
*/
|
||||
if (minlen <= maxlen && besti != -1) {
|
||||
if (minlen > maxlen || besti == -1) {
|
||||
/*
|
||||
* Allocation failed. Set *nextp to the next block to try.
|
||||
*/
|
||||
*nextp = next;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
/*
|
||||
* If size should be a multiple of prod, make that so.
|
||||
*/
|
||||
if (prod > 1) {
|
||||
xfs_rtxlen_t p; /* amount to trim length by */
|
||||
|
||||
/*
|
||||
* If size should be a multiple of prod, make that so.
|
||||
*/
|
||||
if (prod > 1) {
|
||||
div_u64_rem(bestlen, prod, &p);
|
||||
if (p)
|
||||
bestlen -= p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate besti for bestlen & return that.
|
||||
*/
|
||||
error = xfs_rtallocate_range(args, besti, bestlen);
|
||||
if (error)
|
||||
return error;
|
||||
*len = bestlen;
|
||||
*rtx = besti;
|
||||
return 0;
|
||||
div_u64_rem(bestlen, prod, &p);
|
||||
if (p)
|
||||
bestlen -= p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocation failed. Set *nextp to the next block to try.
|
||||
* Allocate besti for bestlen & return that.
|
||||
*/
|
||||
*nextp = next;
|
||||
return -ENOSPC;
|
||||
error = xfs_rtallocate_range(args, besti, bestlen);
|
||||
if (error)
|
||||
return error;
|
||||
*len = bestlen;
|
||||
*rtx = besti;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user