btrfs: sysfs: export dev stats in devinfo directory
authorDavid Sterba <dsterba@suse.com>
Fri, 4 Jun 2021 13:00:05 +0000 (15:00 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 22 Jun 2021 12:11:57 +0000 (14:11 +0200)
commitda658b5708c68b03b395b7c5c50bae47826db8cc
tree0bff8278782f91f78b45ee016053a3dca2050d18
parent1a9fd4172d5c8ba64735b3aef7eed643d398ce05
btrfs: sysfs: export dev stats in devinfo directory

The device stats can be read by ioctl, wrapped by command 'btrfs device
stats'. Provide another source where to read the information in
/sys/fs/btrfs/FSID/devinfo/DEVID/error_stats . The format is a list of
'key value' pairs one per line, which is common in other stat files.
The names are the same as used in other device stat outputs.

The stats are all in one file as it's the snapshot of all available
stats. The 'one value per file' format is not very suitable here. The
stats should be valid right after the stats item is read from disk,
shortly after initializing the device.

In case the stats are not yet valid, print just 'invalid' as the file
contents.

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