From patchwork Thu Oct 30 02:44:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 5193171 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6E0AC11AC for ; Thu, 30 Oct 2014 02:46:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF2C820219 for ; Thu, 30 Oct 2014 02:46:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B486A2025B for ; Thu, 30 Oct 2014 02:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756680AbaJ3CqP (ORCPT ); Wed, 29 Oct 2014 22:46:15 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:51131 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756515AbaJ3CqO (ORCPT ); Wed, 29 Oct 2014 22:46:14 -0400 X-IronPort-AV: E=Sophos;i="5.04,815,1406563200"; d="scan'208";a="42577900" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Oct 2014 10:43:03 +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 s9U2k4Bw032459 for ; Thu, 30 Oct 2014 10:46:04 +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; Thu, 30 Oct 2014 10:46:23 +0800 From: Gui Hecheng To: CC: Gui Hecheng Subject: [PATCH 2/2] btrfs-progs: skip mounted fs when deal with umounted ones for fi show Date: Thu, 30 Oct 2014 10:44:50 +0800 Message-ID: <1414637090-4476-2-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1414637090-4476-1-git-send-email-guihc.fnst@cn.fujitsu.com> References: <1414637090-4476-1-git-send-email-guihc.fnst@cn.fujitsu.com> 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.5 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 Stalling problems may happen when exec balance & fi show cmds concurrently. With the following commit: commit 915902c500 btrfs-progs: fix device missing of btrfs fi show with seed devices The fi show cmd will bother the mounted fs when only umounted fs should be handled after @btrfs_can_kernel() has finished showing all mounted ones. We could skip the mounted fs after @btrfs_can_kernel() is done, then tasks keeps going on mounted fs while fi show continues on umounted ones separately. Reported-by: Petr Janecek Signed-off-by: Gui Hecheng --- cmds-filesystem.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 6437e57..67fe52b 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -53,6 +53,15 @@ struct seen_fsid { static struct seen_fsid *seen_fsid_hash[SEEN_FSID_HASH_SIZE] = {NULL,}; +static int is_seen_fsid(u8 *fsid) +{ + u8 hash = fsid[0]; + int slot = hash % SEEN_FSID_HASH_SIZE; + struct seen_fsid *seen = seen_fsid_hash[slot]; + + return seen ? 1 : 0; +} + static int add_seen_fsid(u8 *fsid) { u8 hash = fsid[0]; @@ -763,6 +772,10 @@ static int search_umounted_fs_uuids(struct list_head *all_uuids, ret = 1; } + /* skip all fs already shown as mounted fs */ + if (is_seen_fsid(cur_fs->fsid)) + continue; + fs_copy = malloc(sizeof(*fs_copy)); if (!fs_copy) { ret = -ENOMEM;