]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Add unique discovery controller flag
authorDaniel Wagner <dwagner@suse.de>
Tue, 17 Jan 2023 08:12:38 +0000 (09:12 +0100)
committerDaniel Wagner <dwagner@suse.de>
Fri, 20 Jan 2023 07:39:33 +0000 (08:39 +0100)
Introduce a setter an getter to track if a discovery controller is
unique (unique NQN as defined in TP8013).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/libnvme.map
src/nvme/fabrics.c
src/nvme/private.h
src/nvme/tree.c
src/nvme/tree.h

index 7f97f70dfb4d1a52df9aa41e43a3ece5ed2e5af6..f6dd43415dde8bc9d10b6931457ace8344506e80 100644 (file)
@@ -2,10 +2,12 @@
 
 LIBNVME_1_3 {
        global:
-               nvme_io_mgmt_recv;
-               nvme_io_mgmt_send;
                nvme_fdp_reclaim_unit_handle_status;
                nvme_fdp_reclaim_unit_handle_update;
+               nvme_io_mgmt_recv;
+               nvme_io_mgmt_send;
+               nvme_ctrl_is_unique_discovery_ctrl;
+               nvme_ctrl_set_unique_discovery_ctrl;
 };
 
 LIBNVME_1_2 {
index 479637939598d1315871b0451327266b86c2dff2..15cff6747f8160d1a9d1cd4296cc79e456290cf4 100644 (file)
@@ -459,6 +459,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)
        }
        if (!strcmp(nvme_ctrl_get_subsysnqn(c), NVME_DISC_SUBSYS_NAME)) {
                nvme_ctrl_set_discovery_ctrl(c, true);
+               nvme_ctrl_set_unique_discovery_ctrl(c, false);
                discovery_nqn = true;
        }
        if (nvme_ctrl_is_discovery_ctrl(c))
@@ -738,11 +739,15 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
        switch (e->subtype) {
        case NVME_NQN_CURR:
                nvme_ctrl_set_discovered(c, true);
+               nvme_ctrl_set_unique_discovery_ctrl(c,
+                               strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME));
                break;
        case NVME_NQN_DISC:
                if (discover)
                        *discover = true;
                nvme_ctrl_set_discovery_ctrl(c, true);
+               nvme_ctrl_set_unique_discovery_ctrl(c,
+                               strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME));
                break;
        default:
                nvme_msg(h->r, LOG_ERR, "unsupported subtype %d\n",
@@ -750,6 +755,7 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
                fallthrough;
        case NVME_NQN_NVME:
                nvme_ctrl_set_discovery_ctrl(c, false);
+               nvme_ctrl_set_unique_discovery_ctrl(c, false);
                break;
        }
 
index fbaaaa4af03b884e8bd2a838cad701bf15b56d5d..924fe98294837b0f87a62c6881ac111e415c97f6 100644 (file)
@@ -85,6 +85,7 @@ struct nvme_ctrl {
        char *cntrltype;
        char *dctype;
        bool discovery_ctrl;
+       bool unique_discovery_ctrl;
        bool discovered;
        bool persistent;
        struct nvme_fabrics_config cfg;
index dde8193e612260f75e9fc07ebcb441dd12bf8ef5..75cbfc899cb41e5a6c1b6277393ad36471921027 100644 (file)
@@ -870,6 +870,16 @@ bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c)
        return c->discovery_ctrl;
 }
 
+void nvme_ctrl_set_unique_discovery_ctrl(nvme_ctrl_t c, bool unique)
+{
+       c->unique_discovery_ctrl = unique;
+}
+
+bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c)
+{
+       return c->unique_discovery_ctrl;
+}
+
 int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id)
 {
        return nvme_identify_ctrl(nvme_ctrl_get_fd(c), id);
index 156cb79118ba41380a3bd19991be386b460a79c4..d34555ca9e263283827e780e7e21466027304e1d 100644 (file)
@@ -968,6 +968,25 @@ void nvme_ctrl_set_discovery_ctrl(nvme_ctrl_t c, bool discovery);
  */
 bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c);
 
+/**
+ * nvme_ctrl_set_unique_discovery_ctrl() - Set the 'unique_discovery_ctrl' flag
+ * @c:         Controller to be modified
+ * @unique:    value of the unique_disc_ctrl flag
+ *
+ * Sets the 'unique_discovery_ctrl' flag in @c to specify wheter
+ * @c is a unique discovery controller
+ *
+ */
+void nvme_ctrl_set_unique_discovery_ctrl(nvme_ctrl_t c, bool unique);
+
+/**
+ * nvme_ctrl_is_unique_discovery_ctrl() - Check the 'unique_discovery_ctrl' flag
+ * @c:         Controller to be checked
+ *
+ * Return: Value of the 'unique_discovery_ctrl' flag
+ */
+bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c);
+
 /**
  * nvme_ctrl_identify() - Issues an 'identify controller' command
  * @c: Controller instance