Skip to content

Commit af9f024

Browse files
author
Darrick J. Wong
committed
xfs: fix null bno_hint handling in xfs_rtallocate_rtg
xfs_bmap_rtalloc initializes the bno_hint variable to NULLRTBLOCK (aka NULLFSBLOCK). If the allocation request is for a file range that's adjacent to an existing mapping, it will then change bno_hint to the blkno hint in the bmalloca structure. In other words, bno_hint is either a rt block number, or it's all 1s. Unfortunately, commit ec12f97 didn't take the NULLRTBLOCK state into account, which means that it tries to translate that into a realtime extent number. We then end up with an obnoxiously high rtx number and pointlessly feed that to the near allocator. This often fails and falls back to the by-size allocator. Seeing as we had no locality hint anyway, this is a waste of time. Fix the code to detect a lack of bno_hint correctly. This was detected by running xfs/009 with metadir enabled and a 28k rt extent size. Cc: <stable@vger.kernel.org> # v6.12 Fixes: ec12f97 ("xfs: make the rtalloc start hint a xfs_rtblock_t") Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent dc5a052 commit af9f024

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/xfs/xfs_rtalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ xfs_rtallocate_rtg(
18271827
* For an allocation to an empty file at offset 0, pick an extent that
18281828
* will space things out in the rt area.
18291829
*/
1830-
if (bno_hint)
1830+
if (bno_hint != NULLFSBLOCK)
18311831
start = xfs_rtb_to_rtx(args.mp, bno_hint);
18321832
else if (!xfs_has_rtgroups(args.mp) && initial_user_data)
18331833
start = xfs_rtpick_extent(args.rtg, tp, maxlen);

0 commit comments

Comments
 (0)