All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete()
@ 2021-06-28  5:08 Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 01/14] nvmet: add common req complete for log page Chaitanya Kulkarni
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Hi,

Since the addition of the NVMeOF target time, we've added various log
page and identify command handlers where we complete the request in
those handlers. This adds 10 repeated nvmet_req_complete() calls.

This patch series removes 10 repeated calls to the nvmet_req_complete()
in for various log page and identify command handlers by completing the
request in the nvmet_execute_get_log_page() and nvmet_execute_identify().
Also, with this change we prevent future repeatation of such calls.

This also allows us to remove 8 goto labels.

I've tested this code on nvme-5.14 [1], blktests and zonefs tests seems
to pass.

-ck

Chaitanya Kulkarni (14):
  nvmet: add common req complete for log page
  nvmet: remove repeated call for error log page
  nvmet: remove repeated call for smart log page
  nvmet: remove repeated call for fw slot log page
  nvmet: remove repeated call for changed-ns log page
  nvmet: remove repeated call for effects log page
  nvmet: remove repeated call for ana log page
  nvmet: add default case for nvmet_execute_identify
  nvmet: remove repeated call for id-ctrl
  nvmet: remove repeated call for id-ns
  nvmet: remove repeated call for nslist
  nvmet: remove repeated call for desclist
  nvmet: remove repeated call for id-cns-ns
  nvmet: remove repeated call for id-cns-ctrl

 drivers/nvme/target/admin-cmd.c | 180 +++++++++++++++++---------------
 drivers/nvme/target/nvmet.h     |  12 +--
 drivers/nvme/target/zns.c       |  27 ++---
 3 files changed, 108 insertions(+), 111 deletions(-)

# ./check nvme 
nvme/002 (create many subsystems and test discovery)         [passed]
    runtime  38.825s  ...  40.506s
nvme/003 (test if we're sending keep-alives to a discovery controller) [passed]
    runtime  10.176s  ...  10.184s
nvme/004 (test nvme and nvmet UUID NS descriptors)           [passed]
    runtime  1.781s  ...  1.776s
nvme/005 (reset local loopback target)                       [passed]
    runtime  2.334s  ...  2.243s
nvme/006 (create an NVMeOF target with a block device-backed ns) [passed]
    runtime  0.155s  ...  0.149s
nvme/007 (create an NVMeOF target with a file-backed ns)     [passed]
    runtime  0.102s  ...  0.104s
nvme/008 (create an NVMeOF host with a block device-backed ns) [passed]
    runtime  1.779s  ...  1.785s
nvme/009 (create an NVMeOF host with a file-backed ns)       [passed]
    runtime  1.747s  ...  1.755s
nvme/010 (run data verification fio job on NVMeOF block device-backed ns) [passed]
    runtime  34.091s  ...  26.953s
nvme/011 (run data verification fio job on NVMeOF file-backed ns) [passed]
    runtime  288.054s  ...  320.502s
nvme/012 (run mkfs and data verification fio job on NVMeOF block device-backed ns) [passed]
    runtime  8.515s  ...  9.634s
nvme/013 (run mkfs and data verification fio job on NVMeOF file-backed ns) [passed]
    runtime  27.329s  ...  24.710s
nvme/014 (flush a NVMeOF block device-backed ns)             [passed]
    runtime  20.028s  ...  21.024s
nvme/015 (unit test for NVMe flush for file backed ns)       [passed]
    runtime  20.615s  ...  21.140s
nvme/016 (create/delete many NVMeOF block device-backed ns and test discovery) [passed]
    runtime  20.653s  ...  21.571s
nvme/017 (create/delete many file-ns and test discovery)     [passed]
    runtime  20.402s  ...  22.023s
nvme/018 (unit test NVMe-oF out of range access on a file backend) [passed]
    runtime  1.747s  ...  1.767s
nvme/019 (test NVMe DSM Discard command on NVMeOF block-device ns) [passed]
    runtime  1.771s  ...  1.805s
nvme/020 (test NVMe DSM Discard command on NVMeOF file-backed ns) [passed]
    runtime  1.735s  ...  1.739s
nvme/021 (test NVMe list command on NVMeOF file-backed ns)   [passed]
    runtime  1.764s  ...  1.752s
nvme/022 (test NVMe reset command on NVMeOF file-backed ns)  [passed]
    runtime  2.163s  ...  2.182s
nvme/023 (test NVMe smart-log command on NVMeOF block-device ns) [passed]
    runtime  1.780s  ...  1.815s
nvme/024 (test NVMe smart-log command on NVMeOF file-backed ns) [passed]
    runtime  1.739s  ...  1.750s
nvme/025 (test NVMe effects-log command on NVMeOF file-backed ns) [passed]
    runtime  1.726s  ...  1.756s
nvme/026 (test NVMe ns-descs command on NVMeOF file-backed ns) [passed]
    runtime  1.740s  ...  1.750s
nvme/027 (test NVMe ns-rescan command on NVMeOF file-backed ns) [passed]
    runtime  1.735s  ...  1.757s
nvme/028 (test NVMe list-subsys command on NVMeOF file-backed ns) [passed]
    runtime  1.738s  ...  1.751s
nvme/029 (test userspace IO via nvme-cli read/write interface) [passed]
    runtime  2.213s  ...  2.253s
nvme/030 (ensure the discovery generation counter is updated appropriately) [passed]
    runtime  0.404s  ...  0.426s
nvme/031 (test deletion of NVMeOF controllers immediately after setup) [passed]
    runtime  6.396s  ...  6.226s
nvme/038 (test deletion of NVMeOF subsystem without enabling) [passed]
    runtime  0.061s  ...  0.058s

# ./zonefs-tests.sh /dev/nvme1n1 
Gathering information on /dev/nvme1n1...
zonefs-tests on /dev/nvme1n1:
  32 zones (0 conventional zones, 32 sequential zones)
  131072 512B sectors zone size (64 MiB)
  0 max open zones
Running tests
  Test 0010:  mkzonefs (options)                                   ... PASS
  Test 0011:  mkzonefs (force format)                              ... PASS
  Test 0012:  mkzonefs (invalid device)                            ... PASS
  Test 0013:  mkzonefs (super block zone state)                    ... PASS
  Test 0020:  mount (default)                                      ... PASS
  Test 0021:  mount (invalid device)                               ... PASS
  Test 0022:  mount (check mount directory sub-directories)        ... PASS
  Test 0023:  mount (options)                                      ... PASS
  Test 0030:  Number of files (default)                            ... PASS
  Test 0031:  Number of files (aggr_cnv)                           ... skip
  Test 0032:  Number of files using stat (default)                 ... PASS
  Test 0033:  Number of files using stat (aggr_cnv)                ... PASS
  Test 0034:  Number of blocks using stat (default)                ... PASS
  Test 0035:  Number of blocks using stat (aggr_cnv)               ... PASS
  Test 0040:  Files permissions (default)                          ... PASS
  Test 0041:  Files permissions (aggr_cnv)                         ... skip
  Test 0042:  Files permissions (set value)                        ... PASS
  Test 0043:  Files permissions (set value + aggr_cnv)             ... skip
  Test 0050:  Files owner (default)                                ... PASS
  Test 0051:  Files owner (aggr_cnv)                               ... skip
  Test 0052:  Files owner (set value)                              ... PASS
  Test 0053:  Files owner (set value + aggr_cnv)                   ... skip
  Test 0060:  Files size (default)                                 ... PASS
  Test 0061:  Files size (aggr_cnv)                                ... skip
  Test 0070:  Conventional file truncate                           ... skip
  Test 0071:  Conventional file truncate (aggr_cnv)                ... skip
  Test 0072:  Conventional file unlink                             ... skip
  Test 0073:  Conventional file unlink (aggr_cnv)                  ... skip
  Test 0074:  Conventional file random write                       ... skip
  Test 0075:  Conventional file random write (direct)              ... skip
  Test 0076:  Conventional file random write (aggr_cnv)            ... skip
  Test 0077:  Conventional file random write (aggr_cnv, direct)    ... skip
  Test 0078:  Conventional file mmap read/write                    ... skip
  Test 0079:  Conventional file mmap read/write (aggr_cnv)         ... skip
  Test 0080:  Sequential file truncate                             ... PASS
  Test 0081:  Sequential file unlink                               ... PASS
  Test 0082:  Sequential file buffered write IO                    ... PASS
  Test 0083:  Sequential file overwrite                            ... PASS
  Test 0084:  Sequential file unaligned write (sync IO)            ... PASS
  Test 0085:  Sequential file unaligned write (async IO)           ... PASS
  Test 0086:  Sequential file append (sync)                        ... PASS
  Test 0087:  Sequential file append (async)                       ... PASS
  Test 0088:  Sequential file random read                          ... PASS
  Test 0089:  Sequential file mmap read/write                      ... PASS
  Test 0090:  sequential file 4K synchronous write                 ... PASS
  Test 0091:  Sequential file large synchronous write              ... PASS

-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/14] nvmet: add common req complete for log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 02/14] nvmet: remove repeated call for error " Chaitanya Kulkarni
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

For set/get features command handlers we don't complete the request in
each feature handler instead we complete the request in the original
callback i.e. in nvmet_execute_set_feature() and
nvmet_execute_get_feature(). This reduces the number of repeated
nvmet_req_complete() calls needed for each feature to complete the
request.

A similar pattern can be used for the log page handler callback and its
helpers.

In this prep patch we add a default caes for unhandled log pages and
complete the request in the nvmet_execute_get_log_page(). Next patches
will use this call for request completion so we can remove the local
call from each log page handler.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 0cb98f2bbc8c..03bfd8676456 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -314,6 +314,8 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 
 static void nvmet_execute_get_log_page(struct nvmet_req *req)
 {
+	u16 status;
+
 	if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd)))
 		return;
 
@@ -335,11 +337,13 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		return nvmet_execute_get_log_cmd_effects_ns(req);
 	case NVME_LOG_ANA:
 		return nvmet_execute_get_log_page_ana(req);
+	default:
+		pr_err("unhandled lid %d on qid %d\n",
+		       req->cmd->get_log_page.lid, req->sq->qid);
+		req->error_loc = offsetof(struct nvme_get_log_page_command, lid);
+		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 	}
-	pr_debug("unhandled lid %d on qid %d\n",
-	       req->cmd->get_log_page.lid, req->sq->qid);
-	req->error_loc = offsetof(struct nvme_get_log_page_command, lid);
-	nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR);
+	nvmet_req_complete(req, status);
 }
 
 static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/14] nvmet: remove repeated call for error log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 01/14] nvmet: add common req complete for log page Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 03/14] nvmet: remove repeated call for smart " Chaitanya Kulkarni
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_get_log_page_error() and complete the
request in nvmet_execute_get_log_page(). This reduces number of
repeated nvmet_req_complete() calls for log page handlers.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 03bfd8676456..66bb5b649ffd 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -45,7 +45,7 @@ static void nvmet_execute_get_log_page_noop(struct nvmet_req *req)
 	nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->transfer_len));
 }
 
-static void nvmet_execute_get_log_page_error(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_page_error(struct nvmet_req *req)
 {
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
 	unsigned long flags;
@@ -68,7 +68,7 @@ static void nvmet_execute_get_log_page_error(struct nvmet_req *req)
 		offset += sizeof(struct nvme_error_slot);
 	}
 	spin_unlock_irqrestore(&ctrl->error_lock, flags);
-	nvmet_req_complete(req, 0);
+	return NVME_SC_SUCCESS;
 }
 
 static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
@@ -321,7 +321,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 
 	switch (req->cmd->get_log_page.lid) {
 	case NVME_LOG_ERROR:
-		return nvmet_execute_get_log_page_error(req);
+		status = nvmet_execute_get_log_page_error(req);
+		break;
 	case NVME_LOG_SMART:
 		return nvmet_execute_get_log_page_smart(req);
 	case NVME_LOG_FW_SLOT:
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/14] nvmet: remove repeated call for smart log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 01/14] nvmet: add common req complete for log page Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 02/14] nvmet: remove repeated call for error " Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 04/14] nvmet: remove repeated call for fw slot " Chaitanya Kulkarni
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_get_log_page_smart() and complete the
request in nvmet_execute_get_log_page(). This reduces number of
repeated nvmet_req_complete() calls for log page handlers.

Also, this allows us to remove the goto out label.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 66bb5b649ffd..079fe04d0ee6 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -130,18 +130,18 @@ static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
 	return NVME_SC_SUCCESS;
 }
 
-static void nvmet_execute_get_log_page_smart(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_page_smart(struct nvmet_req *req)
 {
 	struct nvme_smart_log *log;
 	u16 status = NVME_SC_INTERNAL;
 	unsigned long flags;
 
 	if (req->transfer_len != sizeof(*log))
-		goto out;
+		return status;
 
 	log = kzalloc(sizeof(*log), GFP_KERNEL);
 	if (!log)
-		goto out;
+		return status;
 
 	if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL))
 		status = nvmet_get_smart_log_all(req, log);
@@ -158,8 +158,8 @@ static void nvmet_execute_get_log_page_smart(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
 out_free_log:
 	kfree(log);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static void nvmet_get_cmd_effects_nvm(struct nvme_effects_log *log)
@@ -324,7 +324,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		status = nvmet_execute_get_log_page_error(req);
 		break;
 	case NVME_LOG_SMART:
-		return nvmet_execute_get_log_page_smart(req);
+		status = nvmet_execute_get_log_page_smart(req);
+		break;
 	case NVME_LOG_FW_SLOT:
 		/*
 		 * We only support a single firmware slot which always is
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/14] nvmet: remove repeated call for fw slot log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 03/14] nvmet: remove repeated call for smart " Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 05/14] nvmet: remove repeated call for changed-ns " Chaitanya Kulkarni
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_get_log_page_noop() and complete the
request in nvmet_execute_get_log_page(). This reduces number of
repeated nvmet_req_complete() calls for log page handlers.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 079fe04d0ee6..8c798559f1cc 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -40,9 +40,9 @@ u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
 	return le64_to_cpu(cmd->get_log_page.lpo);
 }
 
-static void nvmet_execute_get_log_page_noop(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_page_noop(struct nvmet_req *req)
 {
-	nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->transfer_len));
+	return nvmet_zero_sgl(req, 0, req->transfer_len);
 }
 
 static u16 nvmet_execute_get_log_page_error(struct nvmet_req *req)
@@ -332,7 +332,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		 * active, so we can zero out the whole firmware slot log and
 		 * still claim to fully implement this mandatory log page.
 		 */
-		return nvmet_execute_get_log_page_noop(req);
+		status = nvmet_execute_get_log_page_noop(req);
+		break;
 	case NVME_LOG_CHANGED_NS:
 		return nvmet_execute_get_log_changed_ns(req);
 	case NVME_LOG_CMD_EFFECTS:
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/14] nvmet: remove repeated call for changed-ns log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 04/14] nvmet: remove repeated call for fw slot " Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 06/14] nvmet: remove repeated call for effects " Chaitanya Kulkarni
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_get_log_page_changed_ns() and complete
the request in nvmet_execute_get_log_page(). This reduces number of
repeated nvmet_req_complete() calls for log page handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 8c798559f1cc..2b018b84bf3f 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -221,14 +221,14 @@ static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
-static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
 {
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
 	u16 status = NVME_SC_INTERNAL;
 	size_t len;
 
 	if (req->transfer_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32))
-		goto out;
+		return status;
 
 	mutex_lock(&ctrl->lock);
 	if (ctrl->nr_changed_ns == U32_MAX)
@@ -241,8 +241,8 @@ static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
 	ctrl->nr_changed_ns = 0;
 	nvmet_clear_aen_bit(req, NVME_AEN_BIT_NS_ATTR);
 	mutex_unlock(&ctrl->lock);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid,
@@ -335,7 +335,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		status = nvmet_execute_get_log_page_noop(req);
 		break;
 	case NVME_LOG_CHANGED_NS:
-		return nvmet_execute_get_log_changed_ns(req);
+		status = nvmet_execute_get_log_changed_ns(req);
+		break;
 	case NVME_LOG_CMD_EFFECTS:
 		return nvmet_execute_get_log_cmd_effects_ns(req);
 	case NVME_LOG_ANA:
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/14] nvmet: remove repeated call for effects log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (4 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 05/14] nvmet: remove repeated call for changed-ns " Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 07/14] nvmet: remove repeated call for ana " Chaitanya Kulkarni
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_get_log_page_cmd_effects_ns() and
complete the request in nvmet_execute_get_log_page(). This reduces
number of repeated nvmet_req_complete() calls for log page
handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 2b018b84bf3f..cf02d70dedeb 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -186,16 +186,14 @@ static void nvmet_get_cmd_effects_zns(struct nvme_effects_log *log)
 	log->iocs[nvme_cmd_zone_mgmt_recv]	= cpu_to_le32(1 << 0);
 }
 
-static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req)
 {
 	struct nvme_effects_log *log;
 	u16 status = NVME_SC_SUCCESS;
 
 	log = kzalloc(sizeof(*log), GFP_KERNEL);
-	if (!log) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!log)
+		return NVME_SC_INTERNAL;
 
 	switch (req->cmd->get_log_page.csi) {
 	case NVME_CSI_NVM:
@@ -217,8 +215,8 @@ static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
 free:
 	kfree(log);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static u16 nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
@@ -338,7 +336,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		status = nvmet_execute_get_log_changed_ns(req);
 		break;
 	case NVME_LOG_CMD_EFFECTS:
-		return nvmet_execute_get_log_cmd_effects_ns(req);
+		status = nvmet_execute_get_log_cmd_effects_ns(req);
+		break;
 	case NVME_LOG_ANA:
 		return nvmet_execute_get_log_page_ana(req);
 	default:
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/14] nvmet: remove repeated call for ana log page
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (5 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 06/14] nvmet: remove repeated call for effects " Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 08/14] nvmet: add default case for nvmet_execute_identify Chaitanya Kulkarni
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_get_log_page_ana() and complete the
request in nvmet_execute_get_log_page(). This reduces number of
repeated nvmet_req_complete() calls for log page handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index cf02d70dedeb..4e58dfbfbbd5 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -265,7 +265,7 @@ static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid,
 	return sizeof(struct nvme_ana_group_desc) + count * sizeof(__le32);
 }
 
-static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 {
 	struct nvme_ana_rsp_hdr hdr = { 0, };
 	struct nvme_ana_group_desc *desc;
@@ -275,11 +275,10 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	u16 ngrps = 0;
 	u16 status;
 
-	status = NVME_SC_INTERNAL;
 	desc = kmalloc(sizeof(struct nvme_ana_group_desc) +
 			NVMET_MAX_NAMESPACES * sizeof(__le32), GFP_KERNEL);
 	if (!desc)
-		goto out;
+		return NVME_SC_INTERNAL;
 
 	down_read(&nvmet_ana_sem);
 	for (grpid = 1; grpid <= NVMET_MAX_ANAGRPS; grpid++) {
@@ -305,9 +304,9 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	kfree(desc);
 
 	/* copy the header last once we know the number of groups */
-	status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
-out:
-	nvmet_req_complete(req, status);
+	if (!status)
+		status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
+	return status;
 }
 
 static void nvmet_execute_get_log_page(struct nvmet_req *req)
@@ -339,7 +338,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		status = nvmet_execute_get_log_cmd_effects_ns(req);
 		break;
 	case NVME_LOG_ANA:
-		return nvmet_execute_get_log_page_ana(req);
+		status = nvmet_execute_get_log_page_ana(req);
+		break;
 	default:
 		pr_err("unhandled lid %d on qid %d\n",
 		       req->cmd->get_log_page.lid, req->sq->qid);
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/14] nvmet: add default case for nvmet_execute_identify
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (6 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 07/14] nvmet: remove repeated call for ana " Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 09/14] nvmet: remove repeated call for id-ctrl Chaitanya Kulkarni
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Just like on what we have done earlier in the series for the
nvmet_execute_get_log_page() repeat the same pattern for the
nvmet_execute_identify(), add a default case to print the error & move
the request completion call outside of the switch so it can be used by
all the switch cases.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 10 +++++++++-
 drivers/nvme/target/nvmet.h     |  8 --------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 4e58dfbfbbd5..28c24c08bd99 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -682,6 +682,8 @@ static bool nvmet_handle_identify_desclist(struct nvmet_req *req)
 
 static void nvmet_execute_identify(struct nvmet_req *req)
 {
+	u16 status;
+
 	if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE))
 		return;
 
@@ -732,9 +734,15 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 		if (nvmet_handle_identify_desclist(req) == true)
 			return;
 		break;
+	default:
+		pr_debug("unhandled identify cns %d on qid %d\n",
+			 req->cmd->identify.cns, req->sq->qid);
+		req->error_loc = offsetof(struct nvme_identify, cns);
+		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+		break;
 	}
 
-	nvmet_req_cns_error_complete(req);
+	nvmet_req_complete(req, status);
 }
 
 /*
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index d719a1cd5dda..2119abc2a9b9 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -645,14 +645,6 @@ static inline bool nvmet_use_inline_bvec(struct nvmet_req *req)
 	       req->sg_cnt <= NVMET_MAX_INLINE_BIOVEC;
 }
 
-static inline void nvmet_req_cns_error_complete(struct nvmet_req *req)
-{
-	pr_debug("unhandled identify cns %d on qid %d\n",
-	       req->cmd->identify.cns, req->sq->qid);
-	req->error_loc = offsetof(struct nvme_identify, cns);
-	nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR);
-}
-
 static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
 {
 	if (bio != &req->b.inline_bio)
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/14] nvmet: remove repeated call for id-ctrl
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (7 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 08/14] nvmet: add default case for nvmet_execute_identify Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 10/14] nvmet: remove repeated call for id-ns Chaitanya Kulkarni
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_identidy_ctrl() and complete request
in nvmet_execute_identify(). This reduces number of repeated
 nvmet_req_complete() calls for log page handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 28c24c08bd99..4f88276e0c48 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -349,7 +349,7 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
-static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
+static u16 nvmet_execute_identify_ctrl(struct nvmet_req *req)
 {
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
 	struct nvmet_subsys *subsys = ctrl->subsys;
@@ -364,10 +364,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	}
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
-	if (!id) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id)
+		return NVME_SC_INTERNAL;
 
 	/* XXX: figure out how to assign real vendors IDs. */
 	id->vid = 0;
@@ -484,8 +482,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
 
 	kfree(id);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static void nvmet_execute_identify_ns(struct nvmet_req *req)
@@ -709,7 +707,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 	case NVME_ID_CNS_CTRL:
 		switch (req->cmd->identify.csi) {
 		case NVME_CSI_NVM:
-			return nvmet_execute_identify_ctrl(req);
+			status = nvmet_execute_identify_ctrl(req);
+			break;
 		}
 		break;
 	case NVME_ID_CNS_CS_CTRL:
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/14] nvmet: remove repeated call for id-ns
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (8 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 09/14] nvmet: remove repeated call for id-ctrl Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 11/14] nvmet: remove repeated call for nslist Chaitanya Kulkarni
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_identidy_ns() and complete the request
in nvmet_execute_identify(). This reduces number of repeated
nvmet_req_complete() calls for identify handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 4f88276e0c48..e625a33d0861 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -486,22 +486,20 @@ static u16 nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	return status;
 }
 
-static void nvmet_execute_identify_ns(struct nvmet_req *req)
+static u16 nvmet_execute_identify_ns(struct nvmet_req *req)
 {
 	struct nvme_id_ns *id;
 	u16 status;
 
 	if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
 		req->error_loc = offsetof(struct nvme_identify, nsid);
-		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
-		goto out;
+		return NVME_SC_INVALID_NS | NVME_SC_DNR;
 	}
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
-	if (!id) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id)
+		return NVME_SC_INTERNAL;
+
 
 	/* return an all zeroed buffer if we can't find an active namespace */
 	status = nvmet_req_find_ns(req);
@@ -565,8 +563,8 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
 		status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
 
 	kfree(id);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static void nvmet_execute_identify_nslist(struct nvmet_req *req)
@@ -689,7 +687,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 	case NVME_ID_CNS_NS:
 		switch (req->cmd->identify.csi) {
 		case NVME_CSI_NVM:
-			return nvmet_execute_identify_ns(req);
+			status = nvmet_execute_identify_ns(req);
+			break;
 		default:
 			break;
 		}
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/14] nvmet: remove repeated call for nslist
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (9 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 10/14] nvmet: remove repeated call for id-ns Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 12/14] nvmet: remove repeated call for desclist Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_identidy_nslist() and complete the
request in nvmet_execute_identify(). This reduces number of repeated
nvmet_req_complete() calls for identify handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index e625a33d0861..749d7e695fa2 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -567,7 +567,7 @@ static u16 nvmet_execute_identify_ns(struct nvmet_req *req)
 	return status;
 }
 
-static void nvmet_execute_identify_nslist(struct nvmet_req *req)
+static u16 nvmet_execute_identify_nslist(struct nvmet_req *req)
 {
 	static const int buf_size = NVME_IDENTIFY_DATA_SIZE;
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -575,14 +575,12 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	unsigned long idx;
 	u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid);
 	__le32 *list;
-	u16 status = 0;
+	u16 status;
 	int i = 0;
 
 	list = kzalloc(buf_size, GFP_KERNEL);
-	if (!list) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!list)
+		return NVME_SC_INTERNAL;
 
 	xa_for_each(&ctrl->subsys->namespaces, idx, ns) {
 		if (ns->nsid <= min_nsid)
@@ -595,8 +593,8 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, list, buf_size);
 
 	kfree(list);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
@@ -723,7 +721,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 	case NVME_ID_CNS_NS_ACTIVE_LIST:
 		switch (req->cmd->identify.csi) {
 		case NVME_CSI_NVM:
-			return nvmet_execute_identify_nslist(req);
+			status = nvmet_execute_identify_nslist(req);
+			break;
 		default:
 			break;
 		}
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 12/14] nvmet: remove repeated call for desclist
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (10 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 11/14] nvmet: remove repeated call for nslist Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 13/14] nvmet: remove repeated call for id-cns-ns Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_identidy_desclist() and complete
the request in nvmet_execute_identify(). This reduces number of
repeated nvmet_req_complete() calls for identify handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 749d7e695fa2..02d28158e9f0 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -619,58 +619,54 @@ static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
 	return 0;
 }
 
-static void nvmet_execute_identify_desclist(struct nvmet_req *req)
+static u16 nvmet_execute_identify_desclist(struct nvmet_req *req)
 {
 	off_t off = 0;
 	u16 status;
 
 	status = nvmet_req_find_ns(req);
 	if (status)
-		goto out;
+		return status;
 
 	if (memchr_inv(&req->ns->uuid, 0, sizeof(req->ns->uuid))) {
 		status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID,
 						  NVME_NIDT_UUID_LEN,
 						  &req->ns->uuid, &off);
 		if (status)
-			goto out;
+			return status;
 	}
 	if (memchr_inv(req->ns->nguid, 0, sizeof(req->ns->nguid))) {
 		status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID,
 						  NVME_NIDT_NGUID_LEN,
 						  &req->ns->nguid, &off);
 		if (status)
-			goto out;
+			return status;
 	}
 
 	status = nvmet_copy_ns_identifier(req, NVME_NIDT_CSI,
 					  NVME_NIDT_CSI_LEN,
 					  &req->ns->csi, &off);
 	if (status)
-		goto out;
+		return status;
 
 	if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off,
 			off) != NVME_IDENTIFY_DATA_SIZE - off)
-		status = NVME_SC_INTERNAL | NVME_SC_DNR;
+		return NVME_SC_INTERNAL | NVME_SC_DNR;
 
-out:
-	nvmet_req_complete(req, status);
+	return status;
 }
 
-static bool nvmet_handle_identify_desclist(struct nvmet_req *req)
+static u16 nvmet_handle_identify_desclist(struct nvmet_req *req)
 {
 	switch (req->cmd->identify.csi) {
 	case NVME_CSI_NVM:
-		nvmet_execute_identify_desclist(req);
-		return true;
+		return nvmet_execute_identify_desclist(req);
 	case NVME_CSI_ZNS:
-		if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
-			nvmet_execute_identify_desclist(req);
-			return true;
-		}
-		return false;
+		if (IS_ENABLED(CONFIG_BLK_DEV_ZONED))
+			return nvmet_execute_identify_desclist(req);
+		return NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 	default:
-		return false;
+		return NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 	}
 }
 
@@ -728,8 +724,7 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 		}
 		break;
 	case NVME_ID_CNS_NS_DESC_LIST:
-		if (nvmet_handle_identify_desclist(req) == true)
-			return;
+		status = nvmet_handle_identify_desclist(req);
 		break;
 	default:
 		pr_debug("unhandled identify cns %d on qid %d\n",
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 13/14] nvmet: remove repeated call for id-cns-ns
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (11 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 12/14] nvmet: remove repeated call for desclist Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-06-28  5:08 ` [PATCH 14/14] nvmet: remove repeated call for id-cns-ctrl Chaitanya Kulkarni
  2021-07-16  7:36 ` [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Christoph Hellwig
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_identify_cns_cs_ns() and complete the
request in nvmet_execute_identify(). This reduces number of repeated
nvmet_req_complete() calls for identify handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c |  3 ++-
 drivers/nvme/target/nvmet.h     |  2 +-
 drivers/nvme/target/zns.c       | 15 ++++++---------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 02d28158e9f0..ef6982beb6b0 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -691,7 +691,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 		if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
 			switch (req->cmd->identify.csi) {
 			case NVME_CSI_ZNS:
-				return nvmet_execute_identify_cns_cs_ns(req);
+				status = nvmet_execute_identify_cns_cs_ns(req);
+				break;
 			default:
 				break;
 			}
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 2119abc2a9b9..f1c9cd445c74 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -546,7 +546,7 @@ u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts);
 
 bool nvmet_bdev_zns_enable(struct nvmet_ns *ns);
 void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req);
-void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req);
+u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_append(struct nvmet_req *req);
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 17f8b7a45f21..2e1f01ec0dd1 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -96,7 +96,7 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
-void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
+u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
 {
 	struct nvme_id_ns_zns *id_zns;
 	u64 zsze;
@@ -104,15 +104,12 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
 
 	if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
 		req->error_loc = offsetof(struct nvme_identify, nsid);
-		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
-		goto out;
+		return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
 	}
 
 	id_zns = kzalloc(sizeof(*id_zns), GFP_KERNEL);
-	if (!id_zns) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id_zns)
+		return NVME_SC_INTERNAL;
 
 	status = nvmet_req_find_ns(req);
 	if (status) {
@@ -136,8 +133,8 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
 done:
 	status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns));
 	kfree(id_zns);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static u16 nvmet_bdev_validate_zone_mgmt_recv(struct nvmet_req *req)
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 14/14] nvmet: remove repeated call for id-cns-ctrl
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (12 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 13/14] nvmet: remove repeated call for id-cns-ns Chaitanya Kulkarni
@ 2021-06-28  5:08 ` Chaitanya Kulkarni
  2021-07-16  7:36 ` [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Christoph Hellwig
  14 siblings, 0 replies; 16+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-28  5:08 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi, Chaitanya Kulkarni

Return status from nvmet_execute_identify_cns_cs_ctrl() and complete
the request in nvmet_execute_identify(). This reduces number of
repeated nvmet_req_complete() calls for identify handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c |  4 +++-
 drivers/nvme/target/nvmet.h     |  2 +-
 drivers/nvme/target/zns.c       | 12 +++++-------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index ef6982beb6b0..1a8ca93b6bb9 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -709,7 +709,9 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 		if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
 			switch (req->cmd->identify.csi) {
 			case NVME_CSI_ZNS:
-				return nvmet_execute_identify_cns_cs_ctrl(req);
+				status =
+				nvmet_execute_identify_cns_cs_ctrl(req);
+				break;
 			default:
 				break;
 			}
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index f1c9cd445c74..b2eeb296cc37 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -545,7 +545,7 @@ void nvmet_ns_revalidate(struct nvmet_ns *ns);
 u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts);
 
 bool nvmet_bdev_zns_enable(struct nvmet_ns *ns);
-void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req);
+u16 nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req);
 u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req);
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 2e1f01ec0dd1..28a1de2e0fbf 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -71,7 +71,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
 	return true;
 }
 
-void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
+u16 nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 {
 	u8 zasl = req->sq->ctrl->subsys->zasl;
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -79,10 +79,8 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 	u16 status;
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
-	if (!id) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id)
+		return NVME_SC_INTERNAL;
 
 	if (ctrl->ops->get_mdts)
 		id->zasl = min_t(u8, ctrl->ops->get_mdts(ctrl), zasl);
@@ -92,8 +90,8 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
 
 	kfree(id);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete()
  2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
                   ` (13 preceding siblings ...)
  2021-06-28  5:08 ` [PATCH 14/14] nvmet: remove repeated call for id-cns-ctrl Chaitanya Kulkarni
@ 2021-07-16  7:36 ` Christoph Hellwig
  14 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2021-07-16  7:36 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: linux-nvme, hch, sagi

So while this looks fine, I'm not sure what problem this actually
solves.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-07-16  7:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28  5:08 [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 01/14] nvmet: add common req complete for log page Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 02/14] nvmet: remove repeated call for error " Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 03/14] nvmet: remove repeated call for smart " Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 04/14] nvmet: remove repeated call for fw slot " Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 05/14] nvmet: remove repeated call for changed-ns " Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 06/14] nvmet: remove repeated call for effects " Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 07/14] nvmet: remove repeated call for ana " Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 08/14] nvmet: add default case for nvmet_execute_identify Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 09/14] nvmet: remove repeated call for id-ctrl Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 10/14] nvmet: remove repeated call for id-ns Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 11/14] nvmet: remove repeated call for nslist Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 12/14] nvmet: remove repeated call for desclist Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 13/14] nvmet: remove repeated call for id-cns-ns Chaitanya Kulkarni
2021-06-28  5:08 ` [PATCH 14/14] nvmet: remove repeated call for id-cns-ctrl Chaitanya Kulkarni
2021-07-16  7:36 ` [PATCH 00/14] nvmet: remove repeated calls to nvmet_req_complete() Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.