btrfs-progs: Add better search generation judgment for btrfs-find-root
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Fri, 16 Jan 2015 07:32:35 +0000 (15:32 +0800)
committerDavid Sterba <dsterba@suse.cz>
Wed, 11 Feb 2015 17:34:06 +0000 (18:34 +0100)
commit8e3eb7a6e8bdea3a16093b7fab5c76961b826686
treec69e2b845a2496199f540bc96ddad9e1c875ff86
parent70701d131a2ec8572b801ede897138f3002fd11c
btrfs-progs: Add better search generation judgment for btrfs-find-root

Before the patch, btrfs-find-root will only consider it find a good root
if its generation matches generation in superblock and its level is
currently found highest level.

But that's not correct in 2 ways.
1) Root with decreased level
Since tree level can decrease, like subvolume/file deletion.
Which will make the new root have higher generation but lower level.

2) Root not updated in latest transaction.
If there is some root not updated in latest transaction, its generation
will be smaller than the one in superblock, and btrfs-find-root will not
find it.

This patch will use different generation for different tree to search,
solving the above problems.

Currently, it only supports generation/level in superblock. Using tree
root level/generation if possible will be introduced later.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-find-root.c