Skip to content

btrfs: introduce 3 debug sysfs interface to tweak the error handling behavior

Qu Wenruo linux-btrfs 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: introduce allow_backup_super_failure sysfs interfacefs/btrfs/disk-io.c fs/btrfs/fs.h fs/btrfs/sysfs.c+45 -20 replies
2/3btrfs: introduce super_failure_tolerance sysfs interfacefs/btrfs/disk-io.c fs/btrfs/fs.h fs/btrfs/sysfs.c+72 -30 replies
3/3btrfs: introduce allow_data_failure sysfs interfacefs/btrfs/disk-io.c fs/btrfs/extent_io.c fs/btrfs/fs.h +2 more+50 -20 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/3] btrfs: introduce 3 debug sysfs interface to tweak the error handling behavior

During a very interesting (and weird) debugging session, it turns out that btrfs will ignore a lot of write errors until we hit some critical location, then btrfs started reacting, normally by aborting the transaction.

This can be problematic for developers

As sometimes we want to catch the earlies sign, continuing without any obvious errors (other than kernel error messages) can make debugging much harder.

On the other hand, I totally understand if just a single sector failed to be write and we mark the whole fs read-only, it can be super frustrating for regular end users, thus we can not make it the default behavior.

So this patchset would introduce the following sysfs entries under /sys/fs/btrfs/<uuid>/debug/:

- allow_backup_super_failure
RW, binary (0 or 1), determines if btrfs would tolerace backup super blocks writeback failure.
If set to 1 and a failure is hit, btrfs would treat backup super blocks writeback failure as critical (the same level as primary super blocks).

The default value is 1, so the default behavior is not changed.

NOTE: this doesn't mean such failure would immediately lead to trasaction abort. Check super_failure_tolerance for more details.

- allow_data_failure
RW, binary (0 or 1), determines if btrfs would tolerace data sectors writeback failure.
If set to 1 and a failure is hit, btrfs would flip read-only immediately.

The default value is 1, so the default behavior is not changed.

- super_failure_tolerance
RW, s8, determines the tolerance for devices super blocks writeback.

Btrfs allows "nr_devices - 1" devices to fail their super blocks writeback. This means if we have 5 disks, btrfs allows 4 to fail their super block writeback.

If the value >= 0, the value itself would be the tolerance. If the value < 0, nr_devices + the value would be the tolerance. If value + nr_devices is still minus, btrfs would allow all devices to fail their super blocks writeback (aka, very dangerous)

The default value is -1, to match the existing behavior.

There would be another one for btrfs bio layer, but I have found something weird in the code, thus it would only be introduced after I solved the problem there, meanwhile we can discuss on the usefulness of this patchset.

Qu Wenruo (3):
btrfs: introduce allow_backup_super_failure sysfs interface
btrfs: introduce super_failure_tolerance sysfs interface
btrfs: introduce allow_data_failure sysfs interface

 fs/btrfs/disk-io.c   | 35 +++++++++++++---
 fs/btrfs/extent_io.c |  8 +++-
 fs/btrfs/fs.h        | 23 ++++++++++
 fs/btrfs/inode.c     |  9 +++-
 fs/btrfs/sysfs.c     | 99 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 167 insertions(+), 7 deletions(-)
Signature · 1 line
2.42.0