Skip to content

Commit 915175b

Browse files
fatherMatrixcmaiolino
authored andcommitted
xfs: fix the entry condition of exact EOF block allocation optimization
When we call create(), lseek() and write() sequentially, offset != 0 cannot be used as a judgment condition for whether the file already has extents. Furthermore, when xfs_bmap_adjacent() has not given a better blkno, it is not necessary to use exact EOF block allocation. Suggested-by: Dave Chinner <[email protected]> Signed-off-by: Jinliang Zheng <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent ee10f6f commit 915175b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,12 +3563,12 @@ xfs_bmap_btalloc_at_eof(
35633563
int error;
35643564

35653565
/*
3566-
* If there are already extents in the file, try an exact EOF block
3567-
* allocation to extend the file as a contiguous extent. If that fails,
3568-
* or it's the first allocation in a file, just try for a stripe aligned
3569-
* allocation.
3566+
* If there are already extents in the file, and xfs_bmap_adjacent() has
3567+
* given a better blkno, try an exact EOF block allocation to extend the
3568+
* file as a contiguous extent. If that fails, or it's the first
3569+
* allocation in a file, just try for a stripe aligned allocation.
35703570
*/
3571-
if (ap->offset) {
3571+
if (ap->eof) {
35723572
xfs_extlen_t nextminlen = 0;
35733573

35743574
/*
@@ -3736,7 +3736,8 @@ xfs_bmap_btalloc_best_length(
37363736
int error;
37373737

37383738
ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino);
3739-
xfs_bmap_adjacent(ap);
3739+
if (!xfs_bmap_adjacent(ap))
3740+
ap->eof = false;
37403741

37413742
/*
37423743
* Search for an allocation group with a single extent large enough for

0 commit comments

Comments
 (0)