-
Notifications
You must be signed in to change notification settings - Fork 721
Use persistent discovery controller by default #3472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,14 @@ | |
|
|
||
| #define NVMF_DEF_DISC_TMO 30 | ||
|
|
||
| #if DEFAULT_EPCSD_ENABLED | ||
| #define EPCSD_DISABLED_DEFAULT_STR | ||
| #define EPCSD_ENABLED_DEFAULT_STR " (default)" | ||
| #else | ||
| #define EPCSD_ENABLED_DEFAULT_STR | ||
| #define EPCSD_DISABLED_DEFAULT_STR " (default)" | ||
| #endif | ||
|
|
||
| /* Name of file to output log pages in their raw format */ | ||
| static char *raw; | ||
| static bool persistent; | ||
|
|
@@ -197,6 +205,7 @@ static int setup_common_context(struct libnvmf_context *fctx, | |
|
|
||
| struct hook_fabrics_data { | ||
| struct nvmf_args *fa; | ||
| struct libnvme_global_ctx *ctx; | ||
| nvme_print_flags_t flags; | ||
| bool quiet; | ||
| char *raw; | ||
|
|
@@ -322,13 +331,17 @@ static int set_fabrics_options(struct libnvmf_context *fctx, | |
| static int hook_parser_next_line(struct libnvmf_context *fctx, void *user_data) | ||
| { | ||
| struct hook_fabrics_data *hfd = user_data; | ||
| bool epcsd_enabled = false, epcsd_disabled = false; | ||
| struct libnvme_host *h = NULL; | ||
| struct nvmf_args fa; | ||
| char *ptr, *p; | ||
| static char line[4096]; | ||
| int argc, ret = 0; | ||
| bool force = false; | ||
|
|
||
| NVMF_ARGS(opts, fa, | ||
| OPT_FLAG("epcsd", 0, &epcsd_enabled, "Enable persistent discovery for controllers that support it"), | ||
| OPT_FLAG("no-epcsd", 0, &epcsd_disabled, "Disable persistent discovery for controllers that support it"), | ||
| OPT_FLAG("persistent", 'p', &persistent, "persistent discovery connection"), | ||
| OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation")); | ||
|
|
||
|
|
@@ -349,6 +362,11 @@ static int hook_parser_next_line(struct libnvmf_context *fctx, void *user_data) | |
| fa.subsysnqn = NVME_DISC_SUBSYS_NAME; | ||
| if (argconfig_parse(argc, hfd->argv, "config", opts)) | ||
| continue; | ||
|
|
||
| if (epcsd_enabled && epcsd_disabled) { | ||
| fprintf(stderr, "--epcsd and --no-epcsd are mutually exclusive\n"); | ||
| continue; | ||
| } | ||
| } while (!fa.transport && !fa.traddr); | ||
|
|
||
| if (!fa.trsvcid) | ||
|
|
@@ -361,6 +379,13 @@ static int hook_parser_next_line(struct libnvmf_context *fctx, void *user_data) | |
| libnvmf_context_set_discovery_hooks(fctx, hook_discovery_log, | ||
| hook_parser_init, hook_parser_cleanup, hook_parser_next_line); | ||
|
|
||
| libnvme_get_host(hfd->ctx, fa.hostnqn, fa.hostid, &h); | ||
| if (epcsd_enabled) | ||
| libnvme_host_set_epcsd_enabled(h, true); | ||
|
|
||
| if (epcsd_disabled) | ||
| libnvme_host_set_epcsd_enabled(h, false); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tempted to argue for if (epcsd_enabled || epcsd_disabled)
libnvme_host_set_epcsd_enabled(h, epcsd_enabled);but this might be a bit too obfuscated... |
||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
@@ -557,13 +582,17 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) | |
| char *device = NULL; | ||
| bool force = false; | ||
| bool json_config = false; | ||
| bool epcsd_enabled = false, epcsd_disabled = false; | ||
| bool nbft = false, nonbft = false; | ||
| char *nbft_path = NBFT_SYSFS_PATH; | ||
| char *owner = NULL; | ||
| struct libnvme_host *h = NULL; | ||
|
|
||
| NVMF_ARGS(opts, fa, | ||
| OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"), | ||
| OPT_FILE("raw", 'r', &raw, "save raw output to file"), | ||
| OPT_FLAG("epcsd", 0, &epcsd_enabled, "Enable persistent discovery for controllers that support it." EPCSD_ENABLED_DEFAULT_STR), | ||
| OPT_FLAG("no-epcsd", 0, &epcsd_disabled, "Disable persistent discovery for controllers that support it." EPCSD_DISABLED_DEFAULT_STR), | ||
| OPT_FLAG("persistent", 'p', &persistent, "persistent discovery connection"), | ||
| OPT_FLAG("quiet", 0, &quiet, "suppress already connected errors"), | ||
| OPT_STRING("config", 'J', "FILE", &config_file, nvmf_config_file), | ||
|
|
@@ -588,6 +617,11 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) | |
| return ret; | ||
| } | ||
|
|
||
| if (epcsd_enabled && epcsd_disabled) { | ||
| fprintf(stderr, "--epcsd and --no-epcsd options are mutually exclusive\n"); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| if (!strcmp(config_file, "none")) | ||
| config_file = NULL; | ||
|
|
||
|
|
@@ -637,6 +671,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) | |
|
|
||
| struct hook_fabrics_data dld = { | ||
| .fa = &fa, | ||
| .ctx = ctx, | ||
| .flags = flags, | ||
| .raw = raw, | ||
| }; | ||
|
|
@@ -662,6 +697,12 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) | |
| goto out_free; | ||
| } | ||
|
|
||
| libnvme_get_host(ctx, fa.hostnqn, fa.hostid, &h); | ||
| if (epcsd_enabled) | ||
| libnvme_host_set_epcsd_enabled(h, true); | ||
|
|
||
| if (epcsd_disabled) | ||
| libnvme_host_set_epcsd_enabled(h, false); | ||
| ret = libnvmf_discovery(ctx, fctx, connect, force); | ||
|
|
||
| out_free: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2351,6 +2351,20 @@ static int _nvmf_discovery(struct libnvme_global_ctx *ctx, | |
| } | ||
|
|
||
| numrec = le64_to_cpu(log->numrec); | ||
|
|
||
| for (int i = 0; i < numrec; i++) { | ||
| struct nvmf_disc_log_entry *e = &log->entries[i]; | ||
| uint16_t eflags = le16_to_cpu(e->eflags); | ||
|
|
||
| if ((e->subtype == NVME_NQN_DISC || | ||
| e->subtype == NVME_NQN_CURR) && | ||
| (eflags & NVMF_DISC_EFLAGS_EPCSD) && | ||
| libnvme_host_is_epcsd_enabled(h, DEFAULT_EPCSD_ENABLED)) { | ||
| libnvmf_context_set_persistent(fctx, true); | ||
| break; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you move this part into the existing loop where we already have the |
||
| } | ||
| } | ||
|
|
||
| if (fctx->hooks.discovery_log) | ||
| fctx->hooks.discovery_log(fctx, connect, log, numrec, | ||
| fctx->hooks.user_data); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.