From: Sagi Grimberg Date: Thu, 1 Aug 2019 23:13:47 +0000 (-0700) Subject: nvme-cli: add --quiet option X-Git-Tag: v1.9~9 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=547f4b752c49b144304b1e33d63d9325e02ca50a;p=users%2Fhch%2Fnvme-cli.git nvme-cli: add --quiet option 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. Example: nvme connect-all ... --quiet This option will be used by the discovery log change corresponding udev rule. Signed-off-by: Sagi Grimberg Reviewed-by: James Smart Reviewed-by: Hannes Reinecke Reviewed-by: Minwoo Im --- diff --git a/fabrics.c b/fabrics.c index f1a5ad2..333669f 100644 --- a/fabrics.c +++ b/fabrics.c @@ -67,6 +67,7 @@ static struct config { int hdr_digest; int data_digest; bool persistent; + bool quiet; } cfg = { NULL }; #define BUF_SIZE 4096 @@ -218,9 +219,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; } @@ -858,10 +861,13 @@ 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; - fprintf(stderr, - "traddr=%.*s is already connected\n", - space_strip_len(NVMF_TRADDR_SIZE, traddr), - traddr); + + if (!cfg.quiet) + fprintf(stderr, + "traddr=%.*s is already connected\n", + space_strip_len(NVMF_TRADDR_SIZE, + traddr), + traddr); continue; } @@ -1066,6 +1072,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}, };