linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Misono, Tomohiro" <misono.tomohiro@jp.fujitsu.com>
To: Qu Wenruo <wqu@suse.com>, <linux-btrfs@vger.kernel.org>
Cc: <dsterba@suse.cz>
Subject: Re: [PATCH] btrfs-progs: print-tree: Enehance uuid item print
Date: Tue, 31 Oct 2017 14:44:35 +0900	[thread overview]
Message-ID: <33d7b245-5a6b-6afc-938d-08d21c6776a2@jp.fujitsu.com> (raw)
In-Reply-To: <20171031040341.18840-1-wqu@suse.com>



On 2017/10/31 13:03, Qu Wenruo wrote:
> For key type BTRFS_UUID_KEY_SUBVOL or BTRFS_UUID_KEY_RECEIVED_SUBVOL the
> key objectid and key offset are just half of the UUID.
> 
> However we just print the key as %llu, which is converted from little
> endian, not byte order for UUID, nor the traditional 36 bytes human
> readable uuid format.
> 
> Although true engineer can easily convert it in their brain, but to
> make it easier for search, output the result UUID using the 36 chars format.
> 
> Cc: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> Inspired by UUID related work from Misono.
> ---
>  print-tree.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/print-tree.c b/print-tree.c
> index 3c585e31f1fc..687f871db302 100644
> --- a/print-tree.c
> +++ b/print-tree.c
> @@ -803,14 +803,25 @@ void btrfs_print_key(struct btrfs_disk_key *disk_key)
>  	}
>  }
>  
> -static void print_uuid_item(struct extent_buffer *l, unsigned long offset,
> -			    u32 item_size)
> +static void print_uuid_item(struct extent_buffer *l, int slot,
> +			    unsigned long offset, u32 item_size)
>  {
> +	struct btrfs_key key;
> +	char uuid_str[BTRFS_UUID_UNPARSED_SIZE];
> +	u8 uuid[BTRFS_UUID_SIZE];
> +
> +	/* Reassemble the uuid from key.objecitd and key.offset */
> +	btrfs_item_key_to_cpu(l, &key, slot);
> +	put_unaligned_le64(key.objectid, uuid);
> +	put_unaligned_le64(key.offset, uuid + sizeof(u64));
> +	uuid_unparse(uuid, uuid_str);
> +
>  	if (item_size & (sizeof(u64) - 1)) {
>  		printf("btrfs: uuid item with illegal size %lu!\n",
>  		       (unsigned long)item_size);
>  		return;
>  	}
> +	printf("\t\tuuid %s\n", uuid_str);
>  	while (item_size) {
>  		__le64 subvol_id;
>  
> @@ -1297,7 +1308,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *eb)
>  			break;
>  		case BTRFS_UUID_KEY_SUBVOL:
>  		case BTRFS_UUID_KEY_RECEIVED_SUBVOL:
> -			print_uuid_item(eb, btrfs_item_ptr_offset(eb, i),
> +			print_uuid_item(eb, i, btrfs_item_ptr_offset(eb, i),
>  					btrfs_item_size_nr(eb, i));
>  			break;
>  		case BTRFS_STRING_ITEM_KEY: {
> 

Reviewed-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>


  reply	other threads:[~2017-10-31  5:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31  4:03 [PATCH] btrfs-progs: print-tree: Enehance uuid item print Qu Wenruo
2017-10-31  5:44 ` Misono, Tomohiro [this message]
2017-10-31  7:15 ` Nikolay Borisov
2017-10-31  7:27   ` Qu Wenruo
2017-10-31  7:29   ` Nikolay Borisov
2017-10-31  7:35     ` Qu Wenruo
2017-10-31  7:41       ` Nikolay Borisov
2017-10-31  8:05         ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33d7b245-5a6b-6afc-938d-08d21c6776a2@jp.fujitsu.com \
    --to=misono.tomohiro@jp.fujitsu.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).