Re: [PATCH 2/2] btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
From: Anand Jain <hidden>
Date: 2021-10-21 08:56:05
On 21/10/2021 12:03, Anand Jain wrote:
On 21/10/2021 02:59, David Sterba wrote:quoted
On Tue, Oct 19, 2021 at 08:22:10AM +0800, Anand Jain wrote:quoted
In the case of the seed device, the fsid can be different from the mounted sprout fsid. The userland has to read the device superblock to know the fsid but, that idea fails if the device is missing. So add a sysfs interface devinfo/<devid>/fsid to show the fsid of the device. For example: $ cd /sys/fs/btrfs/b10b02a5-f9de-4276-b9e8-2bfd09a578a8 $ cat devinfo/1/fsid c44d771f-639d-4df3-99ec-5bc7ad2af93b $ cat devinfo/3/fsid b10b02a5-f9de-4276-b9e8-2bfd09a578a8How do you create such setup? I can't reproduce it. The simplest seeding: mkfs.btrfs /dev/sdx btrfstune -S 1 /dev/sdx mount /dev/sdx mnt ... the device has the same FSID as is the sysfs directory name With a new device and removed the seeding one: btrfs device add /dev/sdy mntAt this step, we generate a new fsid for the writeable FS. Let's call it sprout-fsid. (If you check the sys-fs fsid, you will have two fsid here). Also, at this step, the fs_info->fs_devices->fsid changes from seed-fsid to the sprout-fsid. So, we should make the <mnt> also a writeable without the need to call 'remount,rw' explicitly IMO. What do you think?
More importantly, the fs_info->super_copy is of sprout device. So there isn't any reason that we should maintain the new sprout fs as readonly after the device add.
quoted
mount -o remount,rw mnt btrfs device delete /dev/sdx mnt ... both devices have the same fsid as wellThanks, Anand