From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH nvme-cli 1/4] fabrics: make some arguments integers
Date: Fri, 31 Aug 2018 18:36:02 -0700 [thread overview]
Message-ID: <20180901013605.10658-2-sagi@grimberg.me> (raw)
In-Reply-To: <20180901013605.10658-1-sagi@grimberg.me>
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
fabrics.c | 60 +++++++++++++++++++++++++++++++++++--------------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/fabrics.c b/fabrics.c
index af4d7463d891..28a3e3d9ac82 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -54,11 +54,11 @@ static struct config {
char *host_traddr;
char *hostnqn;
char *hostid;
- char *nr_io_queues;
- char *queue_size;
- char *keep_alive_tmo;
- char *reconnect_delay;
- char *ctrl_loss_tmo;
+ int nr_io_queues;
+ int queue_size;
+ int keep_alive_tmo;
+ int reconnect_delay;
+ int ctrl_loss_tmo;
char *raw;
char *device;
int duplicate_connect;
@@ -505,6 +505,22 @@ add_bool_argument(char **argstr, int *max_len, char *arg_str, bool arg)
return 0;
}
+static int
+add_int_argument(char **argstr, int *max_len, char *arg_str, int arg)
+{
+ int len;
+
+ if (arg) {
+ len = snprintf(*argstr, *max_len, ",%s=%d", arg_str, arg);
+ if (len < 0)
+ return -EINVAL;
+ *argstr += len;
+ *max_len -= len;
+ }
+
+ return 0;
+}
+
static int
add_argument(char **argstr, int *max_len, char *arg_str, char *arg)
{
@@ -552,14 +568,14 @@ static int build_options(char *argstr, int max_len)
add_argument(&argstr, &max_len, "hostnqn", cfg.hostnqn)) ||
((cfg.hostid || nvmf_hostid_file()) &&
add_argument(&argstr, &max_len, "hostid", cfg.hostid)) ||
- add_argument(&argstr, &max_len, "nr_io_queues",
+ add_int_argument(&argstr, &max_len, "nr_io_queues",
cfg.nr_io_queues) ||
- add_argument(&argstr, &max_len, "queue_size", cfg.queue_size) ||
- add_argument(&argstr, &max_len, "keep_alive_tmo",
+ add_int_argument(&argstr, &max_len, "queue_size", cfg.queue_size) ||
+ add_int_argument(&argstr, &max_len, "keep_alive_tmo",
cfg.keep_alive_tmo) ||
- add_argument(&argstr, &max_len, "reconnect_delay",
+ add_int_argument(&argstr, &max_len, "reconnect_delay",
cfg.reconnect_delay) ||
- add_argument(&argstr, &max_len, "ctrl_loss_tmo",
+ add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
cfg.ctrl_loss_tmo) ||
add_bool_argument(&argstr, &max_len, "duplicate_connect",
cfg.duplicate_connect))
@@ -605,14 +621,14 @@ static int connect_ctrl(struct nvmf_disc_rsp_page_entry *e)
}
if (cfg.queue_size) {
- len = sprintf(p, ",queue_size=%s", cfg.queue_size);
+ len = sprintf(p, ",queue_size=%d", cfg.queue_size);
if (len < 0)
return -EINVAL;
p += len;
}
if (cfg.nr_io_queues) {
- len = sprintf(p, ",nr_io_queues=%s", cfg.nr_io_queues);
+ len = sprintf(p, ",nr_io_queues=%d", cfg.nr_io_queues);
if (len < 0)
return -EINVAL;
p += len;
@@ -626,14 +642,14 @@ static int connect_ctrl(struct nvmf_disc_rsp_page_entry *e)
}
if (cfg.ctrl_loss_tmo) {
- len = sprintf(p, ",ctrl_loss_tmo=%s", cfg.ctrl_loss_tmo);
+ len = sprintf(p, ",ctrl_loss_tmo=%d", cfg.ctrl_loss_tmo);
if (len < 0)
return -EINVAL;
p += len;
}
if (cfg.keep_alive_tmo && !discover) {
- len = sprintf(p, ",keep_alive_tmo=%s", cfg.keep_alive_tmo);
+ len = sprintf(p, ",keep_alive_tmo=%d", cfg.keep_alive_tmo);
if (len < 0)
return -EINVAL;
p += len;
@@ -835,9 +851,9 @@ 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" },
- {"keep-alive-tmo", 'k', "LIST", CFG_STRING, &cfg.keep_alive_tmo, required_argument, "keep alive timeout period in seconds" },
- {"reconnect-delay", 'c', "LIST", CFG_STRING, &cfg.reconnect_delay, required_argument, "reconnect timeout period in seconds" },
- {"ctrl-loss-tmo", 'l', "LIST", CFG_STRING, &cfg.ctrl_loss_tmo, required_argument, "controller loss timeout period in seconds" },
+ {"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" },
{NULL},
};
@@ -872,11 +888,11 @@ int connect(const char *desc, int argc, char **argv)
{"host-traddr", 'w', "LIST", CFG_STRING, &cfg.host_traddr, required_argument, "host traddr (e.g. FC WWN's)" },
{"hostnqn", 'q', "LIST", CFG_STRING, &cfg.hostnqn, required_argument, "user-defined hostnqn" },
{"hostid", 'I', "LIST", CFG_STRING, &cfg.hostid, required_argument, "user-defined hostid (if default not used)"},
- {"nr-io-queues", 'i', "LIST", CFG_STRING, &cfg.nr_io_queues, required_argument, "number of io queues to use (default is core count)" },
- {"queue-size", 'Q', "LIST", CFG_STRING, &cfg.queue_size, required_argument, "number of io queue elements to use (default 128)" },
- {"keep-alive-tmo", 'k', "LIST", CFG_STRING, &cfg.keep_alive_tmo, required_argument, "keep alive timeout period in seconds" },
- {"reconnect-delay", 'c', "LIST", CFG_STRING, &cfg.reconnect_delay, required_argument, "reconnect timeout period in seconds" },
- {"ctrl-loss-tmo", 'l', "LIST", CFG_STRING, &cfg.ctrl_loss_tmo, required_argument, "controller loss timeout period in seconds" },
+ {"nr-io-queues", 'i', "LIST", CFG_INT, &cfg.nr_io_queues, required_argument, "number of io queues to use (default is core count)" },
+ {"queue-size", 'Q', "LIST", CFG_INT, &cfg.queue_size, required_argument, "number of io queue elements to use (default 128)" },
+ {"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" },
{"duplicate_connect", 'D', "", CFG_NONE, &cfg.duplicate_connect, no_argument, "allow duplicate connections between same transport host and subsystem port" },
{NULL},
};
--
2.17.1
next prev parent reply other threads:[~2018-09-01 1:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-01 1:36 [PATCH nvme-cli 0/4] Some useful fabrics patches Sagi Grimberg
2018-09-01 1:36 ` Sagi Grimberg [this message]
2018-09-01 20:39 ` [PATCH nvme-cli 1/4] fabrics: make some arguments integers Chaitanya Kulkarni
2018-09-01 1:36 ` [PATCH nvme-cli 2/4] fabrics: don't fail empty discovery log page Sagi Grimberg
2018-09-01 20:40 ` Chaitanya Kulkarni
2018-09-01 1:36 ` [PATCH nvme-cli 3/4] nvme: commonize subsystems info in a helper Sagi Grimberg
2018-09-01 20:40 ` Chaitanya Kulkarni
2018-09-01 1:36 ` [PATCH nvme-cli 4/4] fabrics: add disconnect-all command Sagi Grimberg
2018-09-01 20:40 ` Chaitanya Kulkarni
2018-09-06 0:20 ` [PATCH nvme-cli 0/4] Some useful fabrics patches Keith Busch
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=20180901013605.10658-2-sagi@grimberg.me \
--to=sagi@grimberg.me \
/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;
as well as URLs for NNTP newsgroup(s).