diff mbox

btrfs-progs: btrfs-debug-tree: show the compression method string

Message ID 1457599239-5512-1-git-send-email-wangxg.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiaoguang Wang March 10, 2016, 8:40 a.m. UTC
From: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 print-tree.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

David Sterba March 10, 2016, 1:23 p.m. UTC | #1
On Thu, Mar 10, 2016 at 04:40:39PM +0800, Xiaoguang Wang wrote:
> From: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> 
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> ---
>  print-tree.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/print-tree.c b/print-tree.c
> index 53a6813..5727cb9 100644
> --- a/print-tree.c
> +++ b/print-tree.c
> @@ -286,6 +286,20 @@ static void print_uuids(struct extent_buffer *eb)
>  	printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid);
>  }
>  
> +static char *compress_flags_to_str(u8 flag)
> +{
> +	switch (flag) {
> +	case BTRFS_COMPRESS_NONE:
> +		return "none";
> +	case BTRFS_COMPRESS_ZLIB:
> +		return "zlib";
> +	case BTRFS_COMPRESS_LZO:
> +		return "lzo";
> +	default:
> +		return "UNKNOWN";

would be good to print the actual value
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiaoguang Wang March 11, 2016, 3:08 a.m. UTC | #2
hello,

On 03/10/2016 09:23 PM, David Sterba wrote:
> On Thu, Mar 10, 2016 at 04:40:39PM +0800, Xiaoguang Wang wrote:
>> From: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
>>
>> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
>> ---
>>  print-tree.c | 22 ++++++++++++++++++----
>>  1 file changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/print-tree.c b/print-tree.c
>> index 53a6813..5727cb9 100644
>> --- a/print-tree.c
>> +++ b/print-tree.c
>> @@ -286,6 +286,20 @@ static void print_uuids(struct extent_buffer *eb)
>>  	printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid);
>>  }
>>  
>> +static char *compress_flags_to_str(u8 flag)
>> +{
>> +	switch (flag) {
>> +	case BTRFS_COMPRESS_NONE:
>> +		return "none";
>> +	case BTRFS_COMPRESS_ZLIB:
>> +		return "zlib";
>> +	case BTRFS_COMPRESS_LZO:
>> +		return "lzo";
>> +	default:
>> +		return "UNKNOWN";
> 
> would be good to print the actual value
OK, new version will be sent soon.

Regards,
Xiaoguang Wang

> 
> 
> 



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/print-tree.c b/print-tree.c
index 53a6813..5727cb9 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -286,6 +286,20 @@  static void print_uuids(struct extent_buffer *eb)
 	printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid);
 }
 
+static char *compress_flags_to_str(u8 flag)
+{
+	switch (flag) {
+	case BTRFS_COMPRESS_NONE:
+		return "none";
+	case BTRFS_COMPRESS_ZLIB:
+		return "zlib";
+	case BTRFS_COMPRESS_LZO:
+		return "lzo";
+	default:
+		return "UNKNOWN";
+	}
+}
+
 static void print_file_extent_item(struct extent_buffer *eb,
 				   struct btrfs_item *item,
 				   int slot,
@@ -295,10 +309,10 @@  static void print_file_extent_item(struct extent_buffer *eb,
 
 	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_flags_to_str(btrfs_file_extent_compression(eb, fi)));
 		return;
 	}
 	if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
@@ -317,8 +331,8 @@  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_flags_to_str(btrfs_file_extent_compression(eb, fi)));
 }
 
 /* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */