Skip to content

Commit c58c1f8

Browse files
Roman Penyaevaxboe
authored andcommitted
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]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1c05839 commit c58c1f8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

block/blk-core.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,14 @@ generic_make_request_checks(struct bio *bio)
885885
}
886886

887887
/*
888-
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
889-
* if queue is not a request based queue.
888+
* Non-mq queues do not honor REQ_NOWAIT, so complete a bio
889+
* with BLK_STS_AGAIN status in order to catch -EAGAIN and
890+
* to give a chance to the caller to repeat request gracefully.
890891
*/
891-
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q))
892-
goto not_supported;
892+
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q)) {
893+
status = BLK_STS_AGAIN;
894+
goto end_io;
895+
}
893896

894897
if (should_fail_bio(bio))
895898
goto end_io;

0 commit comments

Comments
 (0)