From patchwork Tue Nov 11 06:39:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 5270871 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 194CB9F387 for ; Tue, 11 Nov 2014 06:41:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E38D20127 for ; Tue, 11 Nov 2014 06:41:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DF82200EC for ; Tue, 11 Nov 2014 06:41:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751587AbaKKGlH (ORCPT ); Tue, 11 Nov 2014 01:41:07 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:21810 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751334AbaKKGlF (ORCPT ); Tue, 11 Nov 2014 01:41:05 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="43184457" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Nov 2014 14:37:52 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sAB6epHb006617; Tue, 11 Nov 2014 14:40:51 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 11 Nov 2014 14:41:11 +0800 From: Gui Hecheng To: CC: , Gui Hecheng Subject: [PATCH v3] btrfs-progs: skip fs with no seed when build seed/sprout mapping for fi show Date: Tue, 11 Nov 2014 14:39:14 +0800 Message-ID: <1415687954-12968-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- changlog v1->v2: adopt more natural function name: no_seed_devices ==> has_seed_devices v2->v3: skip such fs after copied, otherwise such fs won't be shown --- cmds-filesystem.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index e4b2785..97efdee 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) { @@ -799,6 +815,11 @@ static int map_seed_devices(struct list_head *all_uuids, struct btrfs_device, dev_list); if (!device) continue; + + /* skip fs without seeds */ + if (!has_seed_devices(cur_fs)) + continue; + /* * open_ctree_* detects seed/sprout mapping */ @@ -956,8 +977,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) {