btrfs: Remove V0 extent support
authorNikolay Borisov <nborisov@suse.com>
Thu, 21 Jun 2018 06:45:00 +0000 (09:45 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 6 Aug 2018 11:12:41 +0000 (13:12 +0200)
The v0 compat code was introduced in commit 5d4f98a28c7d
("Btrfs: Mixed back reference  (FORWARD ROLLING FORMAT CHANGE)") 9
years ago, which was merged in 2.6.31. This means that the code is
there to support filesystems which are _VERY_ old and if you are using
btrfs on such an old kernel, you have much bigger problems. This coupled
with the fact that no one is likely testing/maintining this code likely
means it has bugs lurking. All things considered I think 43 kernel
releases later it's high time this remnant of the past got removed.

This patch removes all code wrapped in #ifdefs but leaves the BUG_ONs in case
we have a v0 with no support intact as a sort of safety-net.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/print-tree.c
fs/btrfs/relocation.c

index 18f1ca1c5bd98b922be4f312bd3f4a94da740868..d436fb4c002ea563a93482ce263edca1b5f5c490 100644 (file)
@@ -888,11 +888,7 @@ int btrfs_block_can_be_shared(struct btrfs_root *root,
             btrfs_root_last_snapshot(&root->root_item) ||
             btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)))
                return 1;
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) &&
-           btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
-               return 1;
-#endif
+
        return 0;
 }
 
index 41ba770b9db9ff23c56b655ced106fbb6ff850a9..9fa958ed065ef82ec5c44bab30edd0039beaa5dc 100644 (file)
@@ -55,8 +55,6 @@ struct btrfs_ordered_sum;
 
 #define BTRFS_OLDEST_GENERATION        0ULL
 
-#define BTRFS_COMPAT_EXTENT_TREE_V0
-
 /*
  * the max metadata block size.  This limit is somewhat artificial,
  * but the memmove costs go through the roof for larger blocks.
index b28fa3d20ef72f62633311aef3efe558bb56ba0b..6a73d26988071c9b38eb471e597a40370b47e92d 100644 (file)
@@ -867,17 +867,7 @@ search_again:
                        num_refs = btrfs_extent_refs(leaf, ei);
                        extent_flags = btrfs_extent_flags(leaf, ei);
                } else {
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-                       struct btrfs_extent_item_v0 *ei0;
-                       BUG_ON(item_size != sizeof(*ei0));
-                       ei0 = btrfs_item_ptr(leaf, path->slots[0],
-                                            struct btrfs_extent_item_v0);
-                       num_refs = btrfs_extent_refs_v0(leaf, ei0);
-                       /* FIXME: this isn't correct for data */
-                       extent_flags = BTRFS_BLOCK_FLAG_FULL_BACKREF;
-#else
                        BUG();
