linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How btrfs-find-root knows that the block is actually a root?
@ 2014-12-22 14:57 Alex Lyakas
  2014-12-23  5:27 ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Lyakas @ 2014-12-22 14:57 UTC (permalink / raw)
  To: linux-btrfs

Greetings,

I am looking at the code of search_iobuf() in
btrfs-find-root.c.(3.17.3)  I see that we probe nodesize blocks one by
one, and for each block we check:
- its owner is what we are looking for
- its header->bytenr is what we are looking at currently
- its level is not too small
- it has valid checksum
- it has the desired generation

If all those conditions are true, we declare this block as a root and
end the program.

How do we actually know that it's a root and not a leaf or an
intermediate node? What if we are searching for a root of the root
tree, which has one node and two leafs (all have the same highest
transid), and one of the leafs has "logical" lower than the actual
root, i.e., it comes first in our scan. Then we will declare this leaf
as a root, won't we? Or somehow the root always has the lowest
"logical"?

Also, I am confused by this line:
level = h_level;
This means that if we encounter a block that "seems good", we will
skip all other blocks that have lower level. Is this intended?

Thanks,
Alex.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-24  0:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-22 14:57 How btrfs-find-root knows that the block is actually a root? Alex Lyakas
2014-12-23  5:27 ` Qu Wenruo
2014-12-23 10:08   ` Alex Lyakas
2014-12-24  0:41     ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).