Skip to content

Commit 9ade45b

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
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>
1 parent f3e509d commit 9ade45b

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,36 +289,38 @@ xfs_rtallocate_extent_block(
289289
if (error)
290290
return error;
291291
}
292+
292293
/*
293294
* Searched the whole thing & didn't find a maxlen free extent.
294295
*/
295-
if (minlen <= maxlen && besti != -1) {
296-
xfs_rtxlen_t p; /* amount to trim length by */
297-
296+
if (minlen > maxlen || besti == -1) {
298297
/*
299-
* If size should be a multiple of prod, make that so.
298+
* Allocation failed. Set *nextp to the next block to try.
300299
*/
301-
if (prod > 1) {
302-
div_u64_rem(bestlen, prod, &p);
303-
if (p)
304-
bestlen -= p;
305-
}
300+
*nextp = next;
301+
return -ENOSPC;
302+
}
306303

307-
/*
308-
* Allocate besti for bestlen & return that.
309-
*/
310-
error = xfs_rtallocate_range(args, besti, bestlen);
311-
if (error)
312-
return error;
313-
*len = bestlen;
314-
*rtx = besti;
315-
return 0;
304+
/*
305+
* If size should be a multiple of prod, make that so.
306+
*/
307+
if (prod > 1) {
308+
xfs_rtxlen_t p; /* amount to trim length by */
309+
310+
div_u64_rem(bestlen, prod, &p);
311+
if (p)
312+
bestlen -= p;
316313
}
314+
317315
/*
318-
* Allocation failed. Set *nextp to the next block to try.
316+
* Allocate besti for bestlen & return that.
319317
*/
320-
*nextp = next;
321-
return -ENOSPC;
318+
error = xfs_rtallocate_range(args, besti, bestlen);
319+
if (error)
320+
return error;
321+
*len = bestlen;
322+
*rtx = besti;
323+
return 0;
322324
}
323325

324326
/*

0 commit comments

Comments
 (0)