diff mbox

btrfs-progs: Add dev uuid output for print_dev_item().

Message ID 1401325356-27683-1-git-send-email-quwenruo@cn.fujitsu.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Qu Wenruo May 29, 2014, 1:02 a.m. UTC
The original print_dev_item() only prints device id,total bytes and
bytes used.
When it comes to debug things related to duplicated device id, dev uuid
is needed to distinguish different device since device is is no
reliable.

This patch added dev uuid output.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 print-tree.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Mike Fleetwood May 29, 2014, 7:52 p.m. UTC | #1
On 29 May 2014 02:02, Qu Wenruo <quwenruo@cn.fujitsu.com> wrote:
> The original print_dev_item() only prints device id,total bytes and
> bytes used.
> When it comes to debug things related to duplicated device id, dev uuid
> is needed to distinguish different device since device is is no
> reliable.

At the end of the message I think there is a couple of typos and you meant:
... device id is not reliable.

>
> This patch added dev uuid output.
>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> ---
>  print-tree.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)

Thanks,
Mike
--
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
Qu Wenruo May 30, 2014, 12:58 a.m. UTC | #2
-------- Original Message --------
Subject: Re: [PATCH] btrfs-progs: Add dev uuid output for print_dev_item().
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2014?05?30? 03:52
> On 29 May 2014 02:02, Qu Wenruo <quwenruo@cn.fujitsu.com> wrote:
>> The original print_dev_item() only prints device id,total bytes and
>> bytes used.
>> When it comes to debug things related to duplicated device id, dev uuid
>> is needed to distinguish different device since device is is no
>> reliable.
> At the end of the message I think there is a couple of typos and you meant:
> ... device id is not reliable.
Yes, it is not reliable when comes to reappered missing devices.
If you mounted btrfs with missing device using degraded mode and 
replaced missing device,
but the missing device reappered, then devices with same dev uuid will 
show up.

Thanks,
Qu
>
>> This patch added dev uuid output.
>>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
>> ---
>>   print-tree.c | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
> Thanks,
> Mike
> --
> 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

--
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
David Sterba June 2, 2014, 5:43 p.m. UTC | #3
On Thu, May 29, 2014 at 08:52:04PM +0100, Mike Fleetwood wrote:
> On 29 May 2014 02:02, Qu Wenruo <quwenruo@cn.fujitsu.com> wrote:
> > The original print_dev_item() only prints device id,total bytes and
> > bytes used.
> > When it comes to debug things related to duplicated device id, dev uuid
> > is needed to distinguish different device since device is is no
> > reliable.
> 
> At the end of the message I think there is a couple of typos and you meant:
> ... device id is not reliable.

Fixed, thanks.
--
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 574ae9e..cb5c2e1 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -179,11 +179,20 @@  void print_chunk(struct extent_buffer *eb, struct btrfs_chunk *chunk)
 static void print_dev_item(struct extent_buffer *eb,
 			   struct btrfs_dev_item *dev_item)
 {
+	char disk_uuid_c[BTRFS_UUID_UNPARSED_SIZE];
+	u8 disk_uuid[BTRFS_UUID_SIZE];
+
+	read_extent_buffer(eb, disk_uuid,
+			   (unsigned long)btrfs_device_uuid(dev_item),
+			   BTRFS_UUID_SIZE);
+	uuid_unparse(disk_uuid, disk_uuid_c);
 	printf("\t\tdev item devid %llu "
-	       "total_bytes %llu bytes used %Lu\n",
+	       "total_bytes %llu bytes used %Lu\n"
+	       "\t\tdev uuid %s\n",
 	       (unsigned long long)btrfs_device_id(eb, dev_item),
 	       (unsigned long long)btrfs_device_total_bytes(eb, dev_item),
-	       (unsigned long long)btrfs_device_bytes_used(eb, dev_item));
+	       (unsigned long long)btrfs_device_bytes_used(eb, dev_item),
+	       disk_uuid_c);
 }
 
 static void print_uuids(struct extent_buffer *eb)