Skip to contentSkip to conversation

nvmf: fix the return error code of target if host is not allowed

PATCH New Guan Junxiong 3 participants 6 messages May 2, 2017 – May 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nvmf: fix the return error code of target if host is not allowed

nvmf target shall return NVME_SC_CONNECT_INVALID_HOST instead of the gereal code INVALID_PARAM when the given host nqn is not allowed to connect. Refer to the 2.2.1 section of the NVMe over Fabrics Spec.

---
 drivers/nvme/target/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/target/core.c +1 -0
index fc5ba2f9..e6c5a47f 100644
@@ -713,6 +713,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
 			hostnqn, subsysnqn);
 		req->rsp->result.u32 = IPO_IATTR_CONNECT_DATA(hostnqn);
 		up_read(&nvmet_config_sem);
+		status = NVME_SC_CONNECT_INVALID_HOST | NVME_SC_DNR;
 		goto out_put_subsystem;
 	}
 	up_read(&nvmet_config_sem);
Signature · 1 line
2.11.1
#1 lore raw

PATCH 2/2 nvmf: keep track of nvmet connect error status

To let the host know what happends to the connection establishment, adjust the behavior of nvmf_log_connect_error to make more connect specifig error codes human-readble.

---
 drivers/nvme/host/fabrics.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/nvme/host/fabrics.c +18 -0
index 916d1360..1f315987 100644
@@ -337,6 +337,24 @@ static void nvmf_log_connect_error(struct nvme_ctrl *ctrl,
 			}
 		}
 		break;
+
+	case NVME_SC_CONNECT_INVALID_HOST:
+		dev_err(ctrl->device,
+				"Connect for subsystem %s is not allowed, hostnqn : %s\n",
+				data->subsysnqn, data->hostnqn);
+		break;
+
+	case NVME_SC_CONNECT_CTRL_BUSY:
+		dev_err(ctrl->device,
+				"Connect command failed : controller is busy or not available\n");
+		break;
+
+	case NVME_SC_CONNECT_FORMAT:
+		dev_err(ctrl->device,
+				"Connect incompatible format : %d",
+				cmd->connect.recfmt);
+		break;
+
 	default:
 		dev_err(ctrl->device,
 			"Connect command failed, error wo/DNR bit: %d\n",
Signature · 1 line
2.11.1
#2 lore raw

PATCH 2/2 nvmf: keep track of nvmet connect error status

Quoted 3 lines · Guan Junxiong

To let the host know what happends to the connection establishment, adjust the behavior of nvmf_log_connect_error to make more connect specifig error codes human-readble.

Looks fine (module a few indentation issue that can easily be fixed up when applying).

Looks fine:

Reviewed-by Christoph Hellwig <hch at lst.de>