Skip to content

Commit 3c97c9f

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
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>
1 parent d9498fa commit 3c97c9f

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -350,32 +350,24 @@ xfs_rtallocate_extent_exact(
350350
if (error)
351351
return error;
352352

353-
if (isfree) {
353+
if (!isfree) {
354354
/*
355-
* If it is, allocate it and return success.
355+
* If not, allocate what there is, if it's at least minlen.
356356
*/
357-
error = xfs_rtallocate_range(args, start, maxlen);
358-
if (error)
359-
return error;
360-
*len = maxlen;
361-
*rtx = start;
362-
return 0;
363-
}
364-
/*
365-
* If not, allocate what there is, if it's at least minlen.
366-
*/
367-
maxlen = next - start;
368-
if (maxlen < minlen)
369-
return -ENOSPC;
370-
371-
/*
372-
* Trim off tail of extent, if prod is specified.
373-
*/
374-
if (prod > 1 && (i = maxlen % prod)) {
375-
maxlen -= i;
357+
maxlen = next - start;
376358
if (maxlen < minlen)
377359
return -ENOSPC;
360+
361+
/*
362+
* Trim off tail of extent, if prod is specified.
363+
*/
364+
if (prod > 1 && (i = maxlen % prod)) {
365+
maxlen -= i;
366+
if (maxlen < minlen)
367+
return -ENOSPC;
368+
}
378369
}
370+
379371
/*
380372
* Allocate what we can and return it.
381373
*/

0 commit comments

Comments
 (0)