Skip to content

Commit

Permalink
Btrfs: fix punch hole when no extent exists
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Josef Bacik authored and Chris Mason committed Oct 4, 2012
1 parent 926ced1 commit c3308f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -674,6 +675,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
goto next_slot;
}

found = 1;
search_start = max(key.offset, start);
if (recow || !modify_tree) {
modify_tree = -1;
Expand Down Expand Up @@ -829,7 +831,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
}

if (drop_end)
*drop_end = min(end, extent_end);
*drop_end = found ? min(end, extent_end) : end;
btrfs_release_path(path);
return ret;
}
Expand Down

0 comments on commit c3308f8

Please sign in to comment.