linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how btrfs uses devid?
@ 2016-01-01 12:16 UGlee
  2016-01-01 12:23 ` Hugo Mills
  0 siblings, 1 reply; 3+ messages in thread
From: UGlee @ 2016-01-01 12:16 UTC (permalink / raw)
  To: linux-btrfs

Dear all:

If a btrfs device is missing, the command tool tells user the devid of
the missing devices.

I understand that each device (disk) in a btrfs volume has been
assigned a uuid (UUID_SUB field in udevadm info output). If the device
is missing, it's hard to tell user to input such uuid string in
command line. So devid is for convenience.

In our product, we want to record all disk information of a volume in
a file. If a disk is missing, not because it's broken, but because the
user has so many disks and in some cases they may put back the wrong
one. In this scenario, we can provide the disk information (such as
serial number) to user and help them to check if they did something
wrong.

My question is: is the devid just an alias to sub uuid? for a given
disk device, it is never changed during any btrfs operation, including
add, remove, balance and replace? or it may be changed, and when?

One more question just for curiosity. I checked the source code of
btrfs-progs briefly. It seems that there is no data structure in
superblock recording all sub-uuids or all devids for the volume, so
how does btrfs figure out the missing devid? since they are not always
sequential integers, for example, after one device is removed, the
devid is simply removed and the devid of other device is not
re-numbered.

matianfu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: how btrfs uses devid?
  2016-01-01 12:16 how btrfs uses devid? UGlee
@ 2016-01-01 12:23 ` Hugo Mills
  2016-01-02  9:31   ` UGlee
  0 siblings, 1 reply; 3+ messages in thread
From: Hugo Mills @ 2016-01-01 12:23 UTC (permalink / raw)
  To: UGlee; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 2049 bytes --]

On Fri, Jan 01, 2016 at 08:16:28PM +0800, UGlee wrote:
> Dear all:
> 
> If a btrfs device is missing, the command tool tells user the devid of
> the missing devices.
> 
> I understand that each device (disk) in a btrfs volume has been
> assigned a uuid (UUID_SUB field in udevadm info output). If the device
> is missing, it's hard to tell user to input such uuid string in
> command line. So devid is for convenience.

> In our product, we want to record all disk information of a volume in
> a file. If a disk is missing, not because it's broken, but because the
> user has so many disks and in some cases they may put back the wrong
> one. In this scenario, we can provide the disk information (such as
> serial number) to user and help them to check if they did something
> wrong.
> 
> My question is: is the devid just an alias to sub uuid? for a given
> disk device, it is never changed during any btrfs operation, including
> add, remove, balance and replace? or it may be changed, and when?

   Actually, devid is the ID that the FS uses internally in the device
tree to identify them. It's not just a convenience -- it's the
"official" identifier for the device within the filesystem.
 
> One more question just for curiosity. I checked the source code of
> btrfs-progs briefly. It seems that there is no data structure in
> superblock recording all sub-uuids or all devids for the volume, so
> how does btrfs figure out the missing devid? since they are not always
> sequential integers, for example, after one device is removed, the
> devid is simply removed and the devid of other device is not
> re-numbered.

   The devices that should be there (identified by devid) are listed
in the device tree. If one of those doesn't match up with a
currently-known device for that filesystem (as determined by btrfs dev
scan), then it's missing.

   Hugo.

-- 
Hugo Mills             | I gave up smoking, drinking and sex once. It was the
hugo@... carfax.org.uk | scariest 20 minutes of my life.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: how btrfs uses devid?
  2016-01-01 12:23 ` Hugo Mills
@ 2016-01-02  9:31   ` UGlee
  0 siblings, 0 replies; 3+ messages in thread
From: UGlee @ 2016-01-02  9:31 UTC (permalink / raw)
  To: Hugo Mills, UGlee, linux-btrfs

Thank you very much, sir.

Could you confirm that devid and UUID_SUB will never be changed at any
circumstances for a given device, unless it is reformatted by
mkfs.btrfs?

2016-01-01 20:23 GMT+08:00 Hugo Mills <hugo@carfax.org.uk>:
> On Fri, Jan 01, 2016 at 08:16:28PM +0800, UGlee wrote:
>> Dear all:
>>
>> If a btrfs device is missing, the command tool tells user the devid of
>> the missing devices.
>>
>> I understand that each device (disk) in a btrfs volume has been
>> assigned a uuid (UUID_SUB field in udevadm info output). If the device
>> is missing, it's hard to tell user to input such uuid string in
>> command line. So devid is for convenience.
>
>> In our product, we want to record all disk information of a volume in
>> a file. If a disk is missing, not because it's broken, but because the
>> user has so many disks and in some cases they may put back the wrong
>> one. In this scenario, we can provide the disk information (such as
>> serial number) to user and help them to check if they did something
>> wrong.
>>
>> My question is: is the devid just an alias to sub uuid? for a given
>> disk device, it is never changed during any btrfs operation, including
>> add, remove, balance and replace? or it may be changed, and when?
>
>    Actually, devid is the ID that the FS uses internally in the device
> tree to identify them. It's not just a convenience -- it's the
> "official" identifier for the device within the filesystem.
>
>> One more question just for curiosity. I checked the source code of
>> btrfs-progs briefly. It seems that there is no data structure in
>> superblock recording all sub-uuids or all devids for the volume, so
>> how does btrfs figure out the missing devid? since they are not always
>> sequential integers, for example, after one device is removed, the
>> devid is simply removed and the devid of other device is not
>> re-numbered.
>
>    The devices that should be there (identified by devid) are listed
> in the device tree. If one of those doesn't match up with a
> currently-known device for that filesystem (as determined by btrfs dev
> scan), then it's missing.
>
>    Hugo.
>
> --
> Hugo Mills             | I gave up smoking, drinking and sex once. It was the
> hugo@... carfax.org.uk | scariest 20 minutes of my life.
> http://carfax.org.uk/  |
> PGP: E2AB1DE4          |

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-02  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-01 12:16 how btrfs uses devid? UGlee
2016-01-01 12:23 ` Hugo Mills
2016-01-02  9:31   ` UGlee

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).