aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c32a9bffe9e4..0daa1df16439 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1010,7 +1010,7 @@ static int convert_extent_item_v0(struct btrfs_trans_handle *trans,
1010 return ret; 1010 return ret;
1011 BUG_ON(ret); 1011 BUG_ON(ret);
1012 1012
1013 ret = btrfs_extend_item(trans, root, path, new_size); 1013 btrfs_extend_item(trans, root, path, new_size);
1014 1014
1015 leaf = path->nodes[0]; 1015 leaf = path->nodes[0];
1016 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); 1016 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -1592,13 +1592,13 @@ out:
1592 * helper to add new inline back ref 1592 * helper to add new inline back ref
1593 */ 1593 */
1594static noinline_for_stack 1594static noinline_for_stack
1595int setup_inline_extent_backref(struct btrfs_trans_handle *trans, 1595void setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1596 struct btrfs_root *root, 1596 struct btrfs_root *root,
1597 struct btrfs_path *path, 1597 struct btrfs_path *path,
1598 struct btrfs_extent_inline_ref *iref, 1598 struct btrfs_extent_inline_ref *iref,
1599 u64 parent, u64 root_objectid, 1599 u64 parent, u64 root_objectid,
1600 u64 owner, u64 offset, int refs_to_add, 1600 u64 owner, u64 offset, int refs_to_add,
1601 struct btrfs_delayed_extent_op *extent_op) 1601 struct btrfs_delayed_extent_op *extent_op)
1602{ 1602{
1603 struct extent_buffer *leaf; 1603 struct extent_buffer *leaf;
1604 struct btrfs_extent_item *ei; 1604 struct btrfs_extent_item *ei;
@@ -1608,7 +1608,6 @@ int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1608 u64 refs; 1608 u64 refs;
1609 int size; 1609 int size;
1610 int type; 1610 int type;
1611 int ret;
1612 1611
1613 leaf = path->nodes[0]; 1612 leaf = path->nodes[0];
1614 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); 1613 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -1617,7 +1616,7 @@ int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1617 type = extent_ref_type(parent, owner); 1616 type = extent_ref_type(parent, owner);
1618 size = btrfs_extent_inline_ref_size(type); 1617 size = btrfs_extent_inline_ref_size(type);
1619 1618
1620 ret = btrfs_extend_item(trans, root, path, size); 1619 btrfs_extend_item(trans, root, path, size);
1621 1620
1622 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); 1621 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1623 refs = btrfs_extent_refs(leaf, ei); 1622 refs = btrfs_extent_refs(leaf, ei);
@@ -1652,7 +1651,6 @@ int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
1652 btrfs_set_extent_inline_ref_offset(leaf, iref, root_objectid); 1651 btrfs_set_extent_inline_ref_offset(leaf, iref, root_objectid);
1653 } 1652 }
1654 btrfs_mark_buffer_dirty(leaf); 1653 btrfs_mark_buffer_dirty(leaf);
1655 return 0;
1656} 1654}
1657 1655
1658static int lookup_extent_backref(struct btrfs_trans_handle *trans, 1656static int lookup_extent_backref(struct btrfs_trans_handle *trans,
@@ -1687,12 +1685,12 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans,
1687 * helper to update/remove inline back ref 1685 * helper to update/remove inline back ref
1688 */ 1686 */
1689static noinline_for_stack 1687static noinline_for_stack
1690int update_inline_extent_backref(struct btrfs_trans_handle *trans, 1688void update_inline_extent_backref(struct btrfs_trans_handle *trans,
1691 struct btrfs_root *root, 1689 struct btrfs_root *root,
1692 struct btrfs_path *path, 1690 struct btrfs_path *path,
1693 struct btrfs_extent_inline_ref *iref, 1691 struct btrfs_extent_inline_ref *iref,
1694 int refs_to_mod, 1692 int refs_to_mod,
1695 struct btrfs_delayed_extent_op *extent_op) 1693 struct btrfs_delayed_extent_op *extent_op)
1696{ 1694{
1697 struct extent_buffer *leaf; 1695 struct extent_buffer *leaf;
1698 struct btrfs_extent_item *ei; 1696 struct btrfs_extent_item *ei;
@@ -1703,7 +1701,6 @@ int update_inline_extent_backref(struct btrfs_trans_handle *trans,
1703 u32 item_size; 1701 u32 item_size;
1704 int size; 1702 int size;
1705 int type; 1703 int type;
1706 int ret;
1707 u64 refs; 1704 u64 refs;
1708 1705
1709 leaf = path->nodes[0]; 1706 leaf = path->nodes[0];
@@ -1745,10 +1742,9 @@ int update_inline_extent_backref(struct btrfs_trans_handle *trans,
1745 memmove_extent_buffer(leaf, ptr, ptr + size, 1742 memmove_extent_buffer(leaf, ptr, ptr + size,
1746 end - ptr - size); 1743 end - ptr - size);
1747 item_size -= size; 1744 item_size -= size;
1748 ret = btrfs_truncate_item(trans, root, path, item_size, 1); 1745 btrfs_truncate_item(trans, root, path, item_size, 1);
1749 } 1746 }
1750 btrfs_mark_buffer_dirty(leaf); 1747 btrfs_mark_buffer_dirty(leaf);
1751 return 0;
1752} 1748}
1753 1749
1754static noinline_for_stack 1750static noinline_for_stack
@@ -1768,13 +1764,13 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans,
1768 root_objectid, owner, offset, 1); 1764 root_objectid, owner, offset, 1);
1769 if (ret == 0) { 1765 if (ret == 0) {
1770 BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID); 1766 BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID);
1771 ret = update_inline_extent_backref(trans, root, path, iref, 1767 update_inline_extent_backref(trans, root, path, iref,
1772 refs_to_add, extent_op); 1768 refs_to_add, extent_op);
1773 } else if (ret == -ENOENT) { 1769 } else if (ret == -ENOENT) {
1774 ret = setup_inline_extent_backref(trans, root, path, iref, 1770 setup_inline_extent_backref(trans, root, path, iref, parent,
1775 parent, root_objectid, 1771 root_objectid, owner, offset,
1776 owner, offset, refs_to_add, 1772 refs_to_add, extent_op);
1777 extent_op); 1773 ret = 0;
1778 } 1774 }
1779 return ret; 1775 return ret;
1780} 1776}
@@ -1804,12 +1800,12 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
1804 struct btrfs_extent_inline_ref *iref, 1800 struct btrfs_extent_inline_ref *iref,
1805 int refs_to_drop, int is_data) 1801 int refs_to_drop, int is_data)
1806{ 1802{
1807 int ret; 1803 int ret = 0;
1808 1804
1809 BUG_ON(!is_data && refs_to_drop != 1); 1805 BUG_ON(!is_data && refs_to_drop != 1);
1810 if (iref) { 1806 if (iref) {
1811 ret = update_inline_extent_backref(trans, root, path, iref, 1807 update_inline_extent_backref(trans, root, path, iref,
1812 -refs_to_drop, NULL); 1808 -refs_to_drop, NULL);
1813 } else if (is_data) { 1809 } else if (is_data) {
1814 ret = remove_extent_data_ref(trans, root, path, refs_to_drop); 1810 ret = remove_extent_data_ref(trans, root, path, refs_to_drop);
1815 } else { 1811 } else {
@@ -4734,7 +4730,7 @@ static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
4734 return ret; 4730 return ret;
4735} 4731}
4736 4732
4737int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, 4733void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
4738 struct btrfs_root *root) 4734 struct btrfs_root *root)
4739{ 4735{
4740 struct btrfs_fs_info *fs_info = root->fs_info; 4736 struct btrfs_fs_info *fs_info = root->fs_info;
@@ -4764,7 +4760,6 @@ int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
4764 up_write(&fs_info->extent_commit_sem); 4760 up_write(&fs_info->extent_commit_sem);
4765 4761
4766 update_global_block_rsv(fs_info); 4762 update_global_block_rsv(fs_info);
4767 return 0;
4768} 4763}
4769 4764
4770static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end) 4765static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end)
@@ -7189,7 +7184,7 @@ u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo)
7189 return free_bytes; 7184 return free_bytes;
7190} 7185}
7191 7186
7192int btrfs_set_block_group_rw(struct btrfs_root *root, 7187void btrfs_set_block_group_rw(struct btrfs_root *root,
7193 struct btrfs_block_group_cache *cache) 7188 struct btrfs_block_group_cache *cache)
7194{ 7189{
7195 struct btrfs_space_info *sinfo = cache->space_info; 7190 struct btrfs_space_info *sinfo = cache->space_info;
@@ -7205,7 +7200,6 @@ int btrfs_set_block_group_rw(struct btrfs_root *root,
7205 cache->ro = 0; 7200 cache->ro = 0;
7206 spin_unlock(&cache->lock); 7201 spin_unlock(&cache->lock);
7207 spin_unlock(&sinfo->lock); 7202 spin_unlock(&sinfo->lock);
7208 return 0;
7209} 7203}
7210 7204
7211/* 7205/*