16cbd5570SChris Mason /* 26cbd5570SChris Mason * Copyright (C) 2007 Oracle. All rights reserved. 36cbd5570SChris Mason * 46cbd5570SChris Mason * This program is free software; you can redistribute it and/or 56cbd5570SChris Mason * modify it under the terms of the GNU General Public 66cbd5570SChris Mason * License v2 as published by the Free Software Foundation. 76cbd5570SChris Mason * 86cbd5570SChris Mason * This program is distributed in the hope that it will be useful, 96cbd5570SChris Mason * but WITHOUT ANY WARRANTY; without even the implied warranty of 106cbd5570SChris Mason * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 116cbd5570SChris Mason * General Public License for more details. 126cbd5570SChris Mason * 136cbd5570SChris Mason * You should have received a copy of the GNU General Public 146cbd5570SChris Mason * License along with this program; if not, write to the 156cbd5570SChris Mason * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 166cbd5570SChris Mason * Boston, MA 021110-1307, USA. 176cbd5570SChris Mason */ 186cbd5570SChris Mason 195de08d7dSChris Mason #include "ctree.h" 205de08d7dSChris Mason #include "disk-io.h" 2135b7e476SChris Mason #include "print-tree.h" 225de08d7dSChris Mason 230b86a832SChris Mason static void print_chunk(struct extent_buffer *eb, struct btrfs_chunk *chunk) 240b86a832SChris Mason { 250b86a832SChris Mason int num_stripes = btrfs_chunk_num_stripes(eb, chunk); 260b86a832SChris Mason int i; 2762e85577SJeff Mahoney pr_info("\t\tchunk length %llu owner %llu type %llu num_stripes %d\n", 28c1c9ff7cSGeert Uytterhoeven btrfs_chunk_length(eb, chunk), btrfs_chunk_owner(eb, chunk), 29c1c9ff7cSGeert Uytterhoeven btrfs_chunk_type(eb, chunk), num_stripes); 300b86a832SChris Mason for (i = 0 ; i < num_stripes ; i++) { 3162e85577SJeff Mahoney pr_info("\t\t\tstripe %d devid %llu offset %llu\n", i, 32c1c9ff7cSGeert Uytterhoeven btrfs_stripe_devid_nr(eb, chunk, i), 33c1c9ff7cSGeert Uytterhoeven btrfs_stripe_offset_nr(eb, chunk, i)); 340b86a832SChris Mason } 350b86a832SChris Mason } 360b86a832SChris Mason static void print_dev_item(struct extent_buffer *eb, 370b86a832SChris Mason struct btrfs_dev_item *dev_item) 380b86a832SChris Mason { 3962e85577SJeff Mahoney pr_info("\t\tdev item devid %llu total_bytes %llu bytes used %llu\n", 40c1c9ff7cSGeert Uytterhoeven btrfs_device_id(eb, dev_item), 41c1c9ff7cSGeert Uytterhoeven btrfs_device_total_bytes(eb, dev_item), 42c1c9ff7cSGeert Uytterhoeven btrfs_device_bytes_used(eb, dev_item)); 430b86a832SChris Mason } 445d4f98a2SYan Zheng static void print_extent_data_ref(struct extent_buffer *eb, 455d4f98a2SYan Zheng struct btrfs_extent_data_ref *ref) 465d4f98a2SYan Zheng { 4762e85577SJeff Mahoney pr_info("\t\textent data backref root %llu objectid %llu offset %llu count %u\n", 48c1c9ff7cSGeert Uytterhoeven btrfs_extent_data_ref_root(eb, ref), 49c1c9ff7cSGeert Uytterhoeven btrfs_extent_data_ref_objectid(eb, ref), 50c1c9ff7cSGeert Uytterhoeven btrfs_extent_data_ref_offset(eb, ref), 515d4f98a2SYan Zheng btrfs_extent_data_ref_count(eb, ref)); 525d4f98a2SYan Zheng } 535d4f98a2SYan Zheng 54be2c765dSJosef Bacik static void print_extent_item(struct extent_buffer *eb, int slot, int type) 555d4f98a2SYan Zheng { 565d4f98a2SYan Zheng struct btrfs_extent_item *ei; 575d4f98a2SYan Zheng struct btrfs_extent_inline_ref *iref; 585d4f98a2SYan Zheng struct btrfs_extent_data_ref *dref; 595d4f98a2SYan Zheng struct btrfs_shared_data_ref *sref; 605d4f98a2SYan Zheng struct btrfs_disk_key key; 615d4f98a2SYan Zheng unsigned long end; 625d4f98a2SYan Zheng unsigned long ptr; 635d4f98a2SYan Zheng u32 item_size = btrfs_item_size_nr(eb, slot); 645d4f98a2SYan Zheng u64 flags; 655d4f98a2SYan Zheng u64 offset; 665d4f98a2SYan Zheng 675d4f98a2SYan Zheng if (item_size < sizeof(*ei)) { 685d4f98a2SYan Zheng #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 695d4f98a2SYan Zheng struct btrfs_extent_item_v0 *ei0; 705d4f98a2SYan Zheng BUG_ON(item_size != sizeof(*ei0)); 715d4f98a2SYan Zheng ei0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_item_v0); 7262e85577SJeff Mahoney pr_info("\t\textent refs %u\n", 735d4f98a2SYan Zheng btrfs_extent_refs_v0(eb, ei0)); 745d4f98a2SYan Zheng return; 755d4f98a2SYan Zheng #else 765d4f98a2SYan Zheng BUG(); 775d4f98a2SYan Zheng #endif 785d4f98a2SYan Zheng } 795d4f98a2SYan Zheng 805d4f98a2SYan Zheng ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item); 815d4f98a2SYan Zheng flags = btrfs_extent_flags(eb, ei); 825d4f98a2SYan Zheng 8362e85577SJeff Mahoney pr_info("\t\textent refs %llu gen %llu flags %llu\n", 84c1c9ff7cSGeert Uytterhoeven btrfs_extent_refs(eb, ei), btrfs_extent_generation(eb, ei), 85c1c9ff7cSGeert Uytterhoeven flags); 865d4f98a2SYan Zheng 87be2c765dSJosef Bacik if ((type == BTRFS_EXTENT_ITEM_KEY) && 88be2c765dSJosef Bacik flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) { 895d4f98a2SYan Zheng struct btrfs_tree_block_info *info; 905d4f98a2SYan Zheng info = (struct btrfs_tree_block_info *)(ei + 1); 915d4f98a2SYan Zheng btrfs_tree_block_key(eb, info, &key); 9262e85577SJeff Mahoney pr_info("\t\ttree block key (%llu %u %llu) level %d\n", 93c1c9ff7cSGeert Uytterhoeven btrfs_disk_key_objectid(&key), key.type, 94c1c9ff7cSGeert Uytterhoeven btrfs_disk_key_offset(&key), 955d4f98a2SYan Zheng btrfs_tree_block_level(eb, info)); 965d4f98a2SYan Zheng iref = (struct btrfs_extent_inline_ref *)(info + 1); 975d4f98a2SYan Zheng } else { 985d4f98a2SYan Zheng iref = (struct btrfs_extent_inline_ref *)(ei + 1); 995d4f98a2SYan Zheng } 1005d4f98a2SYan Zheng 1015d4f98a2SYan Zheng ptr = (unsigned long)iref; 1025d4f98a2SYan Zheng end = (unsigned long)ei + item_size; 1035d4f98a2SYan Zheng while (ptr < end) { 1045d4f98a2SYan Zheng iref = (struct btrfs_extent_inline_ref *)ptr; 1055d4f98a2SYan Zheng type = btrfs_extent_inline_ref_type(eb, iref); 1065d4f98a2SYan Zheng offset = btrfs_extent_inline_ref_offset(eb, iref); 1075d4f98a2SYan Zheng switch (type) { 1085d4f98a2SYan Zheng case BTRFS_TREE_BLOCK_REF_KEY: 10962e85577SJeff Mahoney pr_info("\t\ttree block backref root %llu\n", offset); 1105d4f98a2SYan Zheng break; 1115d4f98a2SYan Zheng case BTRFS_SHARED_BLOCK_REF_KEY: 11262e85577SJeff Mahoney pr_info("\t\tshared block backref parent %llu\n", offset); 1135d4f98a2SYan Zheng break; 1145d4f98a2SYan Zheng case BTRFS_EXTENT_DATA_REF_KEY: 1155d4f98a2SYan Zheng dref = (struct btrfs_extent_data_ref *)(&iref->offset); 1165d4f98a2SYan Zheng print_extent_data_ref(eb, dref); 1175d4f98a2SYan Zheng break; 1185d4f98a2SYan Zheng case BTRFS_SHARED_DATA_REF_KEY: 1195d4f98a2SYan Zheng sref = (struct btrfs_shared_data_ref *)(iref + 1); 12062e85577SJeff Mahoney pr_info("\t\tshared data backref parent %llu count %u\n", 121c1c9ff7cSGeert Uytterhoeven offset, btrfs_shared_data_ref_count(eb, sref)); 1225d4f98a2SYan Zheng break; 1235d4f98a2SYan Zheng default: 1245d4f98a2SYan Zheng BUG(); 1255d4f98a2SYan Zheng } 1265d4f98a2SYan Zheng ptr += btrfs_extent_inline_ref_size(type); 1275d4f98a2SYan Zheng } 1285d4f98a2SYan Zheng WARN_ON(ptr > end); 1295d4f98a2SYan Zheng } 1305d4f98a2SYan Zheng 1315d4f98a2SYan Zheng #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 1325d4f98a2SYan Zheng static void print_extent_ref_v0(struct extent_buffer *eb, int slot) 1335d4f98a2SYan Zheng { 1345d4f98a2SYan Zheng struct btrfs_extent_ref_v0 *ref0; 1355d4f98a2SYan Zheng 1365d4f98a2SYan Zheng ref0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_ref_v0); 1375d163e0eSJeff Mahoney printk("\t\textent back ref root %llu gen %llu owner %llu num_refs %lu\n", 138c1c9ff7cSGeert Uytterhoeven btrfs_ref_root_v0(eb, ref0), 139c1c9ff7cSGeert Uytterhoeven btrfs_ref_generation_v0(eb, ref0), 140c1c9ff7cSGeert Uytterhoeven btrfs_ref_objectid_v0(eb, ref0), 1415d4f98a2SYan Zheng (unsigned long)btrfs_ref_count_v0(eb, ref0)); 1425d4f98a2SYan Zheng } 1435d4f98a2SYan Zheng #endif 1445d4f98a2SYan Zheng 1458f8ae8e2SStefan Behrens static void print_uuid_item(struct extent_buffer *l, unsigned long offset, 1468f8ae8e2SStefan Behrens u32 item_size) 1478f8ae8e2SStefan Behrens { 1488f8ae8e2SStefan Behrens if (!IS_ALIGNED(item_size, sizeof(u64))) { 149efe120a0SFrank Holton pr_warn("BTRFS: uuid item with illegal size %lu!\n", 1508f8ae8e2SStefan Behrens (unsigned long)item_size); 1518f8ae8e2SStefan Behrens return; 1528f8ae8e2SStefan Behrens } 1538f8ae8e2SStefan Behrens while (item_size) { 1548f8ae8e2SStefan Behrens __le64 subvol_id; 1558f8ae8e2SStefan Behrens 1568f8ae8e2SStefan Behrens read_extent_buffer(l, &subvol_id, offset, sizeof(subvol_id)); 15762e85577SJeff Mahoney pr_info("\t\tsubvol_id %llu\n", 1588f8ae8e2SStefan Behrens (unsigned long long)le64_to_cpu(subvol_id)); 1598f8ae8e2SStefan Behrens item_size -= sizeof(u64); 1608f8ae8e2SStefan Behrens offset += sizeof(u64); 1618f8ae8e2SStefan Behrens } 1628f8ae8e2SStefan Behrens } 1638f8ae8e2SStefan Behrens 1645f39d397SChris Mason void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) 1655de08d7dSChris Mason { 166*0b246afaSJeff Mahoney struct btrfs_fs_info *fs_info = root->fs_info; 1675de08d7dSChris Mason int i; 168068132baSDaniel J Blueman u32 type, nr; 1690783fcfcSChris Mason struct btrfs_item *item; 1703768f368SChris Mason struct btrfs_root_item *ri; 1711d4f6404SChris Mason struct btrfs_dir_item *di; 172293ffd5fSChris Mason struct btrfs_inode_item *ii; 1739078a3e1SChris Mason struct btrfs_block_group_item *bi; 1748c2383c3SChris Mason struct btrfs_file_extent_item *fi; 1755d4f98a2SYan Zheng struct btrfs_extent_data_ref *dref; 1765d4f98a2SYan Zheng struct btrfs_shared_data_ref *sref; 1775d4f98a2SYan Zheng struct btrfs_dev_extent *dev_extent; 1785f39d397SChris Mason struct btrfs_key key; 1795f39d397SChris Mason struct btrfs_key found_key; 1801d4f6404SChris Mason 181068132baSDaniel J Blueman if (!l) 182068132baSDaniel J Blueman return; 183068132baSDaniel J Blueman 184068132baSDaniel J Blueman nr = btrfs_header_nritems(l); 185068132baSDaniel J Blueman 186*0b246afaSJeff Mahoney btrfs_info(fs_info, "leaf %llu total ptrs %d free space %d", 187c1c9ff7cSGeert Uytterhoeven btrfs_header_bytenr(l), nr, btrfs_leaf_free_space(root, l)); 1885de08d7dSChris Mason for (i = 0 ; i < nr ; i++) { 189dd3cc16bSRoss Kirk item = btrfs_item_nr(i); 1905f39d397SChris Mason btrfs_item_key_to_cpu(l, &key, i); 191962a298fSDavid Sterba type = key.type; 19262e85577SJeff Mahoney pr_info("\titem %d key (%llu %u %llu) itemoff %d itemsize %d\n", 193c1c9ff7cSGeert Uytterhoeven i, key.objectid, type, key.offset, 1945f39d397SChris Mason btrfs_item_offset(l, item), btrfs_item_size(l, item)); 19562e2749eSChris Mason switch (type) { 19662e2749eSChris Mason case BTRFS_INODE_ITEM_KEY: 197293ffd5fSChris Mason ii = btrfs_item_ptr(l, i, struct btrfs_inode_item); 19862e85577SJeff Mahoney pr_info("\t\tinode generation %llu size %llu mode %o\n", 199d397712bSChris Mason btrfs_inode_generation(l, ii), 200c1c9ff7cSGeert Uytterhoeven btrfs_inode_size(l, ii), 2015f39d397SChris Mason btrfs_inode_mode(l, ii)); 20262e2749eSChris Mason break; 20362e2749eSChris Mason case BTRFS_DIR_ITEM_KEY: 2041d4f6404SChris Mason di = btrfs_item_ptr(l, i, struct btrfs_dir_item); 2055f39d397SChris Mason btrfs_dir_item_key_to_cpu(l, di, &found_key); 20662e85577SJeff Mahoney pr_info("\t\tdir oid %llu type %u\n", 207c1c9ff7cSGeert Uytterhoeven found_key.objectid, 2085f39d397SChris Mason btrfs_dir_type(l, di)); 20962e2749eSChris Mason break; 21062e2749eSChris Mason case BTRFS_ROOT_ITEM_KEY: 2114beb1b8bSChris Mason ri = btrfs_item_ptr(l, i, struct btrfs_root_item); 21262e85577SJeff Mahoney pr_info("\t\troot data bytenr %llu refs %u\n", 213d397712bSChris Mason btrfs_disk_root_bytenr(l, ri), 2145f39d397SChris Mason btrfs_disk_root_refs(l, ri)); 21562e2749eSChris Mason break; 21662e2749eSChris Mason case BTRFS_EXTENT_ITEM_KEY: 217be2c765dSJosef Bacik case BTRFS_METADATA_ITEM_KEY: 218be2c765dSJosef Bacik print_extent_item(l, i, type); 21962e2749eSChris Mason break; 2205d4f98a2SYan Zheng case BTRFS_TREE_BLOCK_REF_KEY: 22162e85577SJeff Mahoney pr_info("\t\ttree block backref\n"); 2227bb86316SChris Mason break; 2235d4f98a2SYan Zheng case BTRFS_SHARED_BLOCK_REF_KEY: 22462e85577SJeff Mahoney pr_info("\t\tshared block backref\n"); 2255d4f98a2SYan Zheng break; 2265d4f98a2SYan Zheng case BTRFS_EXTENT_DATA_REF_KEY: 2275d4f98a2SYan Zheng dref = btrfs_item_ptr(l, i, 2285d4f98a2SYan Zheng struct btrfs_extent_data_ref); 2295d4f98a2SYan Zheng print_extent_data_ref(l, dref); 2305d4f98a2SYan Zheng break; 2315d4f98a2SYan Zheng case BTRFS_SHARED_DATA_REF_KEY: 2325d4f98a2SYan Zheng sref = btrfs_item_ptr(l, i, 2335d4f98a2SYan Zheng struct btrfs_shared_data_ref); 23462e85577SJeff Mahoney pr_info("\t\tshared data backref count %u\n", 2355d4f98a2SYan Zheng btrfs_shared_data_ref_count(l, sref)); 2365d4f98a2SYan Zheng break; 2378c2383c3SChris Mason case BTRFS_EXTENT_DATA_KEY: 2388c2383c3SChris Mason fi = btrfs_item_ptr(l, i, 2398c2383c3SChris Mason struct btrfs_file_extent_item); 2405f39d397SChris Mason if (btrfs_file_extent_type(l, fi) == 2418c2383c3SChris Mason BTRFS_FILE_EXTENT_INLINE) { 24262e85577SJeff Mahoney pr_info("\t\tinline extent data size %u\n", 243514ac8adSChris Mason btrfs_file_extent_inline_len(l, i, fi)); 2448c2383c3SChris Mason break; 2458c2383c3SChris Mason } 24662e85577SJeff Mahoney pr_info("\t\textent data disk bytenr %llu nr %llu\n", 247d397712bSChris Mason btrfs_file_extent_disk_bytenr(l, fi), 248d397712bSChris Mason btrfs_file_extent_disk_num_bytes(l, fi)); 24962e85577SJeff Mahoney pr_info("\t\textent data offset %llu nr %llu ram %llu\n", 250d397712bSChris Mason btrfs_file_extent_offset(l, fi), 251d397712bSChris Mason btrfs_file_extent_num_bytes(l, fi), 252d397712bSChris Mason btrfs_file_extent_ram_bytes(l, fi)); 2538c2383c3SChris Mason break; 2545d4f98a2SYan Zheng case BTRFS_EXTENT_REF_V0_KEY: 2555d4f98a2SYan Zheng #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 2565d4f98a2SYan Zheng print_extent_ref_v0(l, i); 2575d4f98a2SYan Zheng #else 2585d4f98a2SYan Zheng BUG(); 2595d4f98a2SYan Zheng #endif 260333e8105Sliubo break; 2619078a3e1SChris Mason case BTRFS_BLOCK_GROUP_ITEM_KEY: 2629078a3e1SChris Mason bi = btrfs_item_ptr(l, i, 2639078a3e1SChris Mason struct btrfs_block_group_item); 26462e85577SJeff Mahoney pr_info("\t\tblock group used %llu\n", 265d397712bSChris Mason btrfs_disk_block_group_used(l, bi)); 26662e2749eSChris Mason break; 2670b86a832SChris Mason case BTRFS_CHUNK_ITEM_KEY: 268d397712bSChris Mason print_chunk(l, btrfs_item_ptr(l, i, 269d397712bSChris Mason struct btrfs_chunk)); 2700b86a832SChris Mason break; 2710b86a832SChris Mason case BTRFS_DEV_ITEM_KEY: 2720b86a832SChris Mason print_dev_item(l, btrfs_item_ptr(l, i, 2730b86a832SChris Mason struct btrfs_dev_item)); 2740b86a832SChris Mason break; 2750b86a832SChris Mason case BTRFS_DEV_EXTENT_KEY: 2760b86a832SChris Mason dev_extent = btrfs_item_ptr(l, i, 2770b86a832SChris Mason struct btrfs_dev_extent); 27862e85577SJeff Mahoney pr_info("\t\tdev extent chunk_tree %llu\n\t\tchunk objectid %llu chunk offset %llu length %llu\n", 279e17cade2SChris Mason btrfs_dev_extent_chunk_tree(l, dev_extent), 280e17cade2SChris Mason btrfs_dev_extent_chunk_objectid(l, dev_extent), 281e17cade2SChris Mason btrfs_dev_extent_chunk_offset(l, dev_extent), 282e17cade2SChris Mason btrfs_dev_extent_length(l, dev_extent)); 2830e636027SEric Sandeen break; 284585a3d0dSDavid Sterba case BTRFS_PERSISTENT_ITEM_KEY: 28562e85577SJeff Mahoney pr_info("\t\tpersistent item objectid %llu offset %llu\n", 286585a3d0dSDavid Sterba key.objectid, key.offset); 287585a3d0dSDavid Sterba switch (key.objectid) { 288585a3d0dSDavid Sterba case BTRFS_DEV_STATS_OBJECTID: 28962e85577SJeff Mahoney pr_info("\t\tdevice stats\n"); 290733f4fbbSStefan Behrens break; 291585a3d0dSDavid Sterba default: 29262e85577SJeff Mahoney pr_info("\t\tunknown persistent item\n"); 293585a3d0dSDavid Sterba } 294585a3d0dSDavid Sterba break; 2959f07e1d7SDavid Sterba case BTRFS_TEMPORARY_ITEM_KEY: 29662e85577SJeff Mahoney pr_info("\t\ttemporary item objectid %llu offset %llu\n", 2979f07e1d7SDavid Sterba key.objectid, key.offset); 2989f07e1d7SDavid Sterba switch (key.objectid) { 2999f07e1d7SDavid Sterba case BTRFS_BALANCE_OBJECTID: 30062e85577SJeff Mahoney pr_info("\t\tbalance status\n"); 3019f07e1d7SDavid Sterba break; 3029f07e1d7SDavid Sterba default: 30362e85577SJeff Mahoney pr_info("\t\tunknown temporary item\n"); 3049f07e1d7SDavid Sterba } 3059f07e1d7SDavid Sterba break; 306a2bff640SStefan Behrens case BTRFS_DEV_REPLACE_KEY: 30762e85577SJeff Mahoney pr_info("\t\tdev replace\n"); 308a2bff640SStefan Behrens break; 3098f8ae8e2SStefan Behrens case BTRFS_UUID_KEY_SUBVOL: 3108f8ae8e2SStefan Behrens case BTRFS_UUID_KEY_RECEIVED_SUBVOL: 3118f8ae8e2SStefan Behrens print_uuid_item(l, btrfs_item_ptr_offset(l, i), 3128f8ae8e2SStefan Behrens btrfs_item_size_nr(l, i)); 3138f8ae8e2SStefan Behrens break; 31462e2749eSChris Mason }; 3155de08d7dSChris Mason } 3165de08d7dSChris Mason } 317e20d96d6SChris Mason 3185f39d397SChris Mason void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c) 3195de08d7dSChris Mason { 320*0b246afaSJeff Mahoney struct btrfs_fs_info *fs_info = root->fs_info; 321e17cade2SChris Mason int i; u32 nr; 3225f39d397SChris Mason struct btrfs_key key; 323db94535dSChris Mason int level; 3245de08d7dSChris Mason 3255f39d397SChris Mason if (!c) 3265de08d7dSChris Mason return; 3275f39d397SChris Mason nr = btrfs_header_nritems(c); 328db94535dSChris Mason level = btrfs_header_level(c); 329db94535dSChris Mason if (level == 0) { 3305f39d397SChris Mason btrfs_print_leaf(root, c); 3315de08d7dSChris Mason return; 3325de08d7dSChris Mason } 333*0b246afaSJeff Mahoney btrfs_info(fs_info, 3345d163e0eSJeff Mahoney "node %llu level %d total ptrs %d free spc %u", 335c1c9ff7cSGeert Uytterhoeven btrfs_header_bytenr(c), level, nr, 336*0b246afaSJeff Mahoney (u32)BTRFS_NODEPTRS_PER_BLOCK(fs_info) - nr); 3375de08d7dSChris Mason for (i = 0; i < nr; i++) { 3385f39d397SChris Mason btrfs_node_key_to_cpu(c, &key, i); 33962e85577SJeff Mahoney pr_info("\tkey %d (%llu %u %llu) block %llu\n", 340c1c9ff7cSGeert Uytterhoeven i, key.objectid, key.type, key.offset, 341c1c9ff7cSGeert Uytterhoeven btrfs_node_blockptr(c, i)); 3425de08d7dSChris Mason } 3435de08d7dSChris Mason for (i = 0; i < nr; i++) { 3445f39d397SChris Mason struct extent_buffer *next = read_tree_block(root, 345db94535dSChris Mason btrfs_node_blockptr(c, i), 346ca7a79adSChris Mason btrfs_node_ptr_generation(c, i)); 347a42cbec9SLiu Bo if (IS_ERR(next)) { 348a42cbec9SLiu Bo continue; 349a42cbec9SLiu Bo } else if (!extent_buffer_uptodate(next)) { 350a42cbec9SLiu Bo free_extent_buffer(next); 351a42cbec9SLiu Bo continue; 352a42cbec9SLiu Bo } 353a42cbec9SLiu Bo 3547518a238SChris Mason if (btrfs_is_leaf(next) && 355c271b492SDaniel Cadete level != 1) 3565de08d7dSChris Mason BUG(); 3575f39d397SChris Mason if (btrfs_header_level(next) != 358c271b492SDaniel Cadete level - 1) 3595de08d7dSChris Mason BUG(); 3605f39d397SChris Mason btrfs_print_tree(root, next); 3615f39d397SChris Mason free_extent_buffer(next); 3625de08d7dSChris Mason } 3635de08d7dSChris Mason } 364