summaryrefslogtreecommitdiff
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-12-18 07:57:31 +0300
committerChandan Babu R <chandanbabu@kernel.org>2023-12-22 08:48:13 +0300
commit3c97c9f78d23c7e449fc9a0865b40f44748c3011 (patch)
tree5d82467e5db29324540efed4f30c2fe31af9d624 /fs/xfs
parentd9498fa8c8580b9cedb764e475503706ba7a0fbf (diff)
downloadlinux-3c97c9f78d23c7e449fc9a0865b40f44748c3011.tar.xz
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_rtalloc.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 774e55cd602f..00083013a010 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -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.
*/