Skip to contentSkip to conversation

nvmet: Add support for HOST_ID feature.

PATCH Superseded Omri Mann 3 participants 3 messages Aug 29, 2017 – Aug 30, 2017

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Omri Mann

author
#0 lore raw

PATCH v3 1/1 nvmet: Add support for HOST_ID feature.

Add hostid feature to NVMeoF targets. This will be required in order to support reservations.
Signed-off-by: Omri Mann <omri at excelero.com>

---
 drivers/nvme/target/admin-cmd.c   | 10 ++++++++++
 drivers/nvme/target/fabrics-cmd.c |  1 +
 drivers/nvme/target/nvmet.h       |  2 ++
 3 files changed, 13 insertions(+)
drivers/nvme/target/admin-cmd.c +10 -0
index a53bb66..b98ec5e 100644
@@ -461,6 +461,9 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 		req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000);
 		nvmet_set_result(req, req->sq->ctrl->kato);
 		break;
+	case NVME_FEAT_HOST_ID:
+		status = NVME_SC_CMD_SEQ_ERROR | NVME_SC_DNR;
+		break;
 	default:
 		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		break;
@@ -509,6 +512,13 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
 	case NVME_FEAT_KATO:
 		nvmet_set_result(req, req->sq->ctrl->kato * 1000);
 		break;
+	case NVME_FEAT_HOST_ID:
+		if (!(le32_to_cpu(req->cmd->common.cdw10[1]) & 1))
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+		else
+			status = nvmet_copy_to_sgl(req, 0,
+					&req->sq->ctrl->hostid, 16);
+		break;
 	default:
 		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		break;
drivers/nvme/target/fabrics-cmd.c +1 -0
index 3cc1726..859a667 100644
@@ -154,6 +154,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
 				  le32_to_cpu(c->kato), &ctrl);
 	if (status)
 		goto out;
+	uuid_copy(&ctrl->hostid, &d->hostid);
 
 	status = nvmet_install_queue(ctrl, req);
 	if (status) {
drivers/nvme/target/nvmet.h +2 -0
index e3b244c..ae7c6b7 100644
@@ -110,6 +110,8 @@ struct nvmet_ctrl {
 	struct nvmet_cq		**cqs;
 	struct nvmet_sq		**sqs;
 
+	uuid_t			hostid;
+
 	struct mutex		lock;
 	u64			cap;
 	u32			cc;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v3 1/1 nvmet: Add support for HOST_ID feature.

drivers/nvme/target/admin-cmd.c static void nvmet_execute_get_features(struct nvmet_req *req) · line 521

Quoted 7 lines
drivers/nvme/target/admin-cmd.c +7 -0
+	case NVME_FEAT_HOST_ID:
+		if (!(le32_to_cpu(req->cmd->common.cdw10[1]) & 1))
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+		else
+			status = nvmet_copy_to_sgl(req, 0,
+					&req->sq->ctrl->hostid, 16);
+		break;

The 16 here should be a sizeof(uuid_t) or sizeof(req->sq->ctrl->hostid), but we can fix this up when applying the patch.

Looks good,

Reviewed-by Christoph Hellwig <hch at lst.de>
maintainer
#2 lore raw

PATCH v3 1/1 nvmet: Add support for HOST_ID feature.

Reviewed-by Sagi Grimberg <sagi at grimberg.me>