From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>
Subject: [PATCH 1/2] multipath: don't start multipathd unnecessarily
Date: Thu, 28 Jun 2018 12:34:45 +0200 [thread overview]
Message-ID: <20180628103446.16817-1-mwilck@suse.com> (raw)
When multipathd is off, but systemd is monitoring the multipathd socket,
mpath_connect() has the side effect of starting multipathd. That's
superfluous if we aren't going to pass the command at hand to multipathd.
So, only try to open the socket if the command at hand is a candidate
for delegation.
Note: Despite this, some day in the future, we may decide to delegate
almost everything to multipathd.
Fixes: 506d253b "multipath: delegate dangerous commands to multipathd"
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
multipath/main.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/multipath/main.c b/multipath/main.c
index ed4f40ef..a0f3bde0 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -803,10 +803,6 @@ int delegate_to_multipathd(enum mpath_cmds cmd, const char *dev,
char command[1024], *p, *reply = NULL;
int n, r = 0;
- fd = mpath_connect();
- if (fd == -1)
- return 0;
-
p = command;
*p = '\0';
n = sizeof(command);
@@ -819,7 +815,12 @@ int delegate_to_multipathd(enum mpath_cmds cmd, const char *dev,
if (strlen(command) == 0)
/* No command found, no need to delegate */
return 0;
- else if (p >= command + sizeof(command)) {
+
+ fd = mpath_connect();
+ if (fd == -1)
+ return 0;
+
+ if (p >= command + sizeof(command)) {
condlog(0, "internal error - command buffer overflow");
r = -1;
goto out;
--
2.17.1
next reply other threads:[~2018-06-28 10:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 10:34 Martin Wilck [this message]
2018-06-28 10:34 ` [PATCH 2/2] multipath: fix return code handling in delegate_to_multipathd Martin Wilck
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=20180628103446.16817-1-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.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