summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-06-01 11:23:24 -0500
committerDavid Teigland <teigland@redhat.com>2015-06-02 11:39:34 -0500
commitdca29e1247b1ddd329c2d577f242c0eca5570efa (patch)
treedf19a46a70a728c6bd9ae7ac9a8e5d703e1e2a34
parentf5ea42e08458bdeba6a3a74830d925ce389a047e (diff)
downloadlvm2-dca29e1247b1ddd329c2d577f242c0eca5570efa.tar.gz
client lvmlockd: improve warnings during init
Print one simple warning message if the command cannot properly use lvmlockd.
-rw-r--r--lib/locking/lvmlockd.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index d9bbc8132..4c528c510 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -23,6 +23,7 @@ static const char *_lvmlockd_socket = NULL;
static struct cmd_context *_lvmlockd_cmd = NULL;
static int _use_lvmlockd; /* is 1 if command is configured to use lvmlockd */
static int _lvmlockd_connected; /* is 1 if command is connected to lvmlockd */
+static int _lvmlockd_init_failed; /* used to suppress further warnings */
void lvmlockd_set_socket(const char *sock)
{
@@ -57,8 +58,17 @@ void lvmlockd_init(struct cmd_context *cmd)
log_error("Should not initialize lvmlockd with use_lvmlockd=0.");
}
- if (!!access(LVMLOCKD_PIDFILE, F_OK))
- log_warn("lvmlockd process not found using %s.", LVMLOCKD_PIDFILE);
+ if (!_lvmlockd_socket) {
+ log_warn("WARNING: lvmlockd socket location is not configured.");
+ _lvmlockd_init_failed = 1;
+ }
+
+ if (!!access(LVMLOCKD_PIDFILE, F_OK)) {
+ log_warn("WARNING: lvmlockd process is not running.");
+ _lvmlockd_init_failed = 1;
+ } else {
+ _lvmlockd_init_failed = 0;
+ }
_lvmlockd_cmd = cmd;
}
@@ -75,10 +85,8 @@ void lvmlockd_connect(void)
log_error("lvmlockd is already connected.");
}
- if (!_lvmlockd_socket) {
- log_error("lvmlockd connect failed: no path to socket.");
+ if (_lvmlockd_init_failed)
return;
- }
_lvmlockd = lvmlockd_open(_lvmlockd_socket);
@@ -86,8 +94,7 @@ void lvmlockd_connect(void)
log_debug("Successfully connected to lvmlockd on fd %d.", _lvmlockd.socket_fd);
_lvmlockd_connected = 1;
} else {
- log_error("lvmlockd connect failed: fd %d error %d.",
- _lvmlockd.socket_fd, _lvmlockd.error);
+ log_warn("WARNING: lvmlockd connect failed.");
}
}