Skip to content

Commit

Permalink
Btrfs: fill_holes: Fix slot number passed to hole_mergeable() call.
Browse files Browse the repository at this point in the history
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 <chandan@linux.vnet.ibm.com>
Reviewed-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
chandan authored and Chris Mason committed Aug 19, 2014
1 parent 7a5c3c9 commit 1707e26
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,10 +2088,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
goto out;
}

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

path->slots[0]++;
key.offset = offset;
btrfs_set_item_key_safe(root, path, &key);
fi = btrfs_item_ptr(leaf, path->slots[0],
Expand Down

0 comments on commit 1707e26

Please sign in to comment.