From patchwork Mon Nov 14 18:43:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9428235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5D0F60755 for ; Mon, 14 Nov 2016 18:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B708C28A92 for ; Mon, 14 Nov 2016 18:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABA7728A66; Mon, 14 Nov 2016 18:43:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5610C28ABA for ; Mon, 14 Nov 2016 18:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933571AbcKNSnh (ORCPT ); Mon, 14 Nov 2016 13:43:37 -0500 Received: from mail-pg0-f45.google.com ([74.125.83.45]:33391 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753292AbcKNSnd (ORCPT ); Mon, 14 Nov 2016 13:43:33 -0500 Received: by mail-pg0-f45.google.com with SMTP id 3so56981347pgd.0 for ; Mon, 14 Nov 2016 10:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=l6UzP3ZjvIJw1qlKx4A2hu4JEdXcCiAP/4ekDqEXiVY=; b=aDGbgrPi6ePjKeZZUkiQvyaWJaPDZOxE0/UCXYb+Ctr1OSXiiED40VOZLvVcYrZ7Sl Ojpd2zLHT3/xFXTNC85WaQIfWOhmrtRtgO/QhkMkK+BGBtLp21k1SoNg5Ssy/YG/Eb12 9DCZCXncG0ZP7iu1hBenAzWKsGzZbbqJUQbdU6+WcARXzLeHEiYe7d9Fz+YcKCWcWcHN q+QLEMzH0ejSVK6bD37e1cV6G68XGV97eiqxSwxO758CbAv+vRwzgCi5znf/MzE3+p0M PWDtp7Wh7xN3cNFKft9kRiBIFa0bgxOpLrm9gLAcCfIeDccN4Sjnp+MPhz6y27ZMM2FE 0H9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=l6UzP3ZjvIJw1qlKx4A2hu4JEdXcCiAP/4ekDqEXiVY=; b=jjDgJoJvb0e3zuZcpk4axCLIiQeyHzhX5h2tvUqjCUxnkdrzN95WaumJNYXndwNTCc 0k8XNsxs1WvVTLzdVCnkvimZrGCPJy2vcjUpz08Vx9zDkSEoxNsQ9mdzO79qUVekuvds KT7COMAe5SWomZcwQ2VqD00K+Wy+v5PuOPH589ns6eAW6kTsoJ6mcW30UxUysl0+fPLd qR9z/Pb9TXFL7aiubUSq14ypAVOZqqBNeAsefvjqiVnucaO5+MPGmuX6kkug7GQaZTHq +d8qyxibtdhdRPybsN7uqegxbl1jgtoz7O/MKHdOp9rwjDWDDQCdY77yD64YlQClGbhK ZB1w== X-Gm-Message-State: ABUngveQELN3DmtCCOz0iSp7UXtc17m56yGGeEOrSR8jQN8XGSEijn0R+ulVn+uda55WuPx8 X-Received: by 10.98.26.88 with SMTP id a85mr38525726pfa.57.1479149013014; Mon, 14 Nov 2016 10:43:33 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:200::a:38b9]) by smtp.gmail.com with ESMTPSA id v76sm15488481pfk.77.2016.11.14.10.43.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 10:43:32 -0800 (PST) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH v2 2/6] btrfs-progs: format FREE_SPACE_TREE{, _VALID} nicely in dump-super Date: Mon, 14 Nov 2016 10:43:19 -0800 Message-Id: <86cfb5c7a06eb6fb488e4c615cd8dfbf2fa4180e.1479148594.git.osandov@fb.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Signed-off-by: Omar Sandoval --- cmds-inspect-dump-super.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmds-inspect-dump-super.c b/cmds-inspect-dump-super.c index d9f7bfb..ba0d708 100644 --- a/cmds-inspect-dump-super.c +++ b/cmds-inspect-dump-super.c @@ -197,6 +197,16 @@ struct readable_flag_entry { char *output; }; +#define DEF_COMPAT_RO_FLAG_ENTRY(bit_name) \ + {BTRFS_FEATURE_COMPAT_RO_##bit_name, #bit_name} + +static struct readable_flag_entry compat_ro_flags_array[] = { + DEF_COMPAT_RO_FLAG_ENTRY(FREE_SPACE_TREE), + DEF_COMPAT_RO_FLAG_ENTRY(FREE_SPACE_TREE_VALID), +}; +static const int compat_ro_flags_num = sizeof(compat_ro_flags_array) / + sizeof(struct readable_flag_entry); + #define DEF_INCOMPAT_FLAG_ENTRY(bit_name) \ {BTRFS_FEATURE_INCOMPAT_##bit_name, #bit_name} @@ -268,6 +278,19 @@ static void __print_readable_flag(u64 flag, struct readable_flag_entry *array, printf(")\n"); } +static void print_readable_compat_ro_flag(u64 flag) +{ + /* + * We know about the FREE_SPACE_TREE{,_VALID} bits, but we don't + * actually support them yet. + */ + return __print_readable_flag(flag, compat_ro_flags_array, + compat_ro_flags_num, + BTRFS_FEATURE_COMPAT_RO_SUPP | + BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | + BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID); +} + static void print_readable_incompat_flag(u64 flag) { return __print_readable_flag(flag, incompat_flags_array, @@ -377,6 +400,7 @@ static void dump_superblock(struct btrfs_super_block *sb, int full) (unsigned long long)btrfs_super_compat_flags(sb)); printf("compat_ro_flags\t\t0x%llx\n", (unsigned long long)btrfs_super_compat_ro_flags(sb)); + print_readable_compat_ro_flag(btrfs_super_compat_ro_flags(sb)); printf("incompat_flags\t\t0x%llx\n", (unsigned long long)btrfs_super_incompat_flags(sb)); print_readable_incompat_flag(btrfs_super_incompat_flags(sb));