From 2513077f2f830b4bc83d528bfb6979eb461918bd Mon Sep 17 00:00:00 2001 From: Gui Hecheng Date: Mon, 6 Oct 2014 18:16:46 +0800 Subject: 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 Signed-off-by: David Sterba --- volumes.c | 1 + 1 file changed, 1 insertion(+) (limited to 'volumes.c') diff --git a/volumes.c b/volumes.c index b47bce6b..5b007fc8 100644 --- a/volumes.c +++ b/volumes.c @@ -116,6 +116,7 @@ static int device_list_add(const char *path, } device->fd = -1; device->devid = devid; + device->generation = found_transid; memcpy(device->uuid, disk_super->dev_item.uuid, BTRFS_UUID_SIZE); device->name = kstrdup(path, GFP_NOFS); -- cgit v1.2.3