block: end bio with BLK_STS_AGAIN in case of non-mq devs and REQ_NOWAIT
authorRoman Penyaev <rpenyaev@suse.de>
Tue, 17 Dec 2019 15:54:07 +0000 (16:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Jan 2020 11:21:37 +0000 (12:21 +0100)
commit2ac95310fe5896cae413e4ae06b3af21645979d9
tree0dcce3e22f611b8ad6e6f6a3ef6baa97706a9de1
parente36491f117d1b5a439e1c347bded57844650dab5
block: end bio with BLK_STS_AGAIN in case of non-mq devs and REQ_NOWAIT

[ Upstream commit c58c1f83436b501d45d4050fd1296d71a9760bcb ]

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 <rpenyaev@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-core.c