diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2009-11-12 04:34:08 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-12-15 21:24:52 -0500 |
commit | 920bbbfb05c9fce22e088d20eb9dcb8f96342de9 (patch) | |
tree | b972b3f39ebefb9c026300c1981d18cad769e431 /fs/btrfs/inode.c | |
parent | ad48fd754676bfae4139be1a897b1ea58f9aaf21 (diff) |
Btrfs: Rewrite btrfs_drop_extents
Rewrite btrfs_drop_extents by using btrfs_duplicate_item, so we can
avoid calling lock_extent within transaction.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b3ad168a0bfc..ef250be49cdb 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -230,8 +230,7 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans, | |||
230 | return 1; | 230 | return 1; |
231 | } | 231 | } |
232 | 232 | ||
233 | ret = btrfs_drop_extents(trans, root, inode, start, | 233 | ret = btrfs_drop_extents(trans, inode, start, aligned_end, |
234 | aligned_end, aligned_end, start, | ||
235 | &hint_byte, 1); | 234 | &hint_byte, 1); |
236 | BUG_ON(ret); | 235 | BUG_ON(ret); |
237 | 236 | ||
@@ -1596,7 +1595,6 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, | |||
1596 | struct inode *inode, u64 file_pos, | 1595 | struct inode *inode, u64 file_pos, |
1597 | u64 disk_bytenr, u64 disk_num_bytes, | 1596 | u64 disk_bytenr, u64 disk_num_bytes, |
1598 | u64 num_bytes, u64 ram_bytes, | 1597 | u64 num_bytes, u64 ram_bytes, |
1599 | u64 locked_end, | ||
1600 | u8 compression, u8 encryption, | 1598 | u8 compression, u8 encryption, |
1601 | u16 other_encoding, int extent_type) | 1599 | u16 other_encoding, int extent_type) |
1602 | { | 1600 | { |
@@ -1622,9 +1620,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, | |||
1622 | * the caller is expected to unpin it and allow it to be merged | 1620 | * the caller is expected to unpin it and allow it to be merged |
1623 | * with the others. | 1621 | * with the others. |
1624 | */ | 1622 | */ |
1625 | ret = btrfs_drop_extents(trans, root, inode, file_pos, | 1623 | ret = btrfs_drop_extents(trans, inode, file_pos, file_pos + num_bytes, |
1626 | file_pos + num_bytes, locked_end, | 1624 | &hint, 0); |
1627 | file_pos, &hint, 0); | ||
1628 | BUG_ON(ret); | 1625 | BUG_ON(ret); |
1629 | 1626 | ||
1630 | ins.objectid = inode->i_ino; | 1627 | ins.objectid = inode->i_ino; |
@@ -1746,7 +1743,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1746 | compressed = 1; | 1743 | compressed = 1; |
1747 | if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { | 1744 | if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { |
1748 | BUG_ON(compressed); | 1745 | BUG_ON(compressed); |
1749 | ret = btrfs_mark_extent_written(trans, root, inode, | 1746 | ret = btrfs_mark_extent_written(trans, inode, |
1750 | ordered_extent->file_offset, | 1747 | ordered_extent->file_offset, |
1751 | ordered_extent->file_offset + | 1748 | ordered_extent->file_offset + |
1752 | ordered_extent->len); | 1749 | ordered_extent->len); |
@@ -1758,8 +1755,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1758 | ordered_extent->disk_len, | 1755 | ordered_extent->disk_len, |
1759 | ordered_extent->len, | 1756 | ordered_extent->len, |
1760 | ordered_extent->len, | 1757 | ordered_extent->len, |
1761 | ordered_extent->file_offset + | ||
1762 | ordered_extent->len, | ||
1763 | compressed, 0, 0, | 1758 | compressed, 0, 0, |
1764 | BTRFS_FILE_EXTENT_REG); | 1759 | BTRFS_FILE_EXTENT_REG); |
1765 | unpin_extent_cache(&BTRFS_I(inode)->extent_tree, | 1760 | unpin_extent_cache(&BTRFS_I(inode)->extent_tree, |
@@ -3209,11 +3204,9 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) | |||
3209 | if (test_bit(EXTENT_FLAG_VACANCY, &em->flags)) { | 3204 | if (test_bit(EXTENT_FLAG_VACANCY, &em->flags)) { |
3210 | u64 hint_byte = 0; | 3205 | u64 hint_byte = 0; |
3211 | hole_size = last_byte - cur_offset; | 3206 | hole_size = last_byte - cur_offset; |
3212 | err = btrfs_drop_extents(trans, root, inode, | 3207 | err = btrfs_drop_extents(trans, inode, cur_offset, |
3213 | cur_offset, | ||
3214 | cur_offset + hole_size, | 3208 | cur_offset + hole_size, |
3215 | block_end, | 3209 | &hint_byte, 1); |
3216 | cur_offset, &hint_byte, 1); | ||
3217 | if (err) | 3210 | if (err) |
3218 | break; | 3211 | break; |
3219 | 3212 | ||
@@ -5643,7 +5636,7 @@ out_fail: | |||
5643 | 5636 | ||
5644 | static int prealloc_file_range(struct btrfs_trans_handle *trans, | 5637 | static int prealloc_file_range(struct btrfs_trans_handle *trans, |
5645 | struct inode *inode, u64 start, u64 end, | 5638 | struct inode *inode, u64 start, u64 end, |
5646 | u64 locked_end, u64 alloc_hint, int mode) | 5639 | u64 alloc_hint, int mode) |
5647 | { | 5640 | { |
5648 | struct btrfs_root *root = BTRFS_I(inode)->root; | 5641 | struct btrfs_root *root = BTRFS_I(inode)->root; |
5649 | struct btrfs_key ins; | 5642 | struct btrfs_key ins; |
@@ -5669,8 +5662,7 @@ static int prealloc_file_range(struct btrfs_trans_handle *trans, | |||
5669 | ret = insert_reserved_file_extent(trans, inode, | 5662 | ret = insert_reserved_file_extent(trans, inode, |
5670 | cur_offset, ins.objectid, | 5663 | cur_offset, ins.objectid, |
5671 | ins.offset, ins.offset, | 5664 | ins.offset, ins.offset, |
5672 | ins.offset, locked_end, | 5665 | ins.offset, 0, 0, 0, |
5673 | 0, 0, 0, | ||
5674 | BTRFS_FILE_EXTENT_PREALLOC); | 5666 | BTRFS_FILE_EXTENT_PREALLOC); |
5675 | BUG_ON(ret); | 5667 | BUG_ON(ret); |
5676 | btrfs_drop_extent_cache(inode, cur_offset, | 5668 | btrfs_drop_extent_cache(inode, cur_offset, |
@@ -5779,8 +5771,7 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
5779 | last_byte = (last_byte + mask) & ~mask; | 5771 | last_byte = (last_byte + mask) & ~mask; |
5780 | if (em->block_start == EXTENT_MAP_HOLE) { | 5772 | if (em->block_start == EXTENT_MAP_HOLE) { |
5781 | ret = prealloc_file_range(trans, inode, cur_offset, | 5773 | ret = prealloc_file_range(trans, inode, cur_offset, |
5782 | last_byte, locked_end + 1, | 5774 | last_byte, alloc_hint, mode); |
5783 | alloc_hint, mode); | ||
5784 | if (ret < 0) { | 5775 | if (ret < 0) { |
5785 | free_extent_map(em); | 5776 | free_extent_map(em); |
5786 | break; | 5777 | break; |