[PATCH libnvme] libnvme: Add disallow_pi to connect cmd

Max Gurtovoy mgurtovoy at nvidia.com
Mon Jan 22 07:33:41 PST 2024


From: Israel Rukshin <israelr at nvidia.com>

Add 'disallow_pi' to 'connect' command, so users can disallow
metadata support to save resources.

Signed-off-by: Israel Rukshin <israelr at nvidia.com>
Reviewed-by: Max Gurtovoy <mgurtovoy at nvidia.com>
---

This patch is complementary to NVMe Kernel series:
"Enforce uniform metadata settings for ns head"

---
 libnvme/nvme.i     | 4 ++++
 src/nvme/fabrics.c | 8 +++++++-
 src/nvme/fabrics.h | 2 ++
 src/nvme/json.c    | 4 ++++
 src/nvme/private.h | 1 +
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/libnvme/nvme.i b/libnvme/nvme.i
index eb94cac..7945971 100644
--- a/libnvme/nvme.i
+++ b/libnvme/nvme.i
@@ -199,6 +199,10 @@ PyObject *hostid_from_file();
 			temp.data_digest = PyObject_IsTrue(value) ? true : false;
 			continue;
 		}
+		if (!PyUnicode_CompareWithASCIIString(key, "disallow_pi")) {
+			temp.disallow_pi = PyObject_IsTrue(value) ? true : false;
+			continue;
+		}
 	}
 	$1 = &temp;
 };
diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c
index 4e042d8..d666b39 100644
--- a/src/nvme/fabrics.c
+++ b/src/nvme/fabrics.c
@@ -204,6 +204,7 @@ static const struct nvme_fabric_options default_supported_options = {
 	.ctrl_loss_tmo = true,
 	.data_digest = true,
 	.disable_sqflow = true,
+	.disallow_pi = true,
 	.discovery = true,
 	.duplicate_connect = true,
 	.fast_io_fail_tmo = true,
@@ -260,6 +261,7 @@ static struct nvme_fabrics_config *merge_config(nvme_ctrl_t c,
 	MERGE_CFG_OPTION(ctrl_cfg, cfg, hdr_digest, false);
 	MERGE_CFG_OPTION(ctrl_cfg, cfg, data_digest, false);
 	MERGE_CFG_OPTION(ctrl_cfg, cfg, tls, false);
+	MERGE_CFG_OPTION(ctrl_cfg, cfg, disallow_pi, false);
 
 	return ctrl_cfg;
 }
@@ -289,6 +291,7 @@ void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg)
 	UPDATE_CFG_OPTION(ctrl_cfg, cfg, hdr_digest, false);
 	UPDATE_CFG_OPTION(ctrl_cfg, cfg, data_digest, false);
 	UPDATE_CFG_OPTION(ctrl_cfg, cfg, tls, false);
+	UPDATE_CFG_OPTION(ctrl_cfg, cfg, disallow_pi, false);
 }
 
 static int __add_bool_argument(char **argstr, char *tok, bool arg)
@@ -637,7 +640,9 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)
 	    (!strcmp(transport, "tcp") &&
 	     add_bool_argument(r, argstr, data_digest, cfg->data_digest)) ||
 	    (!strcmp(transport, "tcp") &&
-	     add_bool_argument(r, argstr, tls, cfg->tls))) {
+	     add_bool_argument(r, argstr, tls, cfg->tls)) ||
+	    (!strcmp(transport, "rdma") &&
+	     add_bool_argument(r, argstr, disallow_pi, cfg->disallow_pi))) {
 		free(*argstr);
 		return -1;
 	}
@@ -710,6 +715,7 @@ static  int __nvmf_supported_options(nvme_root_t r)
 		parse_option(r, v, dhchap_ctrl_secret);
 		parse_option(r, v, dhchap_secret);
 		parse_option(r, v, disable_sqflow);
+		parse_option(r, v, disallow_pi);
 		parse_option(r, v, discovery);
 		parse_option(r, v, duplicate_connect);
 		parse_option(r, v, fast_io_fail_tmo);
diff --git a/src/nvme/fabrics.h b/src/nvme/fabrics.h
index 3664a85..a6518df 100644
--- a/src/nvme/fabrics.h
+++ b/src/nvme/fabrics.h
@@ -42,6 +42,7 @@
  * @hdr_digest:		Generate/verify header digest (TCP)
  * @data_digest:	Generate/verify data digest (TCP)
  * @tls:		Start TLS on the connection (TCP)
+ * @disallow_pi:	Disallow metadata (T10-PI) offload support
  */
 struct nvme_fabrics_config {
 	char *host_traddr;
@@ -63,6 +64,7 @@ struct nvme_fabrics_config {
 	bool hdr_digest;
 	bool data_digest;
 	bool tls;
+	bool disallow_pi;
 };
 
 /**
diff --git a/src/nvme/json.c b/src/nvme/json.c
index 4d0f987..bfffd49 100644
--- a/src/nvme/json.c
+++ b/src/nvme/json.c
@@ -60,6 +60,8 @@ static void json_update_attributes(nvme_ctrl_t c,
 					data_digest, val_obj);
 		JSON_UPDATE_BOOL_OPTION(cfg, key_str,
 					tls, val_obj);
+		JSON_UPDATE_BOOL_OPTION(cfg, key_str,
+					disallow_pi, val_obj);
 		if (!strcmp("persistent", key_str) &&
 		    !nvme_ctrl_is_persistent(c))
 			nvme_ctrl_set_persistent(c, true);
@@ -325,6 +327,7 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c)
 	JSON_BOOL_OPTION(cfg, port_obj, hdr_digest);
 	JSON_BOOL_OPTION(cfg, port_obj, data_digest);
 	JSON_BOOL_OPTION(cfg, port_obj, tls);
+	JSON_BOOL_OPTION(cfg, port_obj, disallow_pi);
 	if (nvme_ctrl_is_persistent(c))
 		json_object_object_add(port_obj, "persistent",
 				       json_object_new_boolean(true));
@@ -501,6 +504,7 @@ static void json_dump_ctrl(struct json_object *ctrl_array, nvme_ctrl_t c)
 	JSON_BOOL_OPTION(cfg, ctrl_obj, hdr_digest);
 	JSON_BOOL_OPTION(cfg, ctrl_obj, data_digest);
 	JSON_BOOL_OPTION(cfg, ctrl_obj, tls);
+	JSON_BOOL_OPTION(cfg, ctrl_obj, disallow_pi);
 	if (nvme_ctrl_is_persistent(c))
 		json_object_object_add(ctrl_obj, "persistent",
 				       json_object_new_boolean(true));
diff --git a/src/nvme/private.h b/src/nvme/private.h
index ee9d738..9ba2909 100644
--- a/src/nvme/private.h
+++ b/src/nvme/private.h
@@ -130,6 +130,7 @@ struct nvme_fabric_options {
 	bool dhchap_ctrl_secret;
 	bool dhchap_secret;
 	bool disable_sqflow;
+	bool disallow_pi;
 	bool discovery;
 	bool duplicate_connect;
 	bool fast_io_fail_tmo;
-- 
2.18.2




More information about the Linux-nvme mailing list