diff options
author | Yan Zheng <zheng.yan@oracle.com> | 2008-10-30 14:19:50 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-10-30 14:19:50 -0400 |
commit | 6643558db29006825dbb10012b3f8890aca4bcd5 (patch) | |
tree | 0c0f4f7a0011749cda998431828cb9161747b51a /fs/btrfs/inode.c | |
parent | 9036c10208e1fc496cef7692ba66a78699b360dc (diff) | |
download | op-kernel-dev-6643558db29006825dbb10012b3f8890aca4bcd5.zip op-kernel-dev-6643558db29006825dbb10012b3f8890aca4bcd5.tar.gz |
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/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8254d6f..e8511d1 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -246,7 +246,6 @@ static int cow_file_range_inline(struct btrfs_trans_handle *trans, return 1; } - mutex_lock(&BTRFS_I(inode)->extent_mutex); ret = btrfs_drop_extents(trans, root, inode, start, aligned_end, aligned_end, &hint_byte); BUG_ON(ret); @@ -258,7 +257,6 @@ static int cow_file_range_inline(struct btrfs_trans_handle *trans, compressed_pages); BUG_ON(ret); btrfs_drop_extent_cache(inode, start, aligned_end, 0); - mutex_unlock(&BTRFS_I(inode)->extent_mutex); return 0; } @@ -437,9 +435,7 @@ again: BUG_ON(disk_num_bytes > btrfs_super_total_bytes(&root->fs_info->super_copy)); - mutex_lock(&BTRFS_I(inode)->extent_mutex); btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0); - mutex_unlock(&BTRFS_I(inode)->extent_mutex); while(disk_num_bytes > 0) { unsigned long min_bytes; @@ -477,8 +473,6 @@ again: em->block_start = ins.objectid; em->block_len = ins.offset; em->bdev = root->fs_info->fs_devices->latest_bdev; - - mutex_lock(&BTRFS_I(inode)->extent_mutex); set_bit(EXTENT_FLAG_PINNED, &em->flags); if (will_compress) @@ -495,7 +489,6 @@ again: btrfs_drop_extent_cache(inode, start, start + ram_size - 1, 0); } - mutex_unlock(&BTRFS_I(inode)->extent_mutex); cur_alloc_size = ins.offset; ret = btrfs_add_ordered_extent(inode, start, ins.objectid, @@ -1016,8 +1009,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) INIT_LIST_HEAD(&list); - mutex_lock(&BTRFS_I(inode)->extent_mutex); - ret = btrfs_drop_extents(trans, root, inode, ordered_extent->file_offset, ordered_extent->file_offset + @@ -1059,7 +1050,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) btrfs_drop_extent_cache(inode, ordered_extent->file_offset, ordered_extent->file_offset + ordered_extent->len - 1, 0); - mutex_unlock(&BTRFS_I(inode)->extent_mutex); ins.objectid = ordered_extent->start; ins.offset = ordered_extent->disk_len; |