Skip to content

Commit b7b9bc9

Browse files
axboegregkh
authored andcommitted
block: don't allow splitting of a REQ_NOWAIT bio
commit 9cea62b 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: axboe/liburing#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>
1 parent e1358c8 commit b7b9bc9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

block/blk-merge.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
279279
*segs = nsegs;
280280
return NULL;
281281
split:
282+
/*
283+
* We can't sanely support splitting for a REQ_NOWAIT bio. End it
284+
* with EAGAIN if splitting is required and return an error pointer.
285+
*/
286+
if (bio->bi_opf & REQ_NOWAIT) {
287+
bio->bi_status = BLK_STS_AGAIN;
288+
bio_endio(bio);
289+
return ERR_PTR(-EAGAIN);
290+
}
291+
282292
*segs = nsegs;
283293

284294
/*

0 commit comments

Comments
 (0)