-#endif
                }
                BUG_ON(num_refs == 0);
        } else {
@@ -1036,89 +1026,6 @@ out_free:
  * tree block info structure.
  */
 
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-static int convert_extent_item_v0(struct btrfs_trans_handle *trans,
-                                 struct btrfs_fs_info *fs_info,
-                                 struct btrfs_path *path,
-                                 u64 owner, u32 extra_size)
-{
-       struct btrfs_root *root = fs_info->extent_root;
-       struct btrfs_extent_item *item;
-       struct btrfs_extent_item_v0 *ei0;
-       struct btrfs_extent_ref_v0 *ref0;
-       struct btrfs_tree_block_info *bi;
-       struct extent_buffer *leaf;
-       struct btrfs_key key;
-       struct btrfs_key found_key;
-       u32 new_size = sizeof(*item);
-       u64 refs;
-       int ret;
-
-       leaf = path->nodes[0];
-       BUG_ON(btrfs_item_size_nr(leaf, path->slots[0]) != sizeof(*ei0));
-
-       btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
-       ei0 = btrfs_item_ptr(leaf, path->slots[0],
-                            struct btrfs_extent_item_v0);
-       refs = btrfs_extent_refs_v0(leaf, ei0);
-
-       if (owner == (u64)-1) {
-               while (1) {
-                       if (path->slots[0] >= btrfs_header_nritems(leaf)) {
-                               ret = btrfs_next_leaf(root, path);
-                               if (ret < 0)
-                                       return ret;
-                               BUG_ON(ret > 0); /* Corruption */
-                               leaf = path->nodes[0];
-                       }
-                       btrfs_item_key_to_cpu(leaf, &found_key,
-                                             path->slots[0]);
-                       BUG_ON(key.objectid != found_key.objectid);
-                       if (found_key.type != BTRFS_EXTENT_REF_V0_KEY) {
-                               path->slots[0]++;
-                               continue;
-                       }
-                       ref0 = btrfs_item_ptr(leaf, path->slots[0],
-                                             struct btrfs_extent_ref_v0);
-                       owner = btrfs_ref_objectid_v0(leaf, ref0);
-                       break;
-               }
-       }
-       btrfs_release_path(path);
-
-       if (owner < BTRFS_FIRST_FREE_OBJECTID)
-               new_size += sizeof(*bi);
-
-       new_size -= sizeof(*ei0);
-       ret = btrfs_search_slot(trans, root, &key, path,
-                               new_size + extra_size, 1);
-       if (ret < 0)
-               return ret;
-       BUG_ON(ret); /* Corruption */
-
-       btrfs_extend_item(fs_info, path, new_size);
-
-       leaf = path->nodes[0];
-       item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
-       btrfs_set_extent_refs(leaf, item, refs);
-       /* FIXME: get real generation */
-       btrfs_set_extent_generation(leaf, item, 0);
-       if (owner < BTRFS_FIRST_FREE_OBJECTID) {
-               btrfs_set_extent_flags(leaf, item,
-                                      BTRFS_EXTENT_FLAG_TREE_BLOCK |
-                                      BTRFS_BLOCK_FLAG_FULL_BACKREF);
-               bi = (struct btrfs_tree_block_info *)(item + 1);
-               /* FIXME: get first key of the block */
-               memzero_extent_buffer(leaf, (unsigned long)bi, sizeof(*bi));
-               btrfs_set_tree_block_level(leaf, bi, (int)owner);
-       } else {
-               btrfs_set_extent_flags(leaf, item, BTRFS_EXTENT_FLAG_DATA);
-       }
-       btrfs_mark_buffer_dirty(leaf);
-       return 0;
-}
-#endif
-
 /*
  * is_data == BTRFS_REF_TYPE_BLOCK, tree block type is required,
  * is_data == BTRFS_REF_TYPE_DATA, data type is requried,
@@ -1247,17 +1154,6 @@ again:
        if (parent) {
                if (!ret)
                        return 0;
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               key.type = BTRFS_EXTENT_REF_V0_KEY;
-               btrfs_release_path(path);
-               ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
-               if (ret < 0) {
-                       err = ret;
-                       goto fail;
-               }
-               if (!ret)
-                       return 0;
-#endif
                goto fail;
        }
 
@@ -1400,13 +1296,6 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
                ref2 = btrfs_item_ptr(leaf, path->slots[0],
                                      struct btrfs_shared_data_ref);
                num_refs = btrfs_shared_data_ref_count(leaf, ref2);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       } else if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
-               struct btrfs_extent_ref_v0 *ref0;
-               ref0 = btrfs_item_ptr(leaf, path->slots[0],
-                                     struct btrfs_extent_ref_v0);
-               num_refs = btrfs_ref_count_v0(leaf, ref0);
-#endif
        } else {
                BUG();
        }
@@ -1422,14 +1311,6 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
                        btrfs_set_extent_data_ref_count(leaf, ref1, num_refs);
                else if (key.type == BTRFS_SHARED_DATA_REF_KEY)
                        btrfs_set_shared_data_ref_count(leaf, ref2, num_refs);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               else {
-                       struct btrfs_extent_ref_v0 *ref0;
-                       ref0 = btrfs_item_ptr(leaf, path->slots[0],
-                                       struct btrfs_extent_ref_v0);
-                       btrfs_set_ref_count_v0(leaf, ref0, num_refs);
-               }
-#endif
                btrfs_mark_buffer_dirty(leaf);
        }
        return ret;
@@ -1469,13 +1350,6 @@ static noinline u32 extent_data_ref_count(struct btrfs_path *path,
                ref2 = btrfs_item_ptr(leaf, path->slots[0],
                                      struct btrfs_shared_data_ref);
                num_refs = btrfs_shared_data_ref_count(leaf, ref2);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       } else if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
-               struct btrfs_extent_ref_v0 *ref0;
-               ref0 = btrfs_item_ptr(leaf, path->slots[0],
-                                     struct btrfs_extent_ref_v0);
-               num_refs = btrfs_ref_count_v0(leaf, ref0);
-#endif
        } else {
                WARN_ON(1);
        }
@@ -1503,15 +1377,6 @@ static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans,
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
        if (ret > 0)
                ret = -ENOENT;
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (ret == -ENOENT && parent) {
-               btrfs_release_path(path);
-               key.type = BTRFS_EXTENT_REF_V0_KEY;
-               ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
-               if (ret > 0)
-                       ret = -ENOENT;
-       }
-#endif
        return ret;
 }
 
@@ -1676,22 +1541,6 @@ again:
 
        leaf = path->nodes[0];
        item_size = btrfs_item_size_nr(leaf, path->slots[0]);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (item_size < sizeof(*ei)) {
-               if (!insert) {
-                       err = -ENOENT;
-                       goto out;
-               }
-               ret = convert_extent_item_v0(trans, fs_info, path, owner,
-                                            extra_size);
-               if (ret < 0) {
-                       err = ret;
-                       goto out;
-               }
-               leaf = path->nodes[0];
-               item_size = btrfs_item_size_nr(leaf, path->slots[0]);
-       }
-#endif
        BUG_ON(item_size < sizeof(*ei));
 
        ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -2416,17 +2265,6 @@ again:
 
        leaf = path->nodes[0];
        item_size = btrfs_item_size_nr(leaf, path->slots[0]);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (item_size < sizeof(*ei)) {
-               ret = convert_extent_item_v0(trans, fs_info, path, (u64)-1, 0);
-               if (ret < 0) {
-                       err = ret;
-                       goto out;
-               }
-               leaf = path->nodes[0];
-               item_size = btrfs_item_size_nr(leaf, path->slots[0]);
-       }
-#endif
        BUG_ON(item_size < sizeof(*ei));
        ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
        __run_delayed_extent_op(extent_op, leaf, ei);
@@ -3238,12 +3076,6 @@ static noinline int check_committed_ref(struct btrfs_root *root,
 
        ret = 1;
        item_size = btrfs_item_size_nr(leaf, path->slots[0]);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (item_size < sizeof(*ei)) {
-               WARN_ON(item_size != sizeof(struct btrfs_extent_item_v0));
-               goto out;
-       }
-#endif
        ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
 
        if (item_size != sizeof(*ei) +
@@ -6888,11 +6720,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
                                break;
                        extent_slot--;
                }
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               item_size = btrfs_item_size_nr(path->nodes[0], extent_slot);
-               if (found_extent && item_size < sizeof(*ei))
-                       found_extent = 0;
-#endif
+
                if (!found_extent) {
                        BUG_ON(iref);
                        ret = remove_extent_backref(trans, path, NULL,
@@ -6968,41 +6796,6 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 
        leaf = path->nodes[0];
        item_size = btrfs_item_size_nr(leaf, extent_slot);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (item_size < sizeof(*ei)) {
-               BUG_ON(found_extent || extent_slot != path->slots[0]);
-               ret = convert_extent_item_v0(trans, info, path, owner_objectid,
-                                            0);
-               if (ret < 0) {
-                       btrfs_abort_transaction(trans, ret);
-                       goto out;
-               }
-
-               btrfs_release_path(path);
-               path->leave_spinning = 1;
-
-               key.objectid = bytenr;
-               key.type = BTRFS_EXTENT_ITEM_KEY;
-               key.offset = num_bytes;
-
-               ret = btrfs_search_slot(trans, extent_root, &key, path,
-                                       -1, 1);
-               if (ret) {
-                       btrfs_err(info,
-                                 "umm, got %d back from search, was looking for %llu",
-                               ret, bytenr);
-                       btrfs_print_leaf(path->nodes[0]);
-               }
-               if (ret < 0) {
-                       btrfs_abort_transaction(trans, ret);
-                       goto out;
-               }
-
-               extent_slot = path->slots[0];
-               leaf = path->nodes[0];
-               item_size = btrfs_item_size_nr(leaf, extent_slot);
-       }
-#endif
        BUG_ON(item_size < sizeof(*ei));
        ei = btrfs_item_ptr(leaf, extent_slot,
                            struct btrfs_extent_item);
index 59efcf2e0de8eb007257c5f827456fd895a87e8f..c0dac9d7ce331f092f92c9538f0a514bd42458f4 100644 (file)
@@ -52,18 +52,8 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
        u64 offset;
        int ref_index = 0;
 
-       if (item_size < sizeof(*ei)) {
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               struct btrfs_extent_item_v0 *ei0;
-               BUG_ON(item_size != sizeof(*ei0));
-               ei0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_item_v0);
-               pr_info("\t\textent refs %u\n",
-                      btrfs_extent_refs_v0(eb, ei0));
-               return;
-#else
+       if (item_size < sizeof(*ei))
                BUG();
-#endif
-       }
 
        ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
        flags = btrfs_extent_flags(eb, ei);
@@ -133,20 +123,6 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
        WARN_ON(ptr > end);
 }
 
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-static void print_extent_ref_v0(struct extent_buffer *eb, int slot)
-{
-       struct btrfs_extent_ref_v0 *ref0;
-
-       ref0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_ref_v0);
-       printk("\t\textent back ref root %llu gen %llu owner %llu num_refs %lu\n",
-               btrfs_ref_root_v0(eb, ref0),
-               btrfs_ref_generation_v0(eb, ref0),
-               btrfs_ref_objectid_v0(eb, ref0),
-               (unsigned long)btrfs_ref_count_v0(eb, ref0));
-}
-#endif
-
 static void print_uuid_item(struct extent_buffer *l, unsigned long offset,
                            u32 item_size)
 {
@@ -280,11 +256,7 @@ void btrfs_print_leaf(struct extent_buffer *l)
                               btrfs_file_extent_ram_bytes(l, fi));
                        break;
                case BTRFS_EXTENT_REF_V0_KEY:
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-                       print_extent_ref_v0(l, i);
-#else
                        BUG();
-#endif
                        break;
                case BTRFS_BLOCK_GROUP_ITEM_KEY:
                        bi = btrfs_item_ptr(l, i,
index 44722e939e341b47188e9e2c4bff4ba4cbd27033..6dfa92e5ceed239a7e1928ad55dc3f31eb50fdf5 100644 (file)
@@ -586,29 +586,6 @@ static struct btrfs_root *read_fs_root(struct btrfs_fs_info *fs_info,
        return btrfs_get_fs_root(fs_info, &key, false);
 }
 
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-static noinline_for_stack
-struct btrfs_root *find_tree_root(struct reloc_control *rc,
-                                 struct extent_buffer *leaf,
-                                 struct btrfs_extent_ref_v0 *ref0)
-{
-       struct btrfs_root *root;
-       u64 root_objectid = btrfs_ref_root_v0(leaf, ref0);
-       u64 generation = btrfs_ref_generation_v0(leaf, ref0);
-
-       BUG_ON(root_objectid == BTRFS_TREE_RELOC_OBJECTID);
-
-       root = read_fs_root(rc->extent_root->fs_info, root_objectid);
-       BUG_ON(IS_ERR(root));
-
-       if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) &&
-           generation != btrfs_root_generation(&root->root_item))
-               return NULL;
-
-       return root;
-}
-#endif
-
 static noinline_for_stack
 int find_inline_backref(struct extent_buffer *leaf, int slot,
                        unsigned long *ptr, unsigned long *end)
@@ -621,12 +598,6 @@ int find_inline_backref(struct extent_buffer *leaf, int slot,
        btrfs_item_key_to_cpu(leaf, &key, slot);
 
        item_size = btrfs_item_size_nr(leaf, slot);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (item_size < sizeof(*ei)) {
-               WARN_ON(item_size != sizeof(struct btrfs_extent_item_v0));
-               return 1;
-       }
-#endif
        ei = btrfs_item_ptr(leaf, slot, struct btrfs_extent_item);
        WARN_ON(!(btrfs_extent_flags(leaf, ei) &
                  BTRFS_EXTENT_FLAG_TREE_BLOCK));
@@ -811,29 +782,8 @@ again:
                        goto next;
                }
 
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               if (key.type == BTRFS_SHARED_BLOCK_REF_KEY ||
-                   key.type == BTRFS_EXTENT_REF_V0_KEY) {
-                       if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
-                               struct btrfs_extent_ref_v0 *ref0;
-                               ref0 = btrfs_item_ptr(eb, path1->slots[0],
-                                               struct btrfs_extent_ref_v0);
-                               if (key.objectid == key.offset) {
-                                       root = find_tree_root(rc, eb, ref0);
-                                       if (root && !should_ignore_root(root))
-                                               cur->root = root;
-                                       else
-                                               list_add(&cur->list, &useless);
-                                       break;
-                               }
-                               if (is_cowonly_root(btrfs_ref_root_v0(eb,
-                                                                     ref0)))
-                                       cur->cowonly = 1;
-                       }
-#else
                ASSERT(key.type != BTRFS_EXTENT_REF_V0_KEY);
                if (key.type == BTRFS_SHARED_BLOCK_REF_KEY) {
-#endif
                        if (key.objectid == key.offset) {
                                /*
                                 * only root blocks of reloc trees use
@@ -3333,48 +3283,6 @@ int relocate_data_extent(struct inode *inode, struct btrfs_key *extent_key,
        return 0;
 }
 
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-static int get_ref_objectid_v0(struct reloc_control *rc,
-                              struct btrfs_path *path,
-                              struct btrfs_key *extent_key,
-                              u64 *ref_objectid, int *path_change)
-{
-       struct btrfs_key key;
-       struct extent_buffer *leaf;
-       struct btrfs_extent_ref_v0 *ref0;
-       int ret;
-       int slot;
-
-       leaf = path->nodes[0];
-       slot = path->slots[0];
-       while (1) {
-               if (slot >= btrfs_header_nritems(leaf)) {
-                       ret = btrfs_next_leaf(rc->extent_root, path);
-                       if (ret < 0)
-                               return ret;
-                       BUG_ON(ret > 0);
-                       leaf = path->nodes[0];
-                       slot = path->slots[0];
-                       if (path_change)
-                               *path_change = 1;
-               }
-               btrfs_item_key_to_cpu(leaf, &key, slot);
-               if (key.objectid != extent_key->objectid)
-                       return -ENOENT;
-
-               if (key.type != BTRFS_EXTENT_REF_V0_KEY) {
-                       slot++;
-                       continue;
-               }
-               ref0 = btrfs_item_ptr(leaf, slot,
-                               struct btrfs_extent_ref_v0);
-               *ref_objectid = btrfs_ref_objectid_v0(leaf, ref0);
-               break;
-       }
-       return 0;
-}
-#endif
-
 /*
  * helper to add a tree block to the list.
  * the major work is getting the generation and level of the block
@@ -3408,22 +3316,7 @@ static int add_tree_block(struct reloc_control *rc,
                }
                generation = btrfs_extent_generation(eb, ei);
        } else {
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               u64 ref_owner;
-               int ret;
-
-               BUG_ON(item_size != sizeof(struct btrfs_extent_item_v0));
-               ret = get_ref_objectid_v0(rc, path, extent_key,
-                                         &ref_owner, NULL);
-               if (ret < 0)
-                       return ret;
-               BUG_ON(ref_owner >= BTRFS_MAX_LEVEL);
-               level = (int)ref_owner;
-               /* FIXME: get real generation */
-               generation = 0;
-#else
                BUG();
-#endif
        }
 
        btrfs_release_path(path);
