mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
xfs: tidy up xfs_rtallocate_extent_exact
Use common code for both xfs_rtallocate_range calls by moving the !isfree logic into the non-default 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
d9498fa8c8
commit
3c97c9f78d
@ -350,32 +350,24 @@ xfs_rtallocate_extent_exact(
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (isfree) {
|
||||
if (!isfree) {
|
||||
/*
|
||||
* If it is, allocate it and return success.
|
||||
* If not, allocate what there is, if it's at least minlen.
|
||||
*/
|
||||
error = xfs_rtallocate_range(args, start, maxlen);
|
||||
if (error)
|
||||
return error;
|
||||
*len = maxlen;
|
||||
*rtx = start;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* If not, allocate what there is, if it's at least minlen.
|
||||
*/
|
||||
maxlen = next - start;
|
||||
if (maxlen < minlen)
|
||||
return -ENOSPC;
|
||||
|
||||
/*
|
||||
* Trim off tail of extent, if prod is specified.
|
||||
*/
|
||||
if (prod > 1 && (i = maxlen % prod)) {
|
||||
maxlen -= i;
|
||||
maxlen = next - start;
|
||||
if (maxlen < minlen)
|
||||
return -ENOSPC;
|
||||
|
||||
/*
|
||||
* Trim off tail of extent, if prod is specified.
|
||||
*/
|
||||
if (prod > 1 && (i = maxlen % prod)) {
|
||||
maxlen -= i;
|
||||
if (maxlen < minlen)
|
||||
return -ENOSPC;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate what we can and return it.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user