Skip to content

Commit 1707e26

Browse files
chandanmasoncl
authored andcommitted
Btrfs: fill_holes: Fix slot number passed to hole_mergeable() call.
For a non-existent key, btrfs_search_slot() sets path->slots[0] to the slot where the key could have been present, which in this case would be the slot containing the extent item which would be the next neighbor of the file range being punched. The current code passes an incremented path->slots[0] and we skip to the wrong file extent item. This would mean that we would fail to merge the "yet to be created" hole with the next neighboring hole (if one exists). Fix this. Signed-off-by: Chandan Rajendra <[email protected]> Reviewed-by: Wang Shilong <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 7a5c3c9 commit 1707e26

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/btrfs/file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,10 +2088,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
20882088
goto out;
20892089
}
20902090

2091-
if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) {
2091+
if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {
20922092
u64 num_bytes;
20932093

2094-
path->slots[0]++;
20952094
key.offset = offset;
20962095
btrfs_set_item_key_safe(root, path, &key);
20972096
fi = btrfs_item_ptr(leaf, path->slots[0],

0 commit comments

Comments
 (0)