block: end bio with BLK_STS_AGAIN in case of non-mq devs and REQ_NOWAIT
PATCH 1/1 block: end bio with BLK_STS_AGAIN in case of non-mq devs and REQ_NOWAIT
Non-mq devs do not honor REQ_NOWAIT so give a chance to the caller to repeat request gracefully on -EAGAIN error.
The problem is well reproduced using io_uring:
mkfs.ext4 /dev/ram0
mount /dev/ram0 /mnt
# Preallocate a file
dd if=/dev/zero of=/mnt/file bs=1M count=1
# Start fio with io_uring and get -EIO fio --rw=write --ioengine=io_uring --size=1M --direct=1 --name=job --filename=/mnt/file
Signed-off-by Roman Penyaev <[email protected]>
--- block/blk-core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
block/blk-core.c +7 -4
@@ -886,11 +886,14 @@ generic_make_request_checks(struct bio *bio) }/* -* For a REQ_NOWAIT based request, return -EOPNOTSUPP -* if queue is not a request based queue. +* Non-mq queues do not honor REQ_NOWAIT, so complete a bio +* with BLK_STS_AGAIN status in order to catch -EAGAIN and +* to give a chance to the caller to repeat request gracefully. */ -if ((bio->bi_opf &REQ_NOWAIT ) && !queue_is_mq (q)) - goto not_supported; +if ((bio->bi_opf &REQ_NOWAIT ) && !queue_is_mq (q)) { + status =BLK_STS_AGAIN ; + goto end_io; + }if (should_fail_bio (bio)) goto end_io;
Signature · 1 line
2.24.0
Jens Axboe
maintainerQuoted 5 lines · Roman Penyaev
Non-mq devs do not honor
REQ_NOWAITso give a chance to the caller to repeat request gracefully on-EAGAINerror.The problem is well reproduced using
io_uring:
Quoted 8 lines
mkfs.ext4
/dev/ram0
mount/dev/ram0/mnt# Preallocate a file
dd if=/dev/zero of=/mnt/file bs=1M count=1# Start fio with io_uring and get -EIO fio --rw=write --ioengine=io_uring --size=1M --direct=1 --name=job --filename=/mnt/file
Thanks, this makes a lot of sense, doing -EIO for that case is wrong. Applied for 5.5.
Signature · 1 line
Jens Axboe