Skip to content

[RFE] expose btrfs device stats #1167

@jelly

Description

@jelly

Btrfs exposes records device statistics via btrfs device stats (json or not) or via an ioctl BTRFS_IOC_GET_DEV_STATS. The stats can be obtained unprivileged.

The use case would be exposing these stats in Cockpit's btrfs device view:

Image

I can imagine something like:

BlockDev.btrfs_filesystem_stats(mount_point)

The only question is how this will be integrated in UDisks, the API is based on a Filesystem so it could be. But that can be solved later, it could also become a part of org.freedesktop.UDisks2.Manager.BTRFS.

Regarding the implementation I am open to either using the ioctl in libblockdev or btrfs --format json device stats / (see output below). I am happy to implement either:

[jelle@homeserver ~]$ btrfs --format json device stats /mnt/disk
{
  "__header": {
    "version": "1"
  },
  "device-stats": [
    {
      "device": "/dev/sda",
      "devid": 1,
      "write_io_errs": 0,
      "read_io_errs": 0,
      "flush_io_errs": 0,
      "corruption_errs": 0,
      "generation_errs": 0
    },
    {
      "device": "/dev/sdb",
      "devid": 2,
      "write_io_errs": 0,
      "read_io_errs": 0,
      "flush_io_errs": 0,
      "corruption_errs": 0,
      "generation_errs": 0
    }
  ]
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions