diff options
| author | Md Haris Iqbal <haris.iqbal@linux.dev> | 2026-11-11 22:58:37 +0100 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-11-18 09:06:32 -0700 |
| commit | 6bd856cc99963b786cb530141745ef733de76cc3 (patch) | |
| tree | 11ddc3cce8d6655dffb82898f7bd633be28d2348 /include/linux | |
| parent | d239710cf3e6bd5fec66766957c3752d9cfbd2c5 (diff) | |
block: allow error injection rules to delay bios
Error injection can only fail a bio today. Add a delay_us option so that
a rule can hold a bio back first, to model a slow device.
If a matching rule has delay_us set, the bio is held for that long. It is
then failed if the rule also has a status, or resubmitted otherwise.
The resubmission is done through submit_bio_noacct_nocheck(), which is
where the injection hook sits. To avoid the same delay rule being applied
to it again, mark the bio with the BIO_ERROR_INJECTED flag as soon as a
rule matches. This also prevents bios that are split later and resubmitted
from being evaluated for delay (or error injection) again. __bio_clone()
does not propagate the flag, so a clone a stacking driver aims at a lower
device is still evaluated.
The bio is submitted from a workqueue rather than from the timer, because
submitting a bio can sleep. A REQ_NOWAIT bio is failed with BLK_STS_AGAIN
instead of being delayed. Values above 600 seconds are rejected.
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Md Haris Iqbal <haris.iqbal@linux.dev>
Link: https://patch.msgid.link/20261111215838.103356-3-haris.iqbal@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/blk_types.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 0cc09b975d8f..1a5812fa4052 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -328,6 +328,7 @@ enum { BIO_ZONE_WRITE_PLUGGING, /* bio handled through zone write plugging */ BIO_EMULATES_ZONE_APPEND, /* bio emulates a zone append operation */ BIO_COMPLETE_IN_TASK, /* complete bi_end_io() in task context */ + BIO_ERROR_INJECTED, /* error injection rules already applied */ BIO_FLAG_LAST }; |
