mbox series

[v2,0/2] btrfs-progs: read device fsid from the sysfs

Message ID cover.1676124188.git.anand.jain@oracle.com (mailing list archive)
Headers show
Series btrfs-progs: read device fsid from the sysfs | expand

Message

Anand Jain Feb. 13, 2023, 9:37 a.m. UTC
v2:
 Almost a resend; no code was altered, except for the change log.

The following test scenario (as in fstests btrfs/249) shows an issue
where the "usage" subcommand fails to retrieve the fsid from the
superblock for a missing device.

Create a raid1 seed device while one of its device missing.
   $ mkfs.btrfs -f -draid1 -mraid1 $DEV1 $DEV2
   $ btrfstune -S 1 $DEV1
   $ wipefs -a $DEV2

Mount the seed device
   $ btrfs device scan --forget
   $ mount -o degraded $DEV1 /btrfs

Add a sprout device
   $ btrfs device add $DEV3 /btrfs -f

The usage subommand fails because we try to read superblock for the missing
device
   $ btrfs filesystem usage /btrfs
     ERROR: unexpected number of devices: 1 >= 1
     ERROR: if seed device is used, try running this command as root

The commit a26d60dedf9a ("btrfs: sysfs: add devinfo/fsid to retrieve
actual fsid from the device") introduced a sysfs interface for
retrieving the fsid of a device. This change allows for the reading of the
device fsid through the sysfs interface in the kernel, while retaining the
old method of reading the superblock from the disk for backward
compatibility during normal, non-missing device conditions.

Anand Jain (2):
  btrfs-progs: prepare helper device_is_seed
  btrfs-progs: read fsid from the sysfs in device_is_seed

 cmds/filesystem-usage.c | 47 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 5 deletions(-)

--
2.39.1

Comments

David Sterba Feb. 21, 2023, 9:39 p.m. UTC | #1
On Mon, Feb 13, 2023 at 05:37:40PM +0800, Anand Jain wrote:
> v2:
>  Almost a resend; no code was altered, except for the change log.
> 
> The following test scenario (as in fstests btrfs/249) shows an issue
> where the "usage" subcommand fails to retrieve the fsid from the
> superblock for a missing device.
> 
> Create a raid1 seed device while one of its device missing.
>    $ mkfs.btrfs -f -draid1 -mraid1 $DEV1 $DEV2
>    $ btrfstune -S 1 $DEV1
>    $ wipefs -a $DEV2
> 
> Mount the seed device
>    $ btrfs device scan --forget
>    $ mount -o degraded $DEV1 /btrfs
> 
> Add a sprout device
>    $ btrfs device add $DEV3 /btrfs -f
> 
> The usage subommand fails because we try to read superblock for the missing
> device
>    $ btrfs filesystem usage /btrfs
>      ERROR: unexpected number of devices: 1 >= 1
>      ERROR: if seed device is used, try running this command as root
> 
> The commit a26d60dedf9a ("btrfs: sysfs: add devinfo/fsid to retrieve
> actual fsid from the device") introduced a sysfs interface for
> retrieving the fsid of a device. This change allows for the reading of the
> device fsid through the sysfs interface in the kernel, while retaining the
> old method of reading the superblock from the disk for backward
> compatibility during normal, non-missing device conditions.
> 
> Anand Jain (2):
>   btrfs-progs: prepare helper device_is_seed
>   btrfs-progs: read fsid from the sysfs in device_is_seed

Added to devel with some fixups, thanks.
Anand Jain Feb. 22, 2023, 3:16 a.m. UTC | #2
On 22/02/2023 05:39, David Sterba wrote:
> On Mon, Feb 13, 2023 at 05:37:40PM +0800, Anand Jain wrote:
>> v2:
>>   Almost a resend; no code was altered, except for the change log.
>>
>> The following test scenario (as in fstests btrfs/249) shows an issue
>> where the "usage" subcommand fails to retrieve the fsid from the
>> superblock for a missing device.
>>
>> Create a raid1 seed device while one of its device missing.
>>     $ mkfs.btrfs -f -draid1 -mraid1 $DEV1 $DEV2
>>     $ btrfstune -S 1 $DEV1
>>     $ wipefs -a $DEV2
>>
>> Mount the seed device
>>     $ btrfs device scan --forget
>>     $ mount -o degraded $DEV1 /btrfs
>>
>> Add a sprout device
>>     $ btrfs device add $DEV3 /btrfs -f
>>
>> The usage subommand fails because we try to read superblock for the missing
>> device
>>     $ btrfs filesystem usage /btrfs
>>       ERROR: unexpected number of devices: 1 >= 1
>>       ERROR: if seed device is used, try running this command as root
>>
>> The commit a26d60dedf9a ("btrfs: sysfs: add devinfo/fsid to retrieve
>> actual fsid from the device") introduced a sysfs interface for
>> retrieving the fsid of a device. This change allows for the reading of the
>> device fsid through the sysfs interface in the kernel, while retaining the
>> old method of reading the superblock from the disk for backward
>> compatibility during normal, non-missing device conditions.
>>
>> Anand Jain (2):
>>    btrfs-progs: prepare helper device_is_seed
>>    btrfs-progs: read fsid from the sysfs in device_is_seed
> 
> Added to devel with some fixups, thanks.

Fixups look good in the devel branch.

Thanks, Anand