[Btrfs-devel] I'm kind of confused...

Josef Bacik jbacik at redhat.com
Fri Aug 17 12:08:18 PDT 2007


On Thu, Aug 16, 2007 at 07:56:33PM -0400, Chris Mason wrote:
> On Fri, 17 Aug 2007 06:24:52 +0800
> > >
> > both search_key's flags and offset are set to the maximum value and
> > it's intended no item has such large flags and offset. If there are
> > items that have the objectid search for,  the item at [path->slots[0]
> > - 1] should be last one (the one has largest offset) .
> > (btrfs_search_slot use binary search)
> 
> That's right.  It may make more sense if you use debug-tree to print
> out the metadata, that way you can see the keys and where they are.
> The print-tree.c code in btrfs-progs should have enough examples to
> pull the name out as well.
> 

Ok I understand how this is laid out and such, now I just need a little help on
how to do this right.  So this is what I see from the debug_tree output

root tree
leaf 6 ptrs 10 free space 2832 generation 33 owner 1
...SNIP...
        item 5 key (4 10000000 8178316903378239287) itemoff 3494 itemsize 38
                dir index 6 flags 0 type 2
                name josefs_subvol
...SNIP...
        item 9 key (6 20000000 1) itemoff 3092 itemsize 165
                root data blocknr 10 dirid 5 refs 1
                drop key 0 0 0 level 0

So the only way I see that the dir_item is associated with the root_item is that
the dir_item->location.objectid matches the objectid for my corresponding
root_item.  However the item key the leave has is

(4 10000000 8178316903378239287)

so I would have to search through all of the items in the leaf, check the type
of object it was, if its a DIR_ITEM pull it out and look at the key's objectid
and match it to the root item's objectid.  This seems like a bad idea to me as
far as performance is concerned, is there a better way to do this that I haven't
found yet?  Or is there no way to associate these two objects easily and I have
something to add to my TODO list?  Thanks much,

Josef



More information about the Btrfs-devel mailing list