From patchwork Fri Mar 11 05:09:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoguang Wang X-Patchwork-Id: 8562181 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 57AE89F46A for ; Fri, 11 Mar 2016 05:30:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A9DF2035D for ; Fri, 11 Mar 2016 05:30:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92AAB2034F for ; Fri, 11 Mar 2016 05:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751301AbcCKF3A (ORCPT ); Fri, 11 Mar 2016 00:29:00 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:54249 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750927AbcCKF26 (ORCPT ); Fri, 11 Mar 2016 00:28:58 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="4465451" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Mar 2016 13:28:51 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id B3CDC42B4B17 for ; Fri, 11 Mar 2016 13:28:49 +0800 (CST) Received: from localhost.localdomain (10.167.226.24) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 11 Mar 2016 13:28:49 +0800 From: Xiaoguang Wang To: CC: Wang Xiaoguang Subject: [PATCH v2] btrfs-progs: btrfs-debug-tree: show the compression method string Date: Fri, 11 Mar 2016 13:09:02 +0800 Message-ID: <1457672942-20785-1-git-send-email-wangxg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.2.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.24] X-yoursite-MailScanner-ID: B3CDC42B4B17.A58E1 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wangxg.fnst@cn.fujitsu.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Xiaoguang Signed-off-by: Wang Xiaoguang --- print-tree.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/print-tree.c b/print-tree.c index 53a6813..87ec498 100644 --- a/print-tree.c +++ b/print-tree.c @@ -286,19 +286,40 @@ static void print_uuids(struct extent_buffer *eb) printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid); } +static void compress_type_to_str(u8 compress_type, char *ret) +{ + switch (compress_type) { + case BTRFS_COMPRESS_NONE: + strcpy(ret, "none"); + break; + case BTRFS_COMPRESS_ZLIB: + strcpy(ret, "zlib"); + break; + case BTRFS_COMPRESS_LZO: + strcpy(ret, "lzo"); + break; + default: + sprintf(ret, "unknown value: %d", compress_type); + } +} + static void print_file_extent_item(struct extent_buffer *eb, struct btrfs_item *item, int slot, struct btrfs_file_extent_item *fi) { int extent_type = btrfs_file_extent_type(eb, fi); + char compress_str[BTRFS_NAME_LEN]; + + compress_type_to_str(btrfs_file_extent_compression(eb, fi), + compress_str); if (extent_type == BTRFS_FILE_EXTENT_INLINE) { printf("\t\tinline extent data size %u " - "ram %u compress %d\n", + "ram %u compress(%s)\n", btrfs_file_extent_inline_item_len(eb, item), btrfs_file_extent_inline_len(eb, slot, fi), - btrfs_file_extent_compression(eb, fi)); + compress_str); return; } if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) { @@ -317,8 +338,7 @@ static void print_file_extent_item(struct extent_buffer *eb, (unsigned long long)btrfs_file_extent_offset(eb, fi), (unsigned long long)btrfs_file_extent_num_bytes(eb, fi), (unsigned long long)btrfs_file_extent_ram_bytes(eb, fi)); - printf("\t\textent compression %d\n", - btrfs_file_extent_compression(eb, fi)); + printf("\t\textent compression(%s)\n", compress_str); } /* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */