From: Daniel Wagner Date: Wed, 25 Jan 2023 08:16:53 +0000 (+0100) Subject: fabrics: Make PDC behavior configurable X-Git-Tag: v2.3~9^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ca78e664d575ebd404dca58e60f7e4542768f82c;p=users%2Fsagi%2Fnvme-cli.git fabrics: Make PDC behavior configurable 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 --- diff --git a/fabrics.c b/fabrics.c index 21f22878..8c19b07e 100644 --- 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); diff --git a/meson.build b/meson.build index 89e5d53d..7f5df3e1 100644 --- a/meson.build +++ b/meson.build @@ -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', diff --git a/meson_options.txt b/meson_options.txt index cba027f7..04843ea5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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')