btrfs-progs: fix device missing of btrfs fi show with seed devices
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Mon, 6 Oct 2014 10:16:46 +0000 (18:16 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 10 Oct 2014 08:52:41 +0000 (10:52 +0200)
commit2513077f2f830b4bc83d528bfb6979eb461918bd
tree3a84f559b63262532814af5afd4c80ec74844fea
parentd601190a7df193ecf37a445fbb5a9a0999f28b21
btrfs-progs: fix device missing of btrfs fi show with seed devices

*Note*
this handles the problem under umounted state, the similar problem
under mounted state is already fixed by Anand.

Steps to reproduce:
        # mkfs.btrfs -f /dev/sda1
        # btrfstune -S 1 /dev/sda1
        # mount /dev/sda1 /mnt
        # btrfs dev add /dev/sda2 /mnt
        # umount /mnt                   <== (umounted)
        # btrfs fi show /dev/sda2
result:
        Label: none  uuid: XXXXXXXXXXXXXXXXXX
        Total devices 2 FS bytes used 368.00KiB
        devid    2 size 9.31GiB used 1.25GiB path /dev/sda2
        *** Some devices missing
        Btrfs v3.16-67-g69f54ea-dirty

It is because @btrfs_scan_lblkid() won't establish mappinig
between the seed and sprout devices. So seeding devices are missing.
We could use @open_ctree_* to detect all seed/sprout mappings
for each fs scanned after @btrfs_scan_lblkid().

sth worthes mention:
o If there are multi-level of seeds, all devices in them will be shown
  in the ascending order of @devid
o If device replace is execed on a sprout fs with a device in a seed fs,
  the replaced device still exist in the seed fs together with
  the replacing device in the sprout fs, so we only keep the latest device
  with the newest generation

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-filesystem.c
volumes.c
volumes.h