summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorYan Zheng2008-10-30 19:19:50 +0100
committerChris Mason2008-10-30 19:19:50 +0100
commit6643558db29006825dbb10012b3f8890aca4bcd5 (patch)
tree0c0f4f7a0011749cda998431828cb9161747b51a /fs/btrfs/extent_io.c
parentBtrfs: update hole handling v2 (diff)
downloadkernel-qcow2-linux-6643558db29006825dbb10012b3f8890aca4bcd5.tar.gz
kernel-qcow2-linux-6643558db29006825dbb10012b3f8890aca4bcd5.tar.xz
kernel-qcow2-linux-6643558db29006825dbb10012b3f8890aca4bcd5.zip
Btrfs: Fix bookend extent race v2
When dropping middle part of an extent, btrfs_drop_extents truncates the extent at first, then inserts a bookend extent. Since truncation and insertion can't be done atomically, there is a small period that the bookend extent isn't in the tree. This causes problem for functions that search the tree for file extent item. The way to fix this is lock the range of the bookend extent before truncation. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 7503bd46819b..65a0583027e9 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -946,8 +946,12 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end,
err = set_extent_bit(tree, start, end, EXTENT_LOCKED, 1,
&failed_start, mask);
- if (err == -EEXIST)
+ if (err == -EEXIST) {
+ if (failed_start > start)
+ clear_extent_bit(tree, start, failed_start - 1,
+ EXTENT_LOCKED, 1, 0, mask);
return 0;
+ }
return 1;
}
EXPORT_SYMBOL(try_lock_extent);