All of lore.kernel.org
 help / color / mirror / Atom feed
From: jsmart2021@gmail.com (James Smart)
Subject: [PATCH v2 09/10] nvme-cli: add --quiet option
Date: Fri, 19 Jul 2019 15:53:04 -0700	[thread overview]
Message-ID: <20190719225305.11397-10-jsmart2021@gmail.com> (raw)
In-Reply-To: <20190719225305.11397-1-jsmart2021@gmail.com>

From: Sagi Grimberg <sagi@grimberg.me>

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 <sagi at grimberg.me>
Reviewed-by: James Smart <jsmart2021 at gmail.com>
Reviewed-by: Hannes Reinecke <hare at suse.com>
Reviewed-by: Minwoo Im <minwoo.im.dev at gmail.com>
---
 fabrics.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/fabrics.c b/fabrics.c
index 9a7f832..fd5a742 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;
 	}
@@ -854,10 +857,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;
 		}
 
@@ -1062,6 +1068,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

  parent reply	other threads:[~2019-07-19 22:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 22:52 [PATCH v2 00/10] nvme-cli: nvmf auto-connect scripts James Smart
2019-07-19 22:52 ` [PATCH v2 01/10] nvme-cli: ignore arguments that pass in "none" James Smart
2019-07-19 22:52 ` [PATCH v2 02/10] nvme-cli: support persistent connections to a discovery controller James Smart
2019-07-19 22:52 ` [PATCH v2 03/10] nvme-cli: allow discover to address discovery controller by persistent name James Smart
2019-07-19 22:52 ` [PATCH v2 04/10] nvme-cli: Refactor to create a get_nvme_ctrl_info routine James Smart
2019-07-19 22:53 ` [PATCH v2 05/10] nvme-cli: extend ctrl_list_item for connect attributes James Smart
2019-07-19 22:53 ` [PATCH v2 06/10] nvme-cli: Add routine to compare ctrl_list_item to connect args James Smart
2019-07-19 22:53 ` [PATCH v2 07/10] nvme-cli: Add routine to search for controller with specific attributes James Smart
2019-07-20  8:25   ` Minwoo Im
2019-07-20 18:33     ` James Smart
2019-07-22 22:41     ` Sagi Grimberg
2019-07-23 13:36       ` Minwoo Im
2019-07-19 22:53 ` [PATCH v2 08/10] nvme-cli: Expand --device argument processing James Smart
2019-07-19 22:53 ` James Smart [this message]
2019-07-19 22:53 ` [PATCH v2 10/10] nvme-cli: nvmf auto-connect scripts James Smart
2019-07-23  2:52   ` Sagi Grimberg
2019-07-23 16:01     ` James Smart
2019-07-23  3:57   ` Sagi Grimberg
2019-07-23 16:04     ` James Smart
2019-07-23 17:32       ` Sagi Grimberg
2019-07-24 16:38         ` James Smart
2019-07-24 18:15           ` Sagi Grimberg
2019-07-24 23:45             ` James Smart
2019-07-22 22:43 ` [PATCH v2 00/10] " 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=20190719225305.11397-10-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.