All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] btrfs-progs: skip fs with no seed when build seed/sprout mapping for fi show
@ 2014-11-10  7:55 Gui Hecheng
  0 siblings, 0 replies; only message in thread
From: Gui Hecheng @ 2014-11-10  7:55 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, Gui Hecheng

There is no need to try to build seed/sprout mapping for those btrfs
without seed devices, so just skip such fs.
We could get the total number of devices from the disk super block, if it
equals the number of items in list @fs_devices->devices, then there shouldn't
be any seed devices.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
changlog
	v1->v2: adopt more natural function name:
		no_seed_devices ==> has_seed_devices
---
 cmds-filesystem.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index e4b2785..c55c486 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -750,6 +750,22 @@ static int find_and_copy_seed(struct btrfs_fs_devices *seed,
 	return 1;
 }
 
+static int has_seed_devices(struct btrfs_fs_devices *fs_devices)
+{
+	struct btrfs_device *device;
+	int dev_cnt_total, dev_cnt = 0;
+
+	device = list_first_entry(&fs_devices->devices, struct btrfs_device,
+				  dev_list);
+
+	dev_cnt_total = device->total_devs;
+
+	list_for_each_entry(device, &fs_devices->devices, dev_list)
+		dev_cnt++;
+
+	return dev_cnt_total != dev_cnt;
+}
+
 static int map_seed_devices(struct list_head *all_uuids,
 			    char *search, int *found)
 {
@@ -775,6 +791,10 @@ static int map_seed_devices(struct list_head *all_uuids,
 			*found = 1;
 		}
 
+		/* skip fs without seeds */
+		if (!has_seed_devices(cur_fs))
+			continue;
+
 		/* skip all fs already shown as mounted fs */
 		if (is_seen_fsid(cur_fs->fsid))
 			continue;
@@ -956,8 +976,8 @@ devs_only:
 	}
 
 	/*
-	 * scan_for_btrfs() don't build seed/sprout mapping,
-	 * do mapping build for each scanned fs here
+	 * The seed/sprout mapping are not detected yet,
+	 * do mapping build for all umounted fs
 	 */
 	ret = map_seed_devices(&all_uuids, search, &found);
 	if (ret) {
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-11-10  7:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-10  7:55 [PATCH v2] btrfs-progs: skip fs with no seed when build seed/sprout mapping for fi show Gui Hecheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.