@@ -3781,12 +3674,7 @@ int add_data_references(struct reloc_control *rc,
        eb = path->nodes[0];
        ptr = btrfs_item_ptr_offset(eb, path->slots[0]);
        end = ptr + btrfs_item_size_nr(eb, path->slots[0]);
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-       if (ptr + sizeof(struct btrfs_extent_item_v0) == end)
-               ptr = end;
-       else
-#endif
-               ptr += sizeof(struct btrfs_extent_item);
+       ptr += sizeof(struct btrfs_extent_item);
 
        while (ptr < end) {
                iref = (struct btrfs_extent_inline_ref *)ptr;
@@ -3832,13 +3720,8 @@ int add_data_references(struct reloc_control *rc,
                if (key.objectid != extent_key->objectid)
                        break;
 
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-               if (key.type == BTRFS_SHARED_DATA_REF_KEY ||
-                   key.type == BTRFS_EXTENT_REF_V0_KEY) {
-#else
                BUG_ON(key.type == BTRFS_EXTENT_REF_V0_KEY);
                if (key.type == BTRFS_SHARED_DATA_REF_KEY) {
-#endif
                        ret = __add_tree_block(rc, key.offset, blocksize,
                                               blocks);
                } else if (key.type == BTRFS_EXTENT_DATA_REF_KEY) {
@@ -4086,39 +3969,7 @@ restart:
                        BUG_ON(ret);
 
                } else {
-#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
-                       u64 ref_owner;
-                       int path_change = 0;
-
-                       BUG_ON(item_size !=
-                              sizeof(struct btrfs_extent_item_v0));
-                       ret = get_ref_objectid_v0(rc, path, &key, &ref_owner,
-                                                 &path_change);
-                       if (ret < 0) {
-                               err = ret;
-                               break;
-                       }
-                       if (ref_owner < BTRFS_FIRST_FREE_OBJECTID)
-                               flags = BTRFS_EXTENT_FLAG_TREE_BLOCK;
-                       else
-                               flags = BTRFS_EXTENT_FLAG_DATA;
-
-                       if (path_change) {
-                               btrfs_release_path(path);
-
-                               path->search_commit_root = 1;
-                               path->skip_locking = 1;
-                               ret = btrfs_search_slot(NULL, rc->extent_root,
-                                                       &key, path, 0, 0);
-                               if (ret < 0) {
-                                       err = ret;
-                                       break;
-                               }
-                               BUG_ON(ret > 0);
-                       }
-#else
                        BUG();
-#endif
                }
 
                if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {