From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94F397474 for ; Tue, 10 Jan 2023 18:35:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BCC7C433EF; Tue, 10 Jan 2023 18:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673375738; bh=nNA1gx6XsbCDEfaOH1VryybJE3Jxej005i1zfWGG8qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfOokXyM0uzcW1gkMv/ESZ7hu4fqnzzvJyd8pDuGOFUJluqqHwMRK80Shiqobcl1C OdQBo47sKoqBCe2TrDsX8vvSW5LjR6wH8Ft7LywM04nRx5zUTM5eHq4ijp44gtB2Fh ibGa7UvsFqzLmSKN6QcQRI0rhEOxnm5omVnwOSlM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Kelley , Keith Busch , Jens Axboe Subject: [PATCH 5.15 269/290] block: dont allow splitting of a REQ_NOWAIT bio Date: Tue, 10 Jan 2023 19:06:01 +0100 Message-Id: <20230110180041.245777002@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110180031.620810905@linuxfoundation.org> References: <20230110180031.620810905@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jens Axboe 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 Reviewed-by: Keith Busch Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-merge.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -279,6 +279,16 @@ static struct bio *blk_bio_segment_split *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; /*