Daniel Wagner dc4b08
From: Christoph Hellwig <hch@lst.de>
Daniel Wagner dc4b08
Date: Wed, 21 Dec 2022 09:51:19 +0100
Daniel Wagner dc4b08
Subject: nvmet: don't defer passthrough commands with trivial effects to the
Daniel Wagner dc4b08
 workqueue
Daniel Wagner dc4b08
Patch-mainline: v6.2-rc2
Daniel Wagner dc4b08
Git-commit: 2a459f6933e1c459bffb7cc73fd6c900edc714bd
Daniel Wagner dc4b08
References: git-fixes
Daniel Wagner dc4b08
Daniel Wagner dc4b08
Mask out the "Command Supported" and "Logical Block Content Change" bits
Daniel Wagner dc4b08
and only defer execution of commands that have non-trivial effects to
Daniel Wagner dc4b08
the workqueue for synchronous execution.  This allows to execute admin
Daniel Wagner dc4b08
commands asynchronously on controllers that provide a Command Supported
Daniel Wagner dc4b08
and Effects log page, and will keep allowing to execute Write commands
Daniel Wagner dc4b08
asynchronously once command effects on I/O commands are taken into
Daniel Wagner dc4b08
account.
Daniel Wagner dc4b08
Daniel Wagner dc4b08
Fixes: c1fef73f793b ("nvmet: add passthru code to process commands")
Daniel Wagner dc4b08
Signed-off-by: Christoph Hellwig <hch@lst.de>
Daniel Wagner dc4b08
Reviewed-by: Keith Busch <kbusch@kernel.org>
Daniel Wagner dc4b08
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Daniel Wagner dc4b08
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Daniel Wagner dc4b08
Acked-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner dc4b08
---
Daniel Wagner 2e99a5
 drivers/nvme/target/passthru.c |   11 +++++------
Daniel Wagner 2e99a5
 1 file changed, 5 insertions(+), 6 deletions(-)
Daniel Wagner dc4b08
Daniel Wagner dc4b08
--- a/drivers/nvme/target/passthru.c
Daniel Wagner dc4b08
+++ b/drivers/nvme/target/passthru.c
Daniel Wagner dc4b08
@@ -271,14 +271,13 @@ static void nvmet_passthru_execute_cmd(s
Daniel Wagner dc4b08
 	}
Daniel Wagner dc4b08
 
Daniel Wagner dc4b08
 	/*
Daniel Wagner dc4b08
-	 * If there are effects for the command we are about to execute, or
Daniel Wagner dc4b08
-	 * an end_req function we need to use nvme_execute_passthru_rq()
Daniel Wagner dc4b08
-	 * synchronously in a work item seeing the end_req function and
Daniel Wagner dc4b08
-	 * nvme_passthru_end() can't be called in the request done callback
Daniel Wagner dc4b08
-	 * which is typically in interrupt context.
Daniel Wagner dc4b08
+	 * If a command needs post-execution fixups, or there are any
Daniel Wagner dc4b08
+	 * non-trivial effects, make sure to execute the command synchronously
Daniel Wagner dc4b08
+	 * in a workqueue so that nvme_passthru_end gets called.
Daniel Wagner 2e99a5
 	 */
Daniel Wagner dc4b08
 	effects = nvme_command_effects(ctrl, ns, req->cmd->common.opcode);
Daniel Wagner dc4b08
-	if (req->p.use_workqueue || effects) {
Daniel Wagner dc4b08
+	if (req->p.use_workqueue ||
Daniel Wagner dc4b08
+	    (effects & ~(NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC))) {
Daniel Wagner dc4b08
 		INIT_WORK(&req->p.work, nvmet_passthru_execute_cmd_work);
Daniel Wagner dc4b08
 		req->p.rq = rq;
Daniel Wagner 2e99a5
 		queue_work(nvmet_wq, &req->p.work);