]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: Make PDC behavior configurable
authorDaniel Wagner <dwagner@suse.de>
Wed, 25 Jan 2023 08:16:53 +0000 (09:16 +0100)
committerDaniel Wagner <dwagner@suse.de>
Wed, 25 Jan 2023 11:32:00 +0000 (12:32 +0100)
The persistent discovery controller is a behavior change which might
break existing installation. Instead enabling it per default, introduce
a compile time and a global configuration option to define the default
settings.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
fabrics.c
meson.build
meson_options.txt

index 21f2287850eb6e076fe8ef2b436ec02a2f08e912..8c19b07e6246f908d1bb4cb882839ca8b87ea8e2 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -148,6 +148,14 @@ static inline int strcasecmp0(const char *s1, const char *s2)
        return strcasecmp(s1, s2);
 }
 
+static bool is_persistent_discovery_ctrl(nvme_host_t h, nvme_ctrl_t c)
+{
+       if (nvme_host_is_pdc_enabled(h, DEFAULT_PDC_ENABLED))
+               return nvme_ctrl_is_unique_discovery_ctrl(c);
+
+       return false;
+}
+
 static bool disc_ctrl_config_match(nvme_ctrl_t c, struct tr_config *trcfg)
 {
        if (!strcmp0(nvme_ctrl_get_transport(c), trcfg->transport) &&
@@ -675,7 +683,7 @@ static int discover_from_conf_file(nvme_root_t r, nvme_host_t h,
                        goto next;
 
                __discover(c, &cfg, raw, connect, persistent, flags);
-               if (!(persistent || nvme_ctrl_is_unique_discovery_ctrl(c)))
+               if (!(persistent || is_persistent_discovery_ctrl(h, c)))
                        ret = nvme_disconnect_ctrl(c);
                nvme_free_ctrl(c);
 
@@ -751,7 +759,7 @@ static int discover_from_json_config_file(nvme_root_t r, nvme_host_t h,
                                continue;
 
                        __discover(cn, &cfg, raw, connect, persistent, flags);
-                       if (!(persistent || nvme_ctrl_is_unique_discovery_ctrl(cn)))
+                       if (!(persistent || is_persistent_discovery_ctrl(h, cn)))
                                ret = nvme_disconnect_ctrl(cn);
                        nvme_free_ctrl(cn);
                }
@@ -923,7 +931,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect)
        }
 
        ret = __discover(c, &cfg, raw, connect, persistent, flags);
-       if (!(persistent || nvme_ctrl_is_unique_discovery_ctrl(c)))
+       if (!(persistent || is_persistent_discovery_ctrl(h, c)))
                nvme_disconnect_ctrl(c);
        nvme_free_ctrl(c);
 
index 89e5d53dc58ea0939f545a300331ec77475cad48..7f5df3e1af4bc2da74629bccba9eb78ad0b174cc 100644 (file)
@@ -77,6 +77,8 @@ conf.set('CONFIG_LIBHUGETLBFS', have_libhugetlbfs, description: 'Is libhugetlbfs
 # Set the nvme-cli version
 conf.set('NVME_VERSION', '"' + meson.project_version() + '"')
 
+conf.set10('DEFAULT_PDC_ENABLED', get_option('pdc-enabled'))
+
 # local (cross-compilable) implementations of ccan configure steps
 conf.set10(
     'HAVE_BUILTIN_TYPES_COMPATIBLE_P',
index cba027f73514d5e7c55ef8fd11ee58420a0a1959..04843ea5461aa741ad0c98c4a1ebb1024469d426 100644 (file)
@@ -7,4 +7,5 @@ option('htmldir', type : 'string', value : '', description : 'directory for HTML
 option('systemctl', type : 'string', value : '/usr/bin/systemctl', description : 'path to systemctl binary')
 option('nvme-tests', type : 'boolean', value : false, description: 'Run tests against real hardware')
 option('docs', type : 'combo', choices : ['false', 'html', 'man', 'all'], description : 'install documentation')
-option('docs-build', type : 'boolean', value : false,  description : 'build documentation')
+option('docs-build', type : 'boolean', value : false, description : 'build documentation')
+option('pdc-enabled', type: 'boolean', value : false, description : 'set default Persistent Discovery Controllers behavior')