aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorchandan <chandan@linux.vnet.ibm.com>2014-07-01 02:34:28 -0400
committerChris Mason <clm@fb.com>2014-08-19 11:36:26 -0400
commit1707e26d6ab05c477a91d260e31fda7c6c38588e (patch)
tree3ff2df1816f2f086130f803157a598e40c76ddb8 /fs/btrfs/file.c
parent7a5c3c9be1059feed0e470c6dc0994dcaed4f12c (diff)
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 <chandan@linux.vnet.ibm.com> Reviewed-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3afac292d67..77e33534c7d6 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2088,10 +2088,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
2088 goto out; 2088 goto out;
2089 } 2089 }
2090 2090
2091 if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) { 2091 if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {
2092 u64 num_bytes; 2092 u64 num_bytes;
2093 2093
2094 path->slots[0]++;
2095 key.offset = offset; 2094 key.offset = offset;
2096 btrfs_set_item_key_safe(root, path, &key); 2095 btrfs_set_item_key_safe(root, path, &key);
2097 fi = btrfs_item_ptr(leaf, path->slots[0], 2096 fi = btrfs_item_ptr(leaf, path->slots[0],