linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Subject: [PATCH] btrfs-progs: skip fs with no seed when build seed/sprout mapping for fi show
Date: Fri, 7 Nov 2014 10:07:41 +0800	[thread overview]
Message-ID: <1415326063-8838-1-git-send-email-guihc.fnst@cn.fujitsu.com> (raw)

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>
---
 cmds-filesystem.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 67fe52b..0d49cd1 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -795,6 +795,22 @@ out:
 	return ret;
 }
 
+static int no_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)
 {
 	struct btrfs_fs_devices *cur_fs, *cur_seed;
@@ -812,6 +828,11 @@ static int map_seed_devices(struct list_head *all_uuids)
 						struct btrfs_device, dev_list);
 		if (!device)
 			continue;
+
+		/* skip fs without seeds */
+		if (no_seed_devices(cur_fs))
+			continue;
+
 		/*
 		 * open_ctree_* detects seed/sprout mapping
 		 */
@@ -976,8 +997,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);
 	if (ret) {
-- 
1.8.1.4


             reply	other threads:[~2014-11-07  2:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07  2:07 Gui Hecheng [this message]
2014-11-07  2:07 ` [PATCH 1/2] btrfs-progs: remove BUG_ON on num of devices for btrfs fi show Gui Hecheng
2014-11-07  2:07 ` [PATCH 2/2] btrfs-progs: fix wrong num_devices for btrfs fi show with seed devices Gui Hecheng
2014-11-07 18:16   ` David Sterba
2014-11-08  1:03     ` anand jain
2014-11-08 19:47     ` Mike Fleetwood
2014-11-10  7:53       ` Gui Hecheng
2014-11-07 17:41 ` [PATCH] btrfs-progs: skip fs with no seed when build seed/sprout mapping for fi show David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415326063-8838-1-git-send-email-guihc.fnst@cn.fujitsu.com \
    --to=guihc.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).