From: jsmart2021@gmail.com (James Smart)
Subject: [PATCH rfc 3/6] nvme-cli: allow discover to address discovery controller by persistent name
Date: Wed, 10 Jul 2019 16:27:37 -0700 [thread overview]
Message-ID: <20190710232740.26734-4-jsmart2021@gmail.com> (raw)
In-Reply-To: <20190710232740.26734-1-jsmart2021@gmail.com>
To support discovery (connect/connect-all) to operate against a
persistent discovery controller, let the discovery controller to
be specified by its device node name rather than new connection
attributes.
Example:
nvme connect-all ... --device=nvme5
Also centralize extraction of controller instance from the controller
name to a common helper.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
Signed-off-by: James Smart <jsmart2021 at gmail.com>
Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
---
Patch originated from Sagi in an RFC
fix merge issue
fix contoller->controller
add cfg.device check for "none"
---
fabrics.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/fabrics.c b/fabrics.c
index c4bbe2c..1c5ca9a 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -189,6 +189,19 @@ static const char *cms_str(__u8 cm)
static int do_discover(char *argstr, bool connect);
+static int ctrl_instance(char *device)
+{
+ int ret, instance;
+
+ device = basename(device);
+ ret = sscanf(device, "nvme%d", &instance);
+ if (ret < 0)
+ return ret;
+ if (!ret)
+ return -1;
+ return instance;
+}
+
static int add_ctrl(const char *argstr)
{
substring_t args[MAX_OPT_ARGS];
@@ -851,7 +864,10 @@ static int do_discover(char *argstr, bool connect)
char *dev_name;
int instance, numrec = 0, ret, err;
- instance = add_ctrl(argstr);
+ if (!cfg.device)
+ instance = add_ctrl(argstr);
+ else
+ instance = ctrl_instance(cfg.device);
if (instance < 0)
return instance;
@@ -859,7 +875,7 @@ static int do_discover(char *argstr, bool connect)
return -errno;
ret = nvmf_get_log_page_discovery(dev_name, &log, &numrec);
free(dev_name);
- if (!cfg.persistent) {
+ if (!cfg.device && !cfg.persistent) {
err = remove_ctrl(instance);
if (err)
return err;
@@ -975,6 +991,7 @@ int discover(const char *desc, int argc, char **argv, bool connect)
{"hostnqn", 'q', "LIST", CFG_STRING, &cfg.hostnqn, required_argument, "user-defined hostnqn (if default not used)" },
{"hostid", 'I', "LIST", CFG_STRING, &cfg.hostid, required_argument, "user-defined hostid (if default not used)"},
{"raw", 'r', "LIST", CFG_STRING, &cfg.raw, required_argument, "raw output file" },
+ {"device", 'd', "LIST", CFG_STRING, &cfg.device, required_argument, "use existing discovery controller device" },
{"keep-alive-tmo", 'k', "LIST", CFG_INT, &cfg.keep_alive_tmo, required_argument, "keep alive timeout period in seconds" },
{"reconnect-delay", 'c', "LIST", CFG_INT, &cfg.reconnect_delay, required_argument, "reconnect timeout period in seconds" },
{"ctrl-loss-tmo", 'l', "LIST", CFG_INT, &cfg.ctrl_loss_tmo, required_argument, "controller loss timeout period in seconds" },
@@ -993,6 +1010,9 @@ int discover(const char *desc, int argc, char **argv, bool connect)
if (ret)
return ret;
+ if (cfg.device && !strcmp(cfg.device, "none"))
+ cfg.device = NULL;
+
cfg.nqn = NVME_DISC_SUBSYS_NAME;
if (!cfg.transport && !cfg.traddr) {
@@ -1130,15 +1150,10 @@ static int disconnect_by_nqn(char *nqn)
static int disconnect_by_device(char *device)
{
int instance;
- int ret;
-
- device = basename(device);
- ret = sscanf(device, "nvme%d", &instance);
- if (ret < 0)
- return ret;
- if (!ret)
- return -1;
+ instance = ctrl_instance(device);
+ if (instance < 0)
+ return instance;
return remove_ctrl(instance);
}
--
2.13.7
next prev parent reply other threads:[~2019-07-10 23:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 23:27 [PATCH rfc 0/6] nvme-cli: nvmf auto-connect scripts James Smart
2019-07-10 23:27 ` [PATCH rfc 1/6] nvme-cli: ignore arguments that pass in "none" James Smart
2019-07-11 12:28 ` Minwoo Im
2019-07-10 23:27 ` [PATCH rfc 2/6] nvme-cli: support persistent connections to a discovery controller James Smart
2019-07-11 12:33 ` Minwoo Im
2019-07-10 23:27 ` James Smart [this message]
2019-07-11 12:41 ` [PATCH rfc 3/6] nvme-cli: allow discover to address discovery controller by persistent name Minwoo Im
2019-07-11 16:16 ` James Smart
2019-07-11 17:11 ` Minwoo Im
2019-07-10 23:27 ` [PATCH rfc 4/6] nvme-cli: expand --device argument processing James Smart
2019-07-11 0:43 ` Sagi Grimberg
2019-07-11 23:54 ` Sagi Grimberg
2019-07-10 23:27 ` [PATCH rfc 5/6] nvme-cli: add --quiet option James Smart
2019-07-11 12:53 ` Minwoo Im
2019-07-10 23:27 ` [PATCH rfc 6/6] nvme-cli: nvmf auto-connect scripts James Smart
2019-07-11 0:42 ` Sagi Grimberg
2019-07-11 16:18 ` James Smart
2019-07-11 23:47 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190710232740.26734-4-jsmart2021@gmail.com \
--to=jsmart2021@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox