Skip to content

Btrfs: add IO error device stats

Stefan Behrens linux-btrfs linux-fsdevel lkml 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 3 repliesIn review
  2. v43 patches 4 repliesSuperseded
  3. v33 patches 4 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v23 patches0 repliesSuperseded
v13 patches3 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Btrfs: add device counters for detected IO and checksum errorsfs/btrfs/disk-io.c fs/btrfs/extent_io.c fs/btrfs/ioctl.h +3 more+230 -240 replies
2/3Btrfs: add ioctl to get and reset the device statsfs/btrfs/ioctl.c fs/btrfs/ioctl.h fs/btrfs/volumes.c +1 more+77 -00 replies
3/3Btrfs: read device stats on mount, write modified ones during commitfs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/print-tree.c +3 more+232 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/3] Btrfs: add IO error device stats

Changes v1-v2:
- Remove restriction that BTRFS_IOC_GET_DEVICE_STATS is a privileged operation
- Cast u64 to unsigned long long for printf()

Changes v2-v3:
- Rebased on Chris' current master

Changes v3-v4:
- Add padding at end of ioctl structure

Changes v4-v5:
- The statistic members in the ioctl are now organized as an array of 64 bit values. Symbolic names for the array indexes are defined in an enum, which also defines the max value. This change makes it easier to add new statistic members in the future
- Give ins_len = -1 to btrfs_search_slot() when an item might get deleted
- Introduce a helper function for the repeated sequence stat_int() + dirty = 1 + stat_print()
- Introduce a helper function for the code that shares the bio bi_private member for two pieces of information

The goal is to detect when drives start to get an increased error rate, when drives should be replaced soon. Therefore statistic counters are added that count IO errors (read, write and flush). Additionally, the software detected errors like checksum errors and corrupted blocks are counted.

An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters.

The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters.

A patch for the btrfs-progs world will also be sent.

Stefan Behrens (3):
Btrfs: add device counters for detected IO and checksum errors
Btrfs: add ioctl to get and reset the device stats
Btrfs: read device stats on mount, write modified ones during commit

 fs/btrfs/ctree.h       |   38 ++++++
 fs/btrfs/disk-io.c     |   20 +++-
 fs/btrfs/extent_io.c   |   18 ++-
 fs/btrfs/ioctl.c       |   26 +++++
 fs/btrfs/ioctl.h       |   33 ++++++
 fs/btrfs/print-tree.c  |    3 +
 fs/btrfs/scrub.c       |   65 ++++++++---
 fs/btrfs/transaction.c |    4 +
 fs/btrfs/volumes.c     |  304 +++++++++++++++++++++++++++++++++++++++++++++++-
 fs/btrfs/volumes.h     |   52 +++++++++
 10 files changed, 539 insertions(+), 24 deletions(-)
Signature · 1 line
1.7.10.2