aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/print-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-12 12:01:18 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-12 12:01:18 -0400
commit7518a238ea0152dc849d1ed76d3cae8b44e12f46 (patch)
tree97e5c285f10bdb2576046e7bb15d239471815c28 /fs/btrfs/print-tree.c
parent83e15a28e046dbb4534dd263d1d3dc867a8994a2 (diff)
Btrfs: get/set for struct header fields
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/print-tree.c')
-rw-r--r--fs/btrfs/print-tree.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index e32a959dd3e5..7df16b1e4733 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -8,11 +8,11 @@
8void print_leaf(struct leaf *l) 8void print_leaf(struct leaf *l)
9{ 9{
10 int i; 10 int i;
11 int nr = l->header.nritems; 11 u32 nr = btrfs_header_nritems(&l->header);
12 struct item *item; 12 struct item *item;
13 struct extent_item *ei; 13 struct extent_item *ei;
14 printf("leaf %Lu total ptrs %d free space %d\n", l->header.blocknr, nr, 14 printf("leaf %Lu total ptrs %d free space %d\n",
15 leaf_free_space(l)); 15 btrfs_header_blocknr(&l->header), nr, leaf_free_space(l));
16 fflush(stdout); 16 fflush(stdout);
17 for (i = 0 ; i < nr ; i++) { 17 for (i = 0 ; i < nr ; i++) {
18 item = l->items + i; 18 item = l->items + i;
@@ -32,22 +32,20 @@ void print_leaf(struct leaf *l)
32void print_tree(struct ctree_root *root, struct tree_buffer *t) 32void print_tree(struct ctree_root *root, struct tree_buffer *t)
33{ 33{
34 int i; 34 int i;
35 int nr; 35 u32 nr;
36 struct node *c; 36 struct node *c;
37 37
38 if (!t) 38 if (!t)
39 return; 39 return;
40 c = &t->node; 40 c = &t->node;
41 nr = c->header.nritems; 41 nr = btrfs_header_nritems(&c->header);
42 if (c->header.blocknr != t->blocknr) 42 if (btrfs_is_leaf(c)) {
43 BUG();
44 if (is_leaf(c->header.flags)) {
45 print_leaf((struct leaf *)c); 43 print_leaf((struct leaf *)c);
46 return; 44 return;
47 } 45 }
48 printf("node %Lu level %d total ptrs %d free spc %u\n", t->blocknr, 46 printf("node %Lu level %d total ptrs %d free spc %u\n", t->blocknr,
49 node_level(c->header.flags), c->header.nritems, 47 btrfs_header_level(&c->header), nr,
50 (u32)NODEPTRS_PER_BLOCK - c->header.nritems); 48 (u32)NODEPTRS_PER_BLOCK - nr);
51 fflush(stdout); 49 fflush(stdout);
52 for (i = 0; i < nr; i++) { 50 for (i = 0; i < nr; i++) {
53 printf("\tkey %d (%Lu %u %Lu) block %Lu\n", 51 printf("\tkey %d (%Lu %u %Lu) block %Lu\n",
@@ -60,11 +58,11 @@ void print_tree(struct ctree_root *root, struct tree_buffer *t)
60 struct tree_buffer *next_buf = read_tree_block(root, 58 struct tree_buffer *next_buf = read_tree_block(root,
61 c->blockptrs[i]); 59 c->blockptrs[i]);
62 struct node *next = &next_buf->node; 60 struct node *next = &next_buf->node;
63 if (is_leaf(next->header.flags) && 61 if (btrfs_is_leaf(next) &&
64 node_level(c->header.flags) != 1) 62 btrfs_header_level(&c->header) != 1)
65 BUG(); 63 BUG();
66 if (node_level(next->header.flags) != 64 if (btrfs_header_level(&next->header) !=
67 node_level(c->header.flags) - 1) 65 btrfs_header_level(&c->header) - 1)
68 BUG(); 66 BUG();
69 print_tree(root, next_buf); 67 print_tree(root, next_buf);
70 tree_block_release(root, next_buf); 68 tree_block_release(root, next_buf);