summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-01-04 08:52:06 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-12 12:00:46 +0100
commit3c09dbaf6ea1a027bfe31d6764be5012d21f297b (patch)
treecf387bb35c443bf8e2d782184cf648a34977b7cc
parent34a91a47e0794df64cfa928dc768acf5379452fb (diff)
downloadlinux-stable-3c09dbaf6ea1a027bfe31d6764be5012d21f297b.tar.gz
linux-stable-3c09dbaf6ea1a027bfe31d6764be5012d21f297b.zip
block: don't allow splitting of a REQ_NOWAIT bio
commit 9cea62b2cbabff8ed46f2df17778b624ad9dd25a upstream. If we split a bio marked with REQ_NOWAIT, then we can trigger spurious EAGAIN if constituent parts of that split bio end up failing request allocations. Parts will complete just fine, but just a single failure in one of the chained bios will yield an EAGAIN final result for the parent bio. Return EAGAIN early if we end up needing to split such a bio, which allows for saner recovery handling. Cc: stable@vger.kernel.org # 5.15+ Link: https://github.com/axboe/liburing/issues/766 Reported-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--block/blk-merge.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index ff04e9290715..f46c87ef951d 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -300,6 +300,16 @@ static struct bio *bio_split_rw(struct bio *bio, struct queue_limits *lim,
*segs = nsegs;
return NULL;
split:
+ /*
+ * We can't sanely support splitting for a REQ_NOWAIT bio. End it
+ * with EAGAIN if splitting is required and return an error pointer.
+ */
+ if (bio->bi_opf & REQ_NOWAIT) {
+ bio->bi_status = BLK_STS_AGAIN;
+ bio_endio(bio);
+ return ERR_PTR(-EAGAIN);
+ }
+
*segs = nsegs;
/*