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 483D51F8BA5; Wed, 19 Feb 2025 08:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739954838; cv=none; b=bxU8mNzECldCwQnoBf3zbEWkHPSqQFtCkl9vdZ4CFFTTraHB8tmvDzzOn11Oi1wHZDIZX5jkmuvS2QlBnYFTXbRyDG8dRjM8aa7VlqGfL4ww5Xi6eF7T2KSb2OIoihatV4W76mJwsEzgVUrx29JRxODwBsRnFtZwI3i6wGWX1Fg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739954838; c=relaxed/simple; bh=2Iud9zXa8K/DOqNcIidakJ2a/FGaK59UnvVXWNEXwZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxQNiMiPZ+PprEBkwLtM1pXEAdCelBAJGH4bgl9Pu4gzXnk6Nrlsl/ibsSJF7BXY5OmzbtjWZbAzhM6mXZOAHfZNTC+qg9IS/u8Mb/mqHXcN+jPT6XTOLH+tyoTHIACLfaCYOS4se1jZF8qpATae76KNarAX52ugnay+WHtf9zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YpvCL6v9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="YpvCL6v9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCEF3C4CED1; Wed, 19 Feb 2025 08:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739954838; bh=2Iud9zXa8K/DOqNcIidakJ2a/FGaK59UnvVXWNEXwZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YpvCL6v9ejo8S+M6J1c2i99IG+ADEoDlLZHZgsPjQCj4dykHmRgjn8jZq9IAC+zNz EWPHs9Nmr2j5KVoMBjRBFNMRMeK/qta/dbvtt+ycBfgSFSABD95pU7l2O9mjdr46ZM 4aM+u+3cjq1lBgCgj2bQnWtMf7pMPMiAEhLPjh94= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jens Axboe , Sasha Levin Subject: [PATCH 6.12 052/230] block: cleanup and fix batch completion adding conditions Date: Wed, 19 Feb 2025 09:26:09 +0100 Message-ID: <20250219082603.745084626@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250219082601.683263930@linuxfoundation.org> References: <20250219082601.683263930@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jens Axboe [ Upstream commit 1f47ed294a2bd577d5ae43e6e28e1c9a3be4a833 ] The conditions for whether or not a request is allowed adding to a completion batch are a bit hard to read, and they also have a few issues. One is that ioerror may indeed be a random value on passthrough, and it's being checked unconditionally of whether or not the given request is a passthrough request or not. Rewrite the conditions to be separate for easier reading, and only check ioerror for non-passthrough requests. This fixes an issue with bio unmapping on passthrough, where it fails getting added to a batch. This both leads to suboptimal performance, and may trigger a potential schedule-under-atomic condition for polled passthrough IO. Fixes: f794f3351f26 ("block: add support for blk_mq_end_request_batch()") Link: https://lore.kernel.org/r/20575f0a-656e-4bb3-9d82-dec6c7e3a35c@kernel.dk Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- include/linux/blk-mq.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index c5063e0a38a05..a53cbe2569104 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -880,12 +880,22 @@ static inline bool blk_mq_add_to_batch(struct request *req, void (*complete)(struct io_comp_batch *)) { /* - * blk_mq_end_request_batch() can't end request allocated from - * sched tags + * Check various conditions that exclude batch processing: + * 1) No batch container + * 2) Has scheduler data attached + * 3) Not a passthrough request and end_io set + * 4) Not a passthrough request and an ioerror */ - if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror || - (req->end_io && !blk_rq_is_passthrough(req))) + if (!iob) return false; + if (req->rq_flags & RQF_SCHED_TAGS) + return false; + if (!blk_rq_is_passthrough(req)) { + if (req->end_io) + return false; + if (ioerror < 0) + return false; + } if (!iob->complete) iob->complete = complete; -- 2.39.5