summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorJosef Bacik2012-09-14 20:51:22 +0200
committerChris Mason2012-10-04 15:40:00 +0200
commitc3308f84c1743eabb91f4976a314d118d5ea2342 (patch)
tree996b83b71224a03621fae61a32e8f194954deebf /fs/btrfs/file.c
parentBtrfs: don't do anything in our ->freeze_fs and ->unfreeze_fs (diff)
downloadkernel-qcow2-linux-c3308f84c1743eabb91f4976a314d118d5ea2342.tar.gz
kernel-qcow2-linux-c3308f84c1743eabb91f4976a314d118d5ea2342.tar.xz
kernel-qcow2-linux-c3308f84c1743eabb91f4976a314d118d5ea2342.zip
Btrfs: fix punch hole when no extent exists
I saw the warning in btrfs_drop_extent_cache where our end is less than our start while running xfstests 68 in a loop. This is because we unconditionally do drop_end = min(end, extent_end) in __btrfs_drop_extents(), even though we may not have found an extent in the range we were looking to drop. So keep track of wether or not we found something, and if we didn't just use our end. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d0fc4c5aaf15..110d3cb7b6fe 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -609,6 +609,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
int ret;
int modify_tree = -1;
int update_refs = (root->ref_cows || root == root->fs_info->tree_root);
+ int found = 0;
if (drop_cache)
btrfs_drop_extent_cache(inode, start, end - 1, 0);
@@ -674,6 +675,7 @@ next_slot:
goto next_slot;
}
+ found = 1;
search_start = max(key.offset, start);
if (recow || !modify_tree) {
modify_tree = -1;
@@ -829,7 +831,7 @@ next_slot:
}
if (drop_end)
- *drop_end = min(end, extent_end);
+ *drop_end = found ? min(end, extent_end) : end;
btrfs_release_path(path);
return ret;
}