Re: [PATCH v2 2/2] btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
From: Anand Jain <hidden>
Date: 2021-12-01 16:57:26
David, Gentle ping on this patch? Thanks, Anand On 17/11/2021 11:29, Anand Jain wrote:
On 17/11/2021 01:16, David Sterba wrote:quoted
On Thu, Oct 21, 2021 at 11:31:17PM +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-2bfd09a578a8From user perspective, it's another fsid, one is in the path, so I'm wondering if it should be named like read_fsid or sprout_fsid or if the seed/sprout information should be put into another directory completely.I am viewing it as fsid as per the device's sb. This fsid matches with the blkid(8) output. A path to the device's fsid will help to script. So I am not voting for sprout_fsid because it does not exist in the most common non-sprouted fsid. Now to show whether a device is seed or sprout, the user friendly approach will be like for example: /sys/fs/btrfs/<fsid>/devinfo/<devid>/device_state to show all that apply, for example: SEED|SPROUT|READ_ONLY|WRITABLE|ZONED|METADATA_ONLY|\ DATA_ONLY|READ_PREFERRED|REPLACE_TGT|REPLACE_SRC|\ SCRUB_RUNNING However, per kernel general rule of thumb one value per sys-fs file, so it should be for example: /sys/fs/btrfs/<fsid>/devinfo/<devid>/seed 0 /sys/fs/btrfs/<fsid>/devinfo/<devid>/sprout 1 So based on this my patch "btrfs: introduce new device-state read_preferred" in the mailing list already proposed /sys/fs/btrfs/<fsid>/devinfo/<devid>/read_preferred So to summarize, I can rename fsid to read_fsid. And, progressively in a separate patch, we can add <>/seed <>/sprout sysfs files as above. What do you think?