Skip to content

Commit db8616e

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: reflow the tail end of xfs_bmap_rtalloc
Reorder the tail end of xfs_bmap_rtalloc so that the successfully allocation is in the main path, and the error handling is on a branch. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent ce42b5d commit db8616e

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,39 +1484,39 @@ xfs_bmap_rtalloc(
14841484
raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
14851485
error = xfs_rtallocate_extent(ap->tp, rtx, raminlen, ralen, &ralen,
14861486
ap->wasdel, prod, &rtx);
1487-
if (!error) {
1488-
ap->blkno = xfs_rtx_to_rtb(mp, rtx);
1489-
ap->length = xfs_rtxlen_to_extlen(mp, ralen);
1490-
xfs_bmap_alloc_account(ap);
1491-
return 0;
1492-
}
1493-
1494-
if (error != -ENOSPC)
1495-
return error;
1487+
if (error == -ENOSPC) {
1488+
if (align > mp->m_sb.sb_rextsize) {
1489+
/*
1490+
* We previously enlarged the request length to try to
1491+
* satisfy an extent size hint. The allocator didn't
1492+
* return anything, so reset the parameters to the
1493+
* original values and try again without alignment
1494+
* criteria.
1495+
*/
1496+
ap->offset = orig_offset;
1497+
ap->length = orig_length;
1498+
minlen = align = mp->m_sb.sb_rextsize;
1499+
goto retry;
1500+
}
14961501

1497-
if (align > mp->m_sb.sb_rextsize) {
1498-
/*
1499-
* We previously enlarged the request length to try to satisfy
1500-
* an extent size hint. The allocator didn't return anything,
1501-
* so reset the parameters to the original values and try again
1502-
* without alignment criteria.
1503-
*/
1504-
ap->offset = orig_offset;
1505-
ap->length = orig_length;
1506-
minlen = align = mp->m_sb.sb_rextsize;
1507-
goto retry;
1508-
}
1502+
if (!ignore_locality && ap->blkno != 0) {
1503+
/*
1504+
* If we can't allocate near a specific rt extent, try
1505+
* again without locality criteria.
1506+
*/
1507+
ignore_locality = true;
1508+
goto retry;
1509+
}
15091510

1510-
if (!ignore_locality && ap->blkno != 0) {
1511-
/*
1512-
* If we can't allocate near a specific rt extent, try again
1513-
* without locality criteria.
1514-
*/
1515-
ignore_locality = true;
1516-
goto retry;
1511+
ap->blkno = NULLFSBLOCK;
1512+
ap->length = 0;
1513+
return 0;
15171514
}
1515+
if (error)
1516+
return error;
15181517

1519-
ap->blkno = NULLFSBLOCK;
1520-
ap->length = 0;
1518+
ap->blkno = xfs_rtx_to_rtb(mp, rtx);
1519+
ap->length = xfs_rtxlen_to_extlen(mp, ralen);
1520+
xfs_bmap_alloc_account(ap);
15211521
return 0;
15221522
}

0 commit comments

Comments
 (0)