Blob Blame History Raw
From 56f99b8d06ef1ed1c9730948f9f05ac2b930a20b Mon Sep 17 00:00:00 2001
From: Stefan Roesch <shr@fb.com>
Date: Mon, 12 Sep 2022 09:53:25 -0700
Subject: [PATCH] block: blk_queue_enter() / __bio_queue_enter() must return
 -EAGAIN for nowait
Git-commit: 56f99b8d06ef1ed1c9730948f9f05ac2b930a20b
Patch-mainline: v6.0-rc6
References: git-fixes

Today blk_queue_enter() and __bio_queue_enter() return -EBUSY for the
nowait code path. This is not correct: they should return -EAGAIN
instead.

This problem was detected by fio. The following command exposed the
above problem:

t/io_uring -p0 -d128 -b4096 -s32 -c32 -F1 -B0 -R0 -X1 -n24 -P1 -u1 -O0 /dev/ng0n1

By applying the patch, the retry case is handled correctly in the slow
path.

(Coly Li: rebased for Linux v4.12 based SUSE kernel, remove changes in
 __bio_queue_enter() because the caller bio_queue_enter() doesn't exist
 yet)

Signed-off-by: Stefan Roesch <shr@fb.com>
Fixes: bfd343aa1718 ("blk-mq: don't wait in blk_mq_queue_enter() if __GFP_WAIT isn't set")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Coly Li <colyli@suse.de>

---
 block/blk-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -954,7 +954,7 @@ int blk_queue_enter(struct request_queue
 			return 0;
 
 		if (flags & BLK_MQ_REQ_NOWAIT)
-			return -EBUSY;
+			return -EAGAIN;
 
 		/*
 		 * read pair of barrier in blk_freeze_queue_start(),