aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/print-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:14:19 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit5f39d397dfbe140a14edecd4e73c34ce23c4f9ee (patch)
tree280561e4b68d573590557dd27df656869eed8023 /fs/btrfs/print-tree.c
parent50b78c24d594e6985f36a9a8d8e2fb74e1664e90 (diff)
Btrfs: Create extent_buffer interface for large blocksizes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/print-tree.c')
-rw-r--r--fs/btrfs/print-tree.c96
1 files changed, 45 insertions, 51 deletions
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index bafa78603bd2..a825ce078a54 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -20,10 +20,10 @@
20#include "disk-io.h" 20#include "disk-io.h"
21#include "print-tree.h" 21#include "print-tree.h"
22 22
23void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l) 23void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
24{ 24{
25 int i; 25 int i;
26 u32 nr = btrfs_header_nritems(&l->header); 26 u32 nr = btrfs_header_nritems(l);
27 struct btrfs_item *item; 27 struct btrfs_item *item;
28 struct btrfs_extent_item *ei; 28 struct btrfs_extent_item *ei;
29 struct btrfs_root_item *ri; 29 struct btrfs_root_item *ri;
@@ -31,119 +31,113 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
31 struct btrfs_inode_item *ii; 31 struct btrfs_inode_item *ii;
32 struct btrfs_block_group_item *bi; 32 struct btrfs_block_group_item *bi;
33 struct btrfs_file_extent_item *fi; 33 struct btrfs_file_extent_item *fi;
34 struct btrfs_key key;
35 struct btrfs_key found_key;
34 u32 type; 36 u32 type;
35 37
36 printk("leaf %llu total ptrs %d free space %d\n", 38 printk("leaf %llu total ptrs %d free space %d\n",
37 (unsigned long long)btrfs_header_blocknr(&l->header), nr, 39 (unsigned long long)btrfs_header_blocknr(l), nr,
38 btrfs_leaf_free_space(root, l)); 40 btrfs_leaf_free_space(root, l));
39 for (i = 0 ; i < nr ; i++) { 41 for (i = 0 ; i < nr ; i++) {
40 item = l->items + i; 42 item = btrfs_item_nr(l, i);
41 type = btrfs_disk_key_type(&item->key); 43 btrfs_item_key_to_cpu(l, &key, i);
44 type = btrfs_key_type(&key);
42 printk("\titem %d key (%llu %x %llu) itemoff %d itemsize %d\n", 45 printk("\titem %d key (%llu %x %llu) itemoff %d itemsize %d\n",
43 i, 46 i,
44 (unsigned long long)btrfs_disk_key_objectid(&item->key), 47 (unsigned long long)key.objectid, type,
45 btrfs_disk_key_flags(&item->key), 48 (unsigned long long)key.offset,
46 (unsigned long long)btrfs_disk_key_offset(&item->key), 49 btrfs_item_offset(l, item), btrfs_item_size(l, item));
47 btrfs_item_offset(item),
48 btrfs_item_size(item));
49 switch (type) { 50 switch (type) {
50 case BTRFS_INODE_ITEM_KEY: 51 case BTRFS_INODE_ITEM_KEY:
51 ii = btrfs_item_ptr(l, i, struct btrfs_inode_item); 52 ii = btrfs_item_ptr(l, i, struct btrfs_inode_item);
52 printk("\t\tinode generation %llu size %llu mode %o\n", 53 printk("\t\tinode generation %llu size %llu mode %o\n",
53 (unsigned long long)btrfs_inode_generation(ii), 54 (unsigned long long)btrfs_inode_generation(l, ii),
54 (unsigned long long)btrfs_inode_size(ii), 55 (unsigned long long)btrfs_inode_size(l, ii),
55 btrfs_inode_mode(ii)); 56 btrfs_inode_mode(l, ii));
56 break; 57 break;
57 case BTRFS_DIR_ITEM_KEY: 58 case BTRFS_DIR_ITEM_KEY:
58 di = btrfs_item_ptr(l, i, struct btrfs_dir_item); 59 di = btrfs_item_ptr(l, i, struct btrfs_dir_item);
60 btrfs_dir_item_key_to_cpu(l, di, &found_key);
59 printk("\t\tdir oid %llu flags %u type %u\n", 61 printk("\t\tdir oid %llu flags %u type %u\n",
60 (unsigned long long)btrfs_disk_key_objectid( 62 (unsigned long long)found_key.objectid,
61 &di->location), 63 btrfs_dir_flags(l, di),
62 btrfs_dir_flags(di), 64 btrfs_dir_type(l, di));
63 btrfs_dir_type(di));
64 printk("\t\tname %.*s\n",
65 btrfs_dir_name_len(di),(char *)(di + 1));
66 break; 65 break;
67 case BTRFS_ROOT_ITEM_KEY: 66 case BTRFS_ROOT_ITEM_KEY:
68 ri = btrfs_item_ptr(l, i, struct btrfs_root_item); 67 ri = btrfs_item_ptr(l, i, struct btrfs_root_item);
69 printk("\t\troot data blocknr %llu refs %u\n", 68 printk("\t\troot data blocknr %llu refs %u\n",
70 (unsigned long long)btrfs_root_blocknr(ri), 69 (unsigned long long)btrfs_disk_root_blocknr(l, ri),
71 btrfs_root_refs(ri)); 70 btrfs_disk_root_refs(l, ri));
72 break; 71 break;
73 case BTRFS_EXTENT_ITEM_KEY: 72 case BTRFS_EXTENT_ITEM_KEY:
74 ei = btrfs_item_ptr(l, i, struct btrfs_extent_item); 73 ei = btrfs_item_ptr(l, i, struct btrfs_extent_item);
75 printk("\t\textent data refs %u\n", 74 printk("\t\textent data refs %u\n",
76 btrfs_extent_refs(ei)); 75 btrfs_extent_refs(l, ei));
77 break; 76 break;
78 77
79 case BTRFS_EXTENT_DATA_KEY: 78 case BTRFS_EXTENT_DATA_KEY:
80 fi = btrfs_item_ptr(l, i, 79 fi = btrfs_item_ptr(l, i,
81 struct btrfs_file_extent_item); 80 struct btrfs_file_extent_item);
82 if (btrfs_file_extent_type(fi) == 81 if (btrfs_file_extent_type(l, fi) ==
83 BTRFS_FILE_EXTENT_INLINE) { 82 BTRFS_FILE_EXTENT_INLINE) {
84 printk("\t\tinline extent data size %u\n", 83 printk("\t\tinline extent data size %u\n",
85 btrfs_file_extent_inline_len(l->items + i)); 84 btrfs_file_extent_inline_len(l, item));
86 break; 85 break;
87 } 86 }
88 printk("\t\textent data disk block %llu nr %llu\n", 87 printk("\t\textent data disk block %llu nr %llu\n",
89 (unsigned long long)btrfs_file_extent_disk_blocknr(fi), 88 (unsigned long long)btrfs_file_extent_disk_blocknr(l, fi),
90 (unsigned long long)btrfs_file_extent_disk_num_blocks(fi)); 89 (unsigned long long)btrfs_file_extent_disk_num_blocks(l, fi));
91 printk("\t\textent data offset %llu nr %llu\n", 90 printk("\t\textent data offset %llu nr %llu\n",
92 (unsigned long long)btrfs_file_extent_offset(fi), 91 (unsigned long long)btrfs_file_extent_offset(l, fi),
93 (unsigned long long)btrfs_file_extent_num_blocks(fi)); 92 (unsigned long long)btrfs_file_extent_num_blocks(l, fi));
94 break; 93 break;
95 case BTRFS_BLOCK_GROUP_ITEM_KEY: 94 case BTRFS_BLOCK_GROUP_ITEM_KEY:
96 bi = btrfs_item_ptr(l, i, 95 bi = btrfs_item_ptr(l, i,
97 struct btrfs_block_group_item); 96 struct btrfs_block_group_item);
98 printk("\t\tblock group used %llu\n", 97 printk("\t\tblock group used %llu\n",
99 (unsigned long long)btrfs_block_group_used(bi)); 98 (unsigned long long)btrfs_disk_block_group_used(l, bi));
100 break;
101 case BTRFS_STRING_ITEM_KEY:
102 printk("\t\titem data %.*s\n", btrfs_item_size(item),
103 btrfs_leaf_data(l) + btrfs_item_offset(item));
104 break; 99 break;
105 }; 100 };
106 } 101 }
107} 102}
108 103
109void btrfs_print_tree(struct btrfs_root *root, struct buffer_head *t) 104void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
110{ 105{
111 int i; 106 int i;
112 u32 nr; 107 u32 nr;
113 struct btrfs_node *c; 108 struct btrfs_key key;
114 109
115 if (!t) 110 if (!c)
116 return; 111 return;
117 c = btrfs_buffer_node(t); 112 nr = btrfs_header_nritems(c);
118 nr = btrfs_header_nritems(&c->header);
119 if (btrfs_is_leaf(c)) { 113 if (btrfs_is_leaf(c)) {
120 btrfs_print_leaf(root, (struct btrfs_leaf *)c); 114 btrfs_print_leaf(root, c);
121 return; 115 return;
122 } 116 }
123 printk("node %llu level %d total ptrs %d free spc %u\n", 117 printk("node %llu level %d total ptrs %d free spc %u\n",
124 (unsigned long long)btrfs_header_blocknr(&c->header), 118 (unsigned long long)btrfs_header_blocknr(c),
125 btrfs_header_level(&c->header), nr, 119 btrfs_header_level(c), nr,
126 (u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr); 120 (u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr);
127 for (i = 0; i < nr; i++) { 121 for (i = 0; i < nr; i++) {
122 btrfs_node_key_to_cpu(c, &key, i);
128 printk("\tkey %d (%llu %u %llu) block %llu\n", 123 printk("\tkey %d (%llu %u %llu) block %llu\n",
129 i, 124 i,
130 (unsigned long long)c->ptrs[i].key.objectid, 125 (unsigned long long)key.objectid,
131 c->ptrs[i].key.flags, 126 key.type,
132 (unsigned long long)c->ptrs[i].key.offset, 127 (unsigned long long)key.offset,
133 (unsigned long long)btrfs_node_blockptr(c, i)); 128 (unsigned long long)btrfs_node_blockptr(c, i));
134 } 129 }
135 for (i = 0; i < nr; i++) { 130 for (i = 0; i < nr; i++) {
136 struct buffer_head *next_buf = read_tree_block(root, 131 struct extent_buffer *next = read_tree_block(root,
137 btrfs_node_blockptr(c, i)); 132 btrfs_node_blockptr(c, i));
138 struct btrfs_node *next = btrfs_buffer_node(next_buf);
139 if (btrfs_is_leaf(next) && 133 if (btrfs_is_leaf(next) &&
140 btrfs_header_level(&c->header) != 1) 134 btrfs_header_level(c) != 1)
141 BUG(); 135 BUG();
142 if (btrfs_header_level(&next->header) != 136 if (btrfs_header_level(next) !=
143 btrfs_header_level(&c->header) - 1) 137 btrfs_header_level(c) - 1)
144 BUG(); 138 BUG();
145 btrfs_print_tree(root, next_buf); 139 btrfs_print_tree(root, next);
146 btrfs_block_release(root, next_buf); 140 free_extent_buffer(next);
147 } 141 }
148} 142}
149 143