From patchwork Mon Jan 19 06:45:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5654921 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 69A9B9F444 for ; Mon, 19 Jan 2015 06:49:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D25B2028D for ; Mon, 19 Jan 2015 06:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B83F0202B8 for ; Mon, 19 Jan 2015 06:49:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751652AbbASGsj (ORCPT ); Mon, 19 Jan 2015 01:48:39 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:52325 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751520AbbASGrY (ORCPT ); Mon, 19 Jan 2015 01:47:24 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56253746" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Jan 2015 14:43:56 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t0J6kkpg022588 for ; Mon, 19 Jan 2015 14:46:46 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 19 Jan 2015 14:47:27 +0800 From: Qu Wenruo To: Subject: [PATCH v2 09/10] btrfs-progs: Add new option for btrfs-find-root to search through all the metadata extents. Date: Mon, 19 Jan 2015 14:45:11 +0800 Message-ID: <1421649912-14539-10-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421649912-14539-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1421649912-14539-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Add option '-a' for btrfs-find-root to iterate all the metadata extents even the root is already found. Signed-off-by: Qu Wenruo --- Documentation/btrfs-find-root.txt | 2 ++ btrfs-find-root.c | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Documentation/btrfs-find-root.txt b/Documentation/btrfs-find-root.txt index c934b4c..e04cd3e 100644 --- a/Documentation/btrfs-find-root.txt +++ b/Documentation/btrfs-find-root.txt @@ -16,6 +16,8 @@ root tree's objectid, generation, level. OPTIONS ------- +-a:: +Search through all the metadata extents, even the root is already found. -g :: Filter root tree by it's original transaction id, tree root's generation in default. -o :: diff --git a/btrfs-find-root.c b/btrfs-find-root.c index 31fe0ae..1da5513 100644 --- a/btrfs-find-root.c +++ b/btrfs-find-root.c @@ -39,7 +39,7 @@ static void usage(void) { - fprintf(stderr, "Usage: find-roots [-o search_objectid] " + fprintf(stderr, "Usage: find-roots [-a] [-o search_objectid] " "[ -g search_generation ] [ -l search_level ] \n"); } @@ -152,20 +152,23 @@ int main(int argc, char **argv) filter.objectid = BTRFS_ROOT_TREE_OBJECTID; filter.match_gen = (u64)-1; filter.match_level = (u8)-1; - while ((opt = getopt(argc, argv, "l:o:g:")) != -1) { + while ((opt = getopt(argc, argv, "al:o:g:")) != -1) { switch(opt) { - case 'o': - filter.objectid = arg_strtou64(optarg); - break; - case 'g': - filter.generation = arg_strtou64(optarg); - break; - case 'l': - filter.level = arg_strtou64(optarg); - break; - default: - usage(); - exit(1); + case 'a': + filter.search_all = 1; + break; + case 'o': + filter.objectid = arg_strtou64(optarg); + break; + case 'g': + filter.generation = arg_strtou64(optarg); + break; + case 'l': + filter.level = arg_strtou64(optarg); + break; + default: + usage(); + exit(1); } }