]> git.itanic.dy.fi Git - linux-stable/commitdiff
xfs: tidy up xfs_rtallocate_extent_exact
authorChristoph Hellwig <hch@lst.de>
Mon, 18 Dec 2023 04:57:31 +0000 (05:57 +0100)
committerChandan Babu R <chandanbabu@kernel.org>
Fri, 22 Dec 2023 05:48:13 +0000 (11:18 +0530)
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>
fs/xfs/xfs_rtalloc.c

index 774e55cd602f3bcfde0a86a1ad365140e4feb1b5..00083013a01034f4014206c80d0a0f2ca27e68c4 100644 (file)
@@ -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.
         */