|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 |
| 2 | +
|
| 3 | +============================ |
| 4 | +Configurable Error Injection |
| 5 | +============================ |
| 6 | + |
| 7 | +Overview |
| 8 | +-------- |
| 9 | + |
| 10 | +Configurable error injection allows injecting specific block layer status codes |
| 11 | +for sector ranges of a block device. Errors can be injected unconditionally, or |
| 12 | +with a given probability. |
| 13 | + |
| 14 | +To use configurable error injection, CONFIG_BLK_ERROR_INJECTION must be enabled. |
| 15 | + |
| 16 | +The only interface is the error_injection debugfs file, which is created for |
| 17 | +each registered gendisk. Writes to this file are used to create or delete rules |
| 18 | +and reads return a list of the current error injection sites. |
| 19 | + |
| 20 | +Options |
| 21 | +------- |
| 22 | + |
| 23 | +The following options specify the operations: |
| 24 | + |
| 25 | +=================== ======================================================= |
| 26 | +add add a new rule |
| 27 | +removeall remove all existing rules |
| 28 | +=================== ======================================================= |
| 29 | + |
| 30 | +The following options specify the details of the rule for the add operation: |
| 31 | + |
| 32 | +=================== ======================================================= |
| 33 | +op=<string> block layer operation this rule applies to. This uses |
| 34 | + the XYZ for each REQ_OP_XYZ operation, e.g. READ, WRITE |
| 35 | + or DISCARD. Mandatory. |
| 36 | +status=<string> Status to return. This uses XYZ for each BLK_STS_XYZ |
| 37 | + code, e.g. IOERR or MEDIUM. Mandatory. |
| 38 | +start=<number> First block layer sector the rule applies to. |
| 39 | + Optional, defaults to 0. |
| 40 | +nr_sectors=<number> Number of sectors this rule applies. |
| 41 | + Optional, defaults to the remainder of the device. |
| 42 | +chance=<number> Only return a failure with a likelihood of 1/chance. |
| 43 | + Optional, defaults to 1 (always). |
| 44 | +=================== ======================================================= |
| 45 | + |
| 46 | +Example |
| 47 | +------- |
| 48 | + |
| 49 | +Return BLK_STS_IOERR for one in 10 reads of sector 0 of /dev/nvme0n1: |
| 50 | + |
| 51 | + $ echo 'add,op=READ,start=0,status=IOERR,chance=10' > /sys/kernel/debug/block/nvme0n1/error_injection |
| 52 | + |
| 53 | +Return BLK_STS_MEDIUM for every write to /dev/nvme0n1: |
| 54 | + |
| 55 | + $ echo 'add,op=WRITE,start=0,status=MEDIUM' > /sys/kernel/debug/block/nvme0n1/error_injection |
| 56 | + |
| 57 | +Remove all rules for /dev/nvme0n1: |
| 58 | + |
| 59 | + $ echo 'removeall' > /sys/kernel/debug/block/nvme0n1/error_injection |
0 commit comments