From patchwork Fri May 23 13:44:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4232091 X-Patchwork-Delegate: dave@jikos.cz 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 09032BF90B for ; Fri, 23 May 2014 12:44:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 284F920398 for ; Fri, 23 May 2014 12:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4802B20397 for ; Fri, 23 May 2014 12:44:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751178AbaEWMop (ORCPT ); Fri, 23 May 2014 08:44:45 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:61104 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbaEWMoo (ORCPT ); Fri, 23 May 2014 08:44:44 -0400 Received: by mail-we0-f169.google.com with SMTP id u56so4889327wes.14 for ; Fri, 23 May 2014 05:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=5CNaaj4uSJKbmBv1NukuSe15Dq7m9DVQR0wu2xcjG54=; b=mYk1jMrkzBiwWyN4dLw2iEY4OxKt+mUOIgnTdz/OQ69Q9Xo9y6XaCMClMzto2yQn1o YPebZ2T5VMMvGyJDuSP5Id41/lBG2xoIYTeh0/BX81IxzjK7Y+xHtweFSK+D4/JTeeTZ Wx9jhK9SBWPgTJEUtnWAaAQ5srZik53If7dqn8ShU7bwPPkWoBJV4FkbsZtSynNQQLii gKc3YHhsEweDYWdjpPWtUbtadEecikZM1cdG0VAvbS6g9b+A+IR4pABgfCWpsT7qEIwd BaPZLElmbPx91mRriaidJrsjJZY3cQc6LLAuJflUqCsXu1V93cWhcbf3DH/5OYsdWM+y CJfA== X-Received: by 10.194.7.232 with SMTP id m8mr4019098wja.47.1400849083091; Fri, 23 May 2014 05:44:43 -0700 (PDT) Received: from debian-vm3.lan (bl10-252-12.dsl.telepac.pt. [85.243.252.12]) by mx.google.com with ESMTPSA id fq2sm2790234wib.2.2014.05.23.05.44.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 May 2014 05:44:42 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs-progs: debug-tree, add option to dump a single tree Date: Fri, 23 May 2014 14:44:29 +0100 Message-Id: <1400852669-2100-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 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, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Very often while debugging filesystems with many subvolumes and/or snapshots, specially when they are large, I want to see only the content of one of the trees. So this change just adds an option to btrfs-debug-tree to allow to specify the id of the tree we're interesting in dumping to stdout. Example: btrfs-debug-tree -t 257 /dev/sdc Will only dump the tree of the first snapshot or subvolume that was created. Signed-off-by: Filipe David Borba Manana --- btrfs-debug-tree.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c index cb6c106..36e1115 100644 --- a/btrfs-debug-tree.c +++ b/btrfs-debug-tree.c @@ -41,6 +41,8 @@ static int print_usage(void) fprintf(stderr, "\t-u : print info of uuid tree only\n"); fprintf(stderr, "\t-b block_num : print info of the specified block" " only\n"); + fprintf(stderr, + "\t-t tree_id : print only the tree with the given id\n"); fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION); exit(1); } @@ -136,12 +138,13 @@ int main(int ac, char **av) int root_backups = 0; u64 block_only = 0; struct btrfs_root *tree_root_scan; + u64 tree_id = 0; radix_tree_init(); while(1) { int c; - c = getopt(ac, av, "deb:rRu"); + c = getopt(ac, av, "deb:rRut:"); if (c < 0) break; switch(c) { @@ -164,6 +167,9 @@ int main(int ac, char **av) case 'b': block_only = arg_strtou64(optarg); break; + case 't': + tree_id = arg_strtou64(optarg); + break; default: print_usage(); } @@ -208,7 +214,7 @@ int main(int ac, char **av) goto close_root; } - if (!(extent_only || uuid_tree_only)) { + if (!(extent_only || uuid_tree_only || tree_id)) { if (roots_only) { printf("root tree: %llu level %d\n", (unsigned long long)info->tree_root->node->start, @@ -268,6 +274,8 @@ again: 0); if (!extent_buffer_uptodate(buf)) goto next; + if (tree_id && found_key.objectid != tree_id) + goto next; switch(found_key.objectid) { case BTRFS_ROOT_TREE_OBJECTID: