diff options
author | Christoph Hellwig <hch@lst.de> | 2023-12-18 05:57:25 +0100 |
---|---|---|
committer | Chandan Babu R <chandanbabu@kernel.org> | 2023-12-22 11:18:12 +0530 |
commit | a3e48f68b5f4bc83cdded35be2c4c3cc23eb9e19 (patch) | |
tree | 3d85ceb30f40aa34ea5b07e0c6068f314f8b8d72 /fs/xfs | |
parent | 676544c27e710aee7f8357f57abd348d98b1ccd4 (diff) | |
download | linux-a3e48f68b5f4bc83cdded35be2c4c3cc23eb9e19.tar.gz linux-a3e48f68b5f4bc83cdded35be2c4c3cc23eb9e19.tar.bz2 linux-a3e48f68b5f4bc83cdded35be2c4c3cc23eb9e19.zip |
xfs: cleanup picking the start extent hint in xfs_bmap_rtalloc
Clean up the logical in xfs_bmap_rtalloc that tries to find a rtextent
to start the search from by using a separate variable for the hint, not
calling xfs_bmap_adjacent when we want to ignore the locality and avoid
an extra roundtrip converting between block numbers and RT extent
numbers.
As a side-effect this doesn't pointlessly call xfs_rtpick_extent and
increment the start rtextent hint if we are going to ignore the result
anyway.
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.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 92ff05ce33c7..33f558166642 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1398,7 +1398,8 @@ xfs_bmap_rtalloc( { struct xfs_mount *mp = ap->ip->i_mount; xfs_fileoff_t orig_offset = ap->offset; - xfs_rtxnum_t rtx; + xfs_rtxnum_t start; /* allocation hint rtextent no */ + xfs_rtxnum_t rtx; /* actually allocated rtextent no */ xfs_rtxlen_t prod = 0; /* product factor for allocators */ xfs_extlen_t mod = 0; /* product factor for allocators */ xfs_rtxlen_t ralen = 0; /* realtime allocation length */ @@ -1459,30 +1460,24 @@ retry: rtlocked = true; } - /* - * If it's an allocation to an empty file at offset 0, - * pick an extent that will space things out in the rt area. - */ - if (ap->eof && ap->offset == 0) { - error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); + if (ignore_locality) { + start = 0; + } else if (xfs_bmap_adjacent(ap)) { + start = xfs_rtb_to_rtx(mp, ap->blkno); + } else if (ap->eof && ap->offset == 0) { + /* + * If it's an allocation to an empty file at offset 0, pick an + * extent that will space things out in the rt area. + */ + error = xfs_rtpick_extent(mp, ap->tp, ralen, &start); if (error) return error; - ap->blkno = xfs_rtx_to_rtb(mp, rtx); } else { - ap->blkno = 0; + start = 0; } - xfs_bmap_adjacent(ap); - - /* - * Realtime allocation, done through xfs_rtallocate_extent. - */ - if (ignore_locality) - rtx = 0; - else - rtx = xfs_rtb_to_rtx(mp, ap->blkno); raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen)); - error = xfs_rtallocate_extent(ap->tp, rtx, raminlen, ralen, &ralen, + error = xfs_rtallocate_extent(ap->tp, start, raminlen, ralen, &ralen, ap->wasdel, prod, &rtx); if (error == -ENOSPC) { if (align > mp->m_sb.sb_rextsize) { @@ -1499,7 +1494,7 @@ retry: goto retry; } - if (!ignore_locality && ap->blkno != 0) { + if (!ignore_locality && start != 0) { /* * If we can't allocate near a specific rt extent, try * again without locality criteria. |