From: jsmart2021@gmail.com (James Smart) Date: Fri, 3 May 2019 17:04:55 -0700 Subject: [PATCH nvme-cli rfc 4/5] fabrics: add --quiet option In-Reply-To: <20190504000456.3888-1-jsmart2021@gmail.com> References: <20190504000456.3888-1-jsmart2021@gmail.com> Message-ID: <20190504000456.3888-5-jsmart2021@gmail.com> From: Sagi Grimberg Now we are going to have discovery log change events, so instead of trying to figure out which NVM subsystem ports are already connected, we let the driver do that and only suppress the failure messages. This option will be used by the discovery log change corresponding udev rule. Signed-off-by: Sagi Grimberg --- fabrics.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fabrics.c b/fabrics.c index a80c11c..dc6b824 100644 --- a/fabrics.c +++ b/fabrics.c @@ -66,6 +66,7 @@ static struct config { int hdr_digest; int data_digest; bool persistent; + bool quiet; } cfg = { NULL }; #define BUF_SIZE 4096 @@ -216,9 +217,11 @@ static int add_ctrl(const char *argstr) goto out; } - if (write(fd, argstr, len) != len) { - fprintf(stderr, "Failed to write to %s: %s\n", - PATH_NVME_FABRICS, strerror(errno)); + ret = write(fd, argstr, len); + if (ret != len) { + if (errno != EALREADY || !cfg.quiet) + fprintf(stderr, "Failed to write to %s: %s\n", + PATH_NVME_FABRICS, strerror(errno)); ret = -errno; goto out_close; } @@ -840,6 +843,10 @@ static int connect_ctrls(struct nvmf_disc_rsp_page_hdr *log, int numrec) /* already connected print message */ if (instance == -EALREADY) { const char *traddr = log->entries[i].traddr; + + if (cfg.quiet) + continue; + fprintf(stderr, "traddr=%.*s is already connected\n", space_strip_len(NVMF_TRADDR_SIZE, traddr), @@ -1002,6 +1009,7 @@ int discover(const char *desc, int argc, char **argv, bool connect) {"nr-poll-queues", 'P', "LIST", CFG_INT, &cfg.nr_poll_queues, required_argument, "number of poll queues to use (default 0)" }, {"queue-size", 'Q', "LIST", CFG_INT, &cfg.queue_size, required_argument, "number of io queue elements to use (default 128)" }, {"persistent", 'p', "LIST", CFG_NONE, &cfg.persistent, no_argument, "persistent discovery connection" }, + {"quiet", 'Q', "LIST", CFG_NONE, &cfg.quiet, no_argument, "suppress already connected errors" }, {NULL}, }; -- 2.13.7