diff options
-rw-r--r-- | fs/btrfs/extent-tree.c | 103 |
1 files changed, 53 insertions, 50 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f2373e70d9c8..2c21a7ede933 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -1035,10 +1035,11 @@ out_free: | |||
1035 | 1035 | ||
1036 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 | 1036 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 |
1037 | static int convert_extent_item_v0(struct btrfs_trans_handle *trans, | 1037 | static int convert_extent_item_v0(struct btrfs_trans_handle *trans, |
1038 | struct btrfs_root *root, | 1038 | struct btrfs_fs_info *fs_info, |
1039 | struct btrfs_path *path, | 1039 | struct btrfs_path *path, |
1040 | u64 owner, u32 extra_size) | 1040 | u64 owner, u32 extra_size) |
1041 | { | 1041 | { |
1042 | struct btrfs_root *root = fs_info->extent_root; | ||
1042 | struct btrfs_extent_item *item; | 1043 | struct btrfs_extent_item *item; |
1043 | struct btrfs_extent_item_v0 *ei0; | 1044 | struct btrfs_extent_item_v0 *ei0; |
1044 | struct btrfs_extent_ref_v0 *ref0; | 1045 | struct btrfs_extent_ref_v0 *ref0; |
@@ -1092,7 +1093,7 @@ static int convert_extent_item_v0(struct btrfs_trans_handle *trans, | |||
1092 | return ret; | 1093 | return ret; |
1093 | BUG_ON(ret); /* Corruption */ | 1094 | BUG_ON(ret); /* Corruption */ |
1094 | 1095 | ||
1095 | btrfs_extend_item(root->fs_info, path, new_size); | 1096 | btrfs_extend_item(fs_info, path, new_size); |
1096 | 1097 | ||
1097 | leaf = path->nodes[0]; | 1098 | leaf = path->nodes[0]; |
1098 | item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); | 1099 | item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); |
@@ -1151,12 +1152,13 @@ static int match_extent_data_ref(struct extent_buffer *leaf, | |||
1151 | } | 1152 | } |
1152 | 1153 | ||
1153 | static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, | 1154 | static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, |
1154 | struct btrfs_root *root, | 1155 | struct btrfs_fs_info *fs_info, |
1155 | struct btrfs_path *path, | 1156 | struct btrfs_path *path, |
1156 | u64 bytenr, u64 parent, | 1157 | u64 bytenr, u64 parent, |
1157 | u64 root_objectid, | 1158 | u64 root_objectid, |
1158 | u64 owner, u64 offset) | 1159 | u64 owner, u64 offset) |
1159 | { | 1160 | { |
1161 | struct btrfs_root *root = fs_info->extent_root; | ||
1160 | struct btrfs_key key; | 1162 | struct btrfs_key key; |
1161 | struct btrfs_extent_data_ref *ref; | 1163 | struct btrfs_extent_data_ref *ref; |
1162 | struct extent_buffer *leaf; | 1164 | struct extent_buffer *leaf; |
@@ -1238,12 +1240,13 @@ fail: | |||
1238 | } | 1240 | } |
1239 | 1241 | ||
1240 | static noinline int insert_extent_data_ref(struct btrfs_trans_handle *trans, | 1242 | static noinline int insert_extent_data_ref(struct btrfs_trans_handle *trans, |
1241 | struct btrfs_root *root, | 1243 | struct btrfs_fs_info *fs_info, |
1242 | struct btrfs_path *path, | 1244 | struct btrfs_path *path, |
1243 | u64 bytenr, u64 parent, | 1245 | u64 bytenr, u64 parent, |
1244 | u64 root_objectid, u64 owner, | 1246 | u64 root_objectid, u64 owner, |
1245 | u64 offset, int refs_to_add) | 1247 | u64 offset, int refs_to_add) |
1246 | { | 1248 | { |
1249 | struct btrfs_root *root = fs_info->extent_root; | ||
1247 | struct btrfs_key key; | 1250 | struct btrfs_key key; |
1248 | struct extent_buffer *leaf; | 1251 | struct extent_buffer *leaf; |
1249 | u32 size; | 1252 | u32 size; |
@@ -1317,7 +1320,7 @@ fail: | |||
1317 | } | 1320 | } |
1318 | 1321 | ||
1319 | static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans, | 1322 | static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans, |
1320 | struct btrfs_root *root, | 1323 | struct btrfs_fs_info *fs_info, |
1321 | struct btrfs_path *path, | 1324 | struct btrfs_path *path, |
1322 | int refs_to_drop, int *last_ref) | 1325 | int refs_to_drop, int *last_ref) |
1323 | { | 1326 | { |
@@ -1354,7 +1357,7 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans, | |||
1354 | num_refs -= refs_to_drop; | 1357 | num_refs -= refs_to_drop; |
1355 | 1358 | ||
1356 | if (num_refs == 0) { | 1359 | if (num_refs == 0) { |
1357 | ret = btrfs_del_item(trans, root, path); | 1360 | ret = btrfs_del_item(trans, fs_info->extent_root, path); |
1358 | *last_ref = 1; | 1361 | *last_ref = 1; |
1359 | } else { | 1362 | } else { |
1360 | if (key.type == BTRFS_EXTENT_DATA_REF_KEY) | 1363 | if (key.type == BTRFS_EXTENT_DATA_REF_KEY) |
@@ -1416,11 +1419,12 @@ static noinline u32 extent_data_ref_count(struct btrfs_path *path, | |||
1416 | } | 1419 | } |
1417 | 1420 | ||
1418 | static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans, | 1421 | static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans, |
1419 | struct btrfs_root *root, | 1422 | struct btrfs_fs_info *fs_info, |
1420 | struct btrfs_path *path, | 1423 | struct btrfs_path *path, |
1421 | u64 bytenr, u64 parent, | 1424 | u64 bytenr, u64 parent, |
1422 | u64 root_objectid) | 1425 | u64 root_objectid) |
1423 | { | 1426 | { |
1427 | struct btrfs_root *root = fs_info->extent_root; | ||
1424 | struct btrfs_key key; | 1428 | struct btrfs_key key; |
1425 | int ret; | 1429 | int ret; |
1426 | 1430 | ||
@@ -1449,7 +1453,7 @@ static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans, | |||
1449 | } | 1453 | } |
1450 | 1454 | ||
1451 | static noinline int insert_tree_block_ref(struct btrfs_trans_handle *trans, | 1455 | static noinline int insert_tree_block_ref(struct btrfs_trans_handle *trans, |
1452 | struct btrfs_root *root, | 1456 | struct btrfs_fs_info *fs_info, |
1453 | struct btrfs_path *path, | 1457 | struct btrfs_path *path, |
1454 | u64 bytenr, u64 parent, | 1458 | u64 bytenr, u64 parent, |
1455 | u64 root_objectid) | 1459 | u64 root_objectid) |
@@ -1466,7 +1470,8 @@ static noinline int insert_tree_block_ref(struct btrfs_trans_handle *trans, | |||
1466 | key.offset = root_objectid; | 1470 | key.offset = root_objectid; |
1467 | } | 1471 | } |
1468 | 1472 | ||
1469 | ret = btrfs_insert_empty_item(trans, root, path, &key, 0); | 1473 | ret = btrfs_insert_empty_item(trans, fs_info->extent_root, |
1474 | path, &key, 0); | ||
1470 | btrfs_release_path(path); | 1475 | btrfs_release_path(path); |
1471 | return ret; | 1476 | return ret; |
1472 | } | 1477 | } |
@@ -1524,14 +1529,14 @@ static int find_next_key(struct btrfs_path *path, int level, | |||
1524 | */ | 1529 | */ |
1525 | static noinline_for_stack | 1530 | static noinline_for_stack |
1526 | int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, | 1531 | int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, |
1527 | struct btrfs_root *root, | 1532 | struct btrfs_fs_info *fs_info, |
1528 | struct btrfs_path *path, | 1533 | struct btrfs_path *path, |
1529 | struct btrfs_extent_inline_ref **ref_ret, | 1534 | struct btrfs_extent_inline_ref **ref_ret, |
1530 | u64 bytenr, u64 num_bytes, | 1535 | u64 bytenr, u64 num_bytes, |
1531 | u64 parent, u64 root_objectid, | 1536 | u64 parent, u64 root_objectid, |
1532 | u64 owner, u64 offset, int insert) | 1537 | u64 owner, u64 offset, int insert) |
1533 | { | 1538 | { |
1534 | struct btrfs_fs_info *fs_info = root->fs_info; | 1539 | struct btrfs_root *root = fs_info->extent_root; |
1535 | struct btrfs_key key; | 1540 | struct btrfs_key key; |
1536 | struct extent_buffer *leaf; | 1541 | struct extent_buffer *leaf; |
1537 | struct btrfs_extent_item *ei; | 1542 | struct btrfs_extent_item *ei; |
@@ -1614,7 +1619,7 @@ again: | |||
1614 | err = -ENOENT; | 1619 | err = -ENOENT; |
1615 | goto out; | 1620 | goto out; |
1616 | } | 1621 | } |
1617 | ret = convert_extent_item_v0(trans, root, path, owner, | 1622 | ret = convert_extent_item_v0(trans, fs_info, path, owner, |
1618 | extra_size); | 1623 | extra_size); |
1619 | if (ret < 0) { | 1624 | if (ret < 0) { |
1620 | err = ret; | 1625 | err = ret; |
@@ -1716,7 +1721,7 @@ out: | |||
1716 | * helper to add new inline back ref | 1721 | * helper to add new inline back ref |
1717 | */ | 1722 | */ |
1718 | static noinline_for_stack | 1723 | static noinline_for_stack |
1719 | void setup_inline_extent_backref(struct btrfs_root *root, | 1724 | void setup_inline_extent_backref(struct btrfs_fs_info *fs_info, |
1720 | struct btrfs_path *path, | 1725 | struct btrfs_path *path, |
1721 | struct btrfs_extent_inline_ref *iref, | 1726 | struct btrfs_extent_inline_ref *iref, |
1722 | u64 parent, u64 root_objectid, | 1727 | u64 parent, u64 root_objectid, |
@@ -1739,7 +1744,7 @@ void setup_inline_extent_backref(struct btrfs_root *root, | |||
1739 | type = extent_ref_type(parent, owner); | 1744 | type = extent_ref_type(parent, owner); |
1740 | size = btrfs_extent_inline_ref_size(type); | 1745 | size = btrfs_extent_inline_ref_size(type); |
1741 | 1746 | ||
1742 | btrfs_extend_item(root->fs_info, path, size); | 1747 | btrfs_extend_item(fs_info, path, size); |
1743 | 1748 | ||
1744 | ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); | 1749 | ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item); |
1745 | refs = btrfs_extent_refs(leaf, ei); | 1750 | refs = btrfs_extent_refs(leaf, ei); |
@@ -1777,7 +1782,7 @@ void setup_inline_extent_backref(struct btrfs_root *root, | |||
1777 | } | 1782 | } |
1778 | 1783 | ||
1779 | static int lookup_extent_backref(struct btrfs_trans_handle *trans, | 1784 | static int lookup_extent_backref(struct btrfs_trans_handle *trans, |
1780 | struct btrfs_root *root, | 1785 | struct btrfs_fs_info *fs_info, |
1781 | struct btrfs_path *path, | 1786 | struct btrfs_path *path, |
1782 | struct btrfs_extent_inline_ref **ref_ret, | 1787 | struct btrfs_extent_inline_ref **ref_ret, |
1783 | u64 bytenr, u64 num_bytes, u64 parent, | 1788 | u64 bytenr, u64 num_bytes, u64 parent, |
@@ -1785,7 +1790,7 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans, | |||
1785 | { | 1790 | { |
1786 | int ret; | 1791 | int ret; |
1787 | 1792 | ||
1788 | ret = lookup_inline_extent_backref(trans, root, path, ref_ret, | 1793 | ret = lookup_inline_extent_backref(trans, fs_info, path, ref_ret, |
1789 | bytenr, num_bytes, parent, | 1794 | bytenr, num_bytes, parent, |
1790 | root_objectid, owner, offset, 0); | 1795 | root_objectid, owner, offset, 0); |
1791 | if (ret != -ENOENT) | 1796 | if (ret != -ENOENT) |
@@ -1795,11 +1800,12 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans, | |||
1795 | *ref_ret = NULL; | 1800 | *ref_ret = NULL; |
1796 | 1801 | ||
1797 | if (owner < BTRFS_FIRST_FREE_OBJECTID) { | 1802 | if (owner < BTRFS_FIRST_FREE_OBJECTID) { |
1798 | ret = lookup_tree_block_ref(trans, root, path, bytenr, parent, | 1803 | ret = lookup_tree_block_ref(trans, fs_info, path, bytenr, |
1799 | root_objectid); | 1804 | parent, root_objectid); |
1800 | } else { | 1805 | } else { |
1801 | ret = lookup_extent_data_ref(trans, root, path, bytenr, parent, | 1806 | ret = lookup_extent_data_ref(trans, fs_info, path, bytenr, |
1802 | root_objectid, owner, offset); | 1807 | parent, root_objectid, owner, |
1808 | offset); | ||
1803 | } | 1809 | } |
1804 | return ret; | 1810 | return ret; |
1805 | } | 1811 | } |
@@ -1808,7 +1814,7 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans, | |||
1808 | * helper to update/remove inline back ref | 1814 | * helper to update/remove inline back ref |
1809 | */ | 1815 | */ |
1810 | static noinline_for_stack | 1816 | static noinline_for_stack |
1811 | void update_inline_extent_backref(struct btrfs_root *root, | 1817 | void update_inline_extent_backref(struct btrfs_fs_info *fs_info, |
1812 | struct btrfs_path *path, | 1818 | struct btrfs_path *path, |
1813 | struct btrfs_extent_inline_ref *iref, | 1819 | struct btrfs_extent_inline_ref *iref, |
1814 | int refs_to_mod, | 1820 | int refs_to_mod, |
@@ -1866,14 +1872,14 @@ void update_inline_extent_backref(struct btrfs_root *root, | |||
1866 | memmove_extent_buffer(leaf, ptr, ptr + size, | 1872 | memmove_extent_buffer(leaf, ptr, ptr + size, |
1867 | end - ptr - size); | 1873 | end - ptr - size); |
1868 | item_size -= size; | 1874 | item_size -= size; |
1869 | btrfs_truncate_item(root->fs_info, path, item_size, 1); | 1875 | btrfs_truncate_item(fs_info, path, item_size, 1); |
1870 | } | 1876 | } |
1871 | btrfs_mark_buffer_dirty(leaf); | 1877 | btrfs_mark_buffer_dirty(leaf); |
1872 | } | 1878 | } |
1873 | 1879 | ||
1874 | static noinline_for_stack | 1880 | static noinline_for_stack |
1875 | int insert_inline_extent_backref(struct btrfs_trans_handle *trans, | 1881 | int insert_inline_extent_backref(struct btrfs_trans_handle *trans, |
1876 | struct btrfs_root *root, | 1882 | struct btrfs_fs_info *fs_info, |
1877 | struct btrfs_path *path, | 1883 | struct btrfs_path *path, |
1878 | u64 bytenr, u64 num_bytes, u64 parent, | 1884 | u64 bytenr, u64 num_bytes, u64 parent, |
1879 | u64 root_objectid, u64 owner, | 1885 | u64 root_objectid, u64 owner, |
@@ -1883,15 +1889,15 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans, | |||
1883 | struct btrfs_extent_inline_ref *iref; | 1889 | struct btrfs_extent_inline_ref *iref; |
1884 | int ret; | 1890 | int ret; |
1885 | 1891 | ||
1886 | ret = lookup_inline_extent_backref(trans, root, path, &iref, | 1892 | ret = lookup_inline_extent_backref(trans, fs_info, path, &iref, |
1887 | bytenr, num_bytes, parent, | 1893 | bytenr, num_bytes, parent, |
1888 | root_objectid, owner, offset, 1); | 1894 | root_objectid, owner, offset, 1); |
1889 | if (ret == 0) { | 1895 | if (ret == 0) { |
1890 | BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID); | 1896 | BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID); |
1891 | update_inline_extent_backref(root, path, iref, | 1897 | update_inline_extent_backref(fs_info, path, iref, |
1892 | refs_to_add, extent_op, NULL); | 1898 | refs_to_add, extent_op, NULL); |
1893 | } else if (ret == -ENOENT) { | 1899 | } else if (ret == -ENOENT) { |
1894 | setup_inline_extent_backref(root, path, iref, parent, | 1900 | setup_inline_extent_backref(fs_info, path, iref, parent, |
1895 | root_objectid, owner, offset, | 1901 | root_objectid, owner, offset, |
1896 | refs_to_add, extent_op); | 1902 | refs_to_add, extent_op); |
1897 | ret = 0; | 1903 | ret = 0; |
@@ -1900,7 +1906,7 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans, | |||
1900 | } | 1906 | } |
1901 | 1907 | ||
1902 | static int insert_extent_backref(struct btrfs_trans_handle *trans, | 1908 | static int insert_extent_backref(struct btrfs_trans_handle *trans, |
1903 | struct btrfs_root *root, | 1909 | struct btrfs_fs_info *fs_info, |
1904 | struct btrfs_path *path, | 1910 | struct btrfs_path *path, |
1905 | u64 bytenr, u64 parent, u64 root_objectid, | 1911 | u64 bytenr, u64 parent, u64 root_objectid, |
1906 | u64 owner, u64 offset, int refs_to_add) | 1912 | u64 owner, u64 offset, int refs_to_add) |
@@ -1908,10 +1914,10 @@ static int insert_extent_backref(struct btrfs_trans_handle *trans, | |||
1908 | int ret; | 1914 | int ret; |
1909 | if (owner < BTRFS_FIRST_FREE_OBJECTID) { | 1915 | if (owner < BTRFS_FIRST_FREE_OBJECTID) { |
1910 | BUG_ON(refs_to_add != 1); | 1916 | BUG_ON(refs_to_add != 1); |
1911 | ret = insert_tree_block_ref(trans, root, path, bytenr, | 1917 | ret = insert_tree_block_ref(trans, fs_info, path, bytenr, |
1912 | parent, root_objectid); | 1918 | parent, root_objectid); |
1913 | } else { | 1919 | } else { |
1914 | ret = insert_extent_data_ref(trans, root, path, bytenr, | 1920 | ret = insert_extent_data_ref(trans, fs_info, path, bytenr, |
1915 | parent, root_objectid, | 1921 | parent, root_objectid, |
1916 | owner, offset, refs_to_add); | 1922 | owner, offset, refs_to_add); |
1917 | } | 1923 | } |
@@ -1919,7 +1925,7 @@ static int insert_extent_backref(struct btrfs_trans_handle *trans, | |||
1919 | } | 1925 | } |
1920 | 1926 | ||
1921 | static int remove_extent_backref(struct btrfs_trans_handle *trans, | 1927 | static int remove_extent_backref(struct btrfs_trans_handle *trans, |
1922 | struct btrfs_root *root, | 1928 | struct btrfs_fs_info *fs_info, |
1923 | struct btrfs_path *path, | 1929 | struct btrfs_path *path, |
1924 | struct btrfs_extent_inline_ref *iref, | 1930 | struct btrfs_extent_inline_ref *iref, |
1925 | int refs_to_drop, int is_data, int *last_ref) | 1931 | int refs_to_drop, int is_data, int *last_ref) |
@@ -1928,14 +1934,14 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans, | |||
1928 | 1934 | ||
1929 | BUG_ON(!is_data && refs_to_drop != 1); | 1935 | BUG_ON(!is_data && refs_to_drop != 1); |
1930 | if (iref) { | 1936 | if (iref) { |
1931 | update_inline_extent_backref(root, path, iref, | 1937 | update_inline_extent_backref(fs_info, path, iref, |
1932 | -refs_to_drop, NULL, last_ref); | 1938 | -refs_to_drop, NULL, last_ref); |
1933 | } else if (is_data) { | 1939 | } else if (is_data) { |
1934 | ret = remove_extent_data_ref(trans, root, path, refs_to_drop, | 1940 | ret = remove_extent_data_ref(trans, fs_info, path, refs_to_drop, |
1935 | last_ref); | 1941 | last_ref); |
1936 | } else { | 1942 | } else { |
1937 | *last_ref = 1; | 1943 | *last_ref = 1; |
1938 | ret = btrfs_del_item(trans, root, path); | 1944 | ret = btrfs_del_item(trans, fs_info->extent_root, path); |
1939 | } | 1945 | } |
1940 | return ret; | 1946 | return ret; |
1941 | } | 1947 | } |
@@ -2117,9 +2123,9 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, | |||
2117 | path->reada = READA_FORWARD; | 2123 | path->reada = READA_FORWARD; |
2118 | path->leave_spinning = 1; | 2124 | path->leave_spinning = 1; |
2119 | /* this will setup the path even if it fails to insert the back ref */ | 2125 | /* this will setup the path even if it fails to insert the back ref */ |
2120 | ret = insert_inline_extent_backref(trans, fs_info->extent_root, path, | 2126 | ret = insert_inline_extent_backref(trans, fs_info, path, bytenr, |
2121 | bytenr, num_bytes, parent, | 2127 | num_bytes, parent, root_objectid, |
2122 | root_objectid, owner, offset, | 2128 | owner, offset, |
2123 | refs_to_add, extent_op); | 2129 | refs_to_add, extent_op); |
2124 | if ((ret < 0 && ret != -EAGAIN) || !ret) | 2130 | if ((ret < 0 && ret != -EAGAIN) || !ret) |
2125 | goto out; | 2131 | goto out; |
@@ -2143,9 +2149,8 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, | |||
2143 | path->reada = READA_FORWARD; | 2149 | path->reada = READA_FORWARD; |
2144 | path->leave_spinning = 1; | 2150 | path->leave_spinning = 1; |
2145 | /* now insert the actual backref */ | 2151 | /* now insert the actual backref */ |
2146 | ret = insert_extent_backref(trans, fs_info->extent_root, | 2152 | ret = insert_extent_backref(trans, fs_info, path, bytenr, parent, |
2147 | path, bytenr, parent, root_objectid, | 2153 | root_objectid, owner, offset, refs_to_add); |
2148 | owner, offset, refs_to_add); | ||
2149 | if (ret) | 2154 | if (ret) |
2150 | btrfs_abort_transaction(trans, ret); | 2155 | btrfs_abort_transaction(trans, ret); |
2151 | out: | 2156 | out: |
@@ -2290,8 +2295,7 @@ again: | |||
2290 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); | 2295 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); |
2291 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 | 2296 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 |
2292 | if (item_size < sizeof(*ei)) { | 2297 | if (item_size < sizeof(*ei)) { |
2293 | ret = convert_extent_item_v0(trans, fs_info->extent_root, | 2298 | ret = convert_extent_item_v0(trans, fs_info, path, (u64)-1, 0); |
2294 | path, (u64)-1, 0); | ||
2295 | if (ret < 0) { | 2299 | if (ret < 0) { |
2296 | err = ret; | 2300 | err = ret; |
2297 | goto out; | 2301 | goto out; |
@@ -6841,7 +6845,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
6841 | if (is_data) | 6845 | if (is_data) |
6842 | skinny_metadata = 0; | 6846 | skinny_metadata = 0; |
6843 | 6847 | ||
6844 | ret = lookup_extent_backref(trans, extent_root, path, &iref, | 6848 | ret = lookup_extent_backref(trans, info, path, &iref, |
6845 | bytenr, num_bytes, parent, | 6849 | bytenr, num_bytes, parent, |
6846 | root_objectid, owner_objectid, | 6850 | root_objectid, owner_objectid, |
6847 | owner_offset); | 6851 | owner_offset); |
@@ -6873,8 +6877,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
6873 | #endif | 6877 | #endif |
6874 | if (!found_extent) { | 6878 | if (!found_extent) { |
6875 | BUG_ON(iref); | 6879 | BUG_ON(iref); |
6876 | ret = remove_extent_backref(trans, extent_root, path, | 6880 | ret = remove_extent_backref(trans, info, path, NULL, |
6877 | NULL, refs_to_drop, | 6881 | refs_to_drop, |
6878 | is_data, &last_ref); | 6882 | is_data, &last_ref); |
6879 | if (ret) { | 6883 | if (ret) { |
6880 | btrfs_abort_transaction(trans, ret); | 6884 | btrfs_abort_transaction(trans, ret); |
@@ -6949,8 +6953,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
6949 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 | 6953 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 |
6950 | if (item_size < sizeof(*ei)) { | 6954 | if (item_size < sizeof(*ei)) { |
6951 | BUG_ON(found_extent || extent_slot != path->slots[0]); | 6955 | BUG_ON(found_extent || extent_slot != path->slots[0]); |
6952 | ret = convert_extent_item_v0(trans, extent_root, path, | 6956 | ret = convert_extent_item_v0(trans, info, path, owner_objectid, |
6953 | owner_objectid, 0); | 6957 | 0); |
6954 | if (ret < 0) { | 6958 | if (ret < 0) { |
6955 | btrfs_abort_transaction(trans, ret); | 6959 | btrfs_abort_transaction(trans, ret); |
6956 | goto out; | 6960 | goto out; |
@@ -7017,7 +7021,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
7017 | btrfs_mark_buffer_dirty(leaf); | 7021 | btrfs_mark_buffer_dirty(leaf); |
7018 | } | 7022 | } |
7019 | if (found_extent) { | 7023 | if (found_extent) { |
7020 | ret = remove_extent_backref(trans, extent_root, path, | 7024 | ret = remove_extent_backref(trans, info, path, |
7021 | iref, refs_to_drop, | 7025 | iref, refs_to_drop, |
7022 | is_data, &last_ref); | 7026 | is_data, &last_ref); |
7023 | if (ret) { | 7027 | if (ret) { |
@@ -7415,12 +7419,11 @@ btrfs_release_block_group(struct btrfs_block_group_cache *cache, | |||
7415 | * If there is no suitable free space, we will record the max size of | 7419 | * If there is no suitable free space, we will record the max size of |
7416 | * the free space extent currently. | 7420 | * the free space extent currently. |
7417 | */ | 7421 | */ |
7418 | static noinline int find_free_extent(struct btrfs_root *orig_root, | 7422 | static noinline int find_free_extent(struct btrfs_fs_info *fs_info, |
7419 | u64 ram_bytes, u64 num_bytes, u64 empty_size, | 7423 | u64 ram_bytes, u64 num_bytes, u64 empty_size, |
7420 | u64 hint_byte, struct btrfs_key *ins, | 7424 | u64 hint_byte, struct btrfs_key *ins, |
7421 | u64 flags, int delalloc) | 7425 | u64 flags, int delalloc) |
7422 | { | 7426 | { |
7423 | struct btrfs_fs_info *fs_info = orig_root->fs_info; | ||
7424 | int ret = 0; | 7427 | int ret = 0; |
7425 | struct btrfs_root *root = fs_info->extent_root; | 7428 | struct btrfs_root *root = fs_info->extent_root; |
7426 | struct btrfs_free_cluster *last_ptr = NULL; | 7429 | struct btrfs_free_cluster *last_ptr = NULL; |
@@ -7948,7 +7951,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, | |||
7948 | flags = btrfs_get_alloc_profile(root, is_data); | 7951 | flags = btrfs_get_alloc_profile(root, is_data); |
7949 | again: | 7952 | again: |
7950 | WARN_ON(num_bytes < fs_info->sectorsize); | 7953 | WARN_ON(num_bytes < fs_info->sectorsize); |
7951 | ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, | 7954 | ret = find_free_extent(fs_info, ram_bytes, num_bytes, empty_size, |
7952 | hint_byte, ins, flags, delalloc); | 7955 | hint_byte, ins, flags, delalloc); |
7953 | if (!ret && !is_data) { | 7956 | if (!ret && !is_data) { |
7954 | btrfs_dec_block_group_reservations(fs_info, ins->objectid); | 7957 | btrfs_dec_block_group_reservations(fs_info, ins->objectid); |