btrfs: sysfs: add devinfo/fsid to retrieve actual fsid from the device
authorAnand Jain <anand.jain@oracle.com>
Thu, 21 Oct 2021 15:31:17 +0000 (23:31 +0800)
committerDavid Sterba <dsterba@suse.com>
Fri, 7 Jan 2022 13:18:25 +0000 (14:18 +0100)
commita26d60dedf9af81df7aeaef66353eb391f85e7a9
treef6e8ec4274cdddcc399d78b34299d6e120742195
parentc18e3235646a8ba74d013067a6475c8d262d3776
btrfs: sysfs: add devinfo/fsid to retrieve actual fsid from the device

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-2bfd09a578a8

Though it's related to seeding, the name of the sysfs file is plain fsid as it
matches what blkid says.  A path to the device's fsid will aid scripting.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/sysfs.c