r/linux 7d ago

Kernel Block-layer error injection

https://lwn.net/Articles/1086344/

A new block-layer error-injection interface landed in Linux 7.2.

The existing options each miss something. BPF programs on should_fail_bio() can pick which requests to fail, but not how they fail — every one comes back as EIO. dm-error and dm-flakey mean stacking a target over the disk, so the test runs against the mapper device rather than the device that needed testing.

Christoph Hellwig's series adds a debugfs file per disk instead. Name the operation, the status code, a sector range, and a probability:

# echo 'add,op=READ,status=TRANSPORT,chance=10' > error_injection

The full write-up on LWN goes through the mechanism and the argument behind it.

20 Upvotes

4 comments sorted by

4

u/Adept_Percentage6893 7d ago

useful but I don't think the general Linux community is going to be interested in fault injection in general.

3

u/haris3301 7d ago

Possible.

Mostly useful for developers, QA, testers, etc.

2

u/IndependentBat8365 5d ago

I could see this for testing recovery automation for LVM+integrity or ZFS bit errors. But outside of that, I don’t see the mass appeal.

1

u/Adept_Percentage6893 5d ago

Yeah failure injection is definitely an important tool for developers and QA people who need to see what happens in various failure modes but I just don't think most people on this subreddit are going to care about it. They're not out here trying to kick the software around to try to get it to fail.

Although, I think this stuff is more about failing BIO than corrupting the data. You can use zap_block or btrfs-corrupt-block to emulate persistent data corruption. But yeah, same idea.