master - lvmpolld.8.in: man page rewrite
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77fa958c1e019c...
Commit: 77fa958c1e019cccebf30a92edfec07970e9f927
Parent: d4317c040635a67c62df95bd102e03575d49f09d
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Thu May 14 19:33:27 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:47 2015 +0200
lvmpolld.8.in: man page rewrite
- add client functionality
- fill in long option variants
---
man/lvmpolld.8.in | 57 +++++++++++++++++++++++++++++-----------------------
1 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/man/lvmpolld.8.in b/man/lvmpolld.8.in
index 462ac1f..5906f42 100644
--- a/man/lvmpolld.8.in
+++ b/man/lvmpolld.8.in
@@ -3,73 +3,80 @@
lvmpolld \(em LVM poll daemon
.SH SYNOPSIS
.B lvmpolld
-.RB [ \-l
+.RB [ \-l | \-\-log
.RI { all | wire | debug }]
-.RB [ \-p
+.RB [ \-p | \-\-pidfile
.IR pidfile_path ]
-.RB [ \-s
+.RB [ \-s | \-\-socket
.IR socket_path ]
-.RB [ \-B
+.RB [ \-B | \-\-binary
.IR lvm_binary_path ]
-.RB [ \-t
+.RB [ \-t | \-\-timeout
.IR timeout_value ]
-.RB [ \-f ]
-.RB [ \-h ]
-.RB [ \-V ]
-.RB [ \-? ]
+.RB [ \-f | \-\-foreground ]
+.RB [ \-h | \-\-help ]
+.RB [ \-V | \-\-version ]
+
+.B lvmpolld
+.RB [ \-\-dump ]
.SH DESCRIPTION
lvmpolld is polling daemon for LVM. The daemon receives requests for polling
of already initialised operations originating in LVM2 command line tool.
-The requests for polling originates in \fBlvconvert\fP, \fBpvmove\fP,
-\fBlvchange\fP or \fBvgchange\fP LVM2 command.
+The requests for polling originate in the \fBlvconvert\fP, \fBpvmove\fP,
+\fBlvchange\fP or \fBvgchange\fP LVM2 commands.
The purpose of lvmpolld is to reduce the number of spawned background processes
-per otherwise unique polling operation. There should be only one. It also eliminates
-the possibility of unsolicited termination of background process by external factors.
+per otherwise unique polling operation. There should be only one. It also
+eliminates the possibility of unsolicited termination of background process by
+external factors.
-lvmpolld is used by LVM only if it is enabled in \fBlvm.conf\fP(5) by specifying the
-\fBglobal/use_lvmpolld\fP setting. If this is not defined in the LVM configuration
-explicitly then default setting is used instead (see the output of
-\fBlvmconfig \-\-type default global/use_lvmpolld\fP command).
+lvmpolld is used by LVM only if it is enabled in \fBlvm.conf\fP(5) by
+specifying the \fBglobal/use_lvmpolld\fP setting. If this is not defined in the
+LVM configuration explicitly then default setting is used instead (see the
+output of \fBlvmconfig \-\-type default global/use_lvmpolld\fP command).
.SH OPTIONS
To run the daemon in a test environment both the pidfile_path and the
socket_path should be changed from the defaults.
.TP
-.B \-f
+.BR \-f ", " \-\-foreground
Don't fork, but run in the foreground.
.TP
-.BR \-h ", " \-?
+.BR \-h ", " \-\-help
Show help information.
.TP
-.IR \fB\-l " {" all | wire | debug }
+.IR \fB\-l\fP ", " \fB\-\-log\fP " {" all | wire | debug }
Select the type of log messages to generate.
Messages are logged by syslog.
Additionally, when \-f is given they are also sent to standard error.
There are two classes of messages: wire and debug. Selecting 'all' supplies both
and is equivalent to a comma-separated list \-l wire,debug.
.TP
-.B \-p \fIpidfile_path
+.BR \-p ", " \-\-pidfile \fIpidfile_path
Path to the pidfile. This overrides both the built-in default
(#DEFAULT_PID_DIR#/lvmpolld.pid) and the environment variable
\fBLVM_LVMPOLLD_PIDFILE\fP. This file is used to prevent more
than one instance of the daemon running simultaneously.
.TP
-.B \-s \fIsocket_path
+.BR \-s ", " \-\-socket " " \fIsocket_path
Path to the socket file. This overrides both the built-in default
(#DEFAULT_RUN_DIR#/lvmpolld.socket) and the environment variable
\fBLVM_LVMPOLLD_SOCKET\fP.
.TP
-.B \-t \fItimeout_value
+.BR \-t ", " \-\-timeout " " \fItimeout_value
The daemon may shutdown after being idle for the given time (in seconds). When the
option is omitted or the value given is zero the daemon never shutdowns on idle.
.TP
-.B \-B \fIlvm_binary_path
+.BR \-B ", " \-\-binary " " \fIlvm_binary_path
Optional path to alternative LVM binary (default: #LVM_PATH#). Use for
testing purposes only.
.TP
-.B \-V
+.BR \-V ", " \-\-version
Display the version of lvmpolld daemon.
+.TP
+.B \-\-dump
+Contact the running lvmpolld daemon to obtain the complete state and print it
+out in a raw format.
.SH ENVIRONMENT VARIABLES
.TP
.B LVM_LVMPOLLD_PIDFILE
9 years
master - lvmpolld: don't return success on invalid option
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4317c040635a6...
Commit: d4317c040635a67c62df95bd102e03575d49f09d
Parent: d34de2d91270a1f3cd427e1dab4a6df8789de7e5
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 19:28:23 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:40 2015 +0200
lvmpolld: don't return success on invalid option
---
daemons/lvmpolld/lvmpolld-core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c
index a141d77..1a33625 100644
--- a/daemons/lvmpolld/lvmpolld-core.c
+++ b/daemons/lvmpolld/lvmpolld-core.c
@@ -914,7 +914,7 @@ int main(int argc, char *argv[])
.socket_path = getenv("LVM_LVMPOLLD_SOCKET") ?: LVMPOLLD_SOCKET,
};
- while ((opt = getopt_long(argc, argv, "?fhVl:p:s:B:t:", long_options, &option_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", long_options, &option_index)) != -1) {
switch (opt) {
case 0 :
if (action < ACTION_MAX) {
@@ -928,7 +928,7 @@ int main(int argc, char *argv[])
break;
case '?':
_usage(argv[0], stderr);
- exit(EXIT_SUCCESS);
+ exit(EXIT_FAILURE);
case 'B': /* --binary */
ls.lvm_binary = optarg;
server = 1;
9 years
master - lvmpolld: add long option variants for all short ones
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d34de2d91270a1...
Commit: d34de2d91270a1f3cd427e1dab4a6df8789de7e5
Parent: b91e1ea95ec3b1196eade0bbd9f539bf3c7c460a
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 19:18:32 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:34 2015 +0200
lvmpolld: add long option variants for all short ones
---
daemons/lvmpolld/lvmpolld-core.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c
index 5385a04..a141d77 100644
--- a/daemons/lvmpolld/lvmpolld-core.c
+++ b/daemons/lvmpolld/lvmpolld-core.c
@@ -65,17 +65,17 @@ static const char *_strerror_r(int errnum, struct lvmpolld_thread_data *data)
static void _usage(const char *prog, FILE *file)
{
fprintf(file, "Usage:\n"
- "%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path]\n"
+ "%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path] [-B path] [-p path] [-t secs]\n"
"%s --dump [-s path]\n"
- " -V Show version info\n"
- " -h Show this help information\n"
- " -f Don't fork, run in the foreground\n"
- " --dump Dump full lvmpolld state\n"
- " -l Logging message level (-l {all|wire|debug})\n"
- " -p Set path to the pidfile\n"
- " -s Set path to the communication socket\n"
- " -B Path to lvm2 binary\n"
- " -t Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog, prog);
+ " -V|--version Show version info\n"
+ " -h|--help Show this help information\n"
+ " -f|--foreground Don't fork, run in the foreground\n"
+ " --dump Dump full lvmpolld state\n"
+ " -l|--log Logging message level (-l {all|wire|debug})\n"
+ " -p|--pidfile Set path to the pidfile\n"
+ " -s|--socket Set path to the communication socket\n"
+ " -B|--binary Path to lvm2 binary\n"
+ " -t|--timeout Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog, prog);
}
static int _init(struct daemon_state *s)
@@ -882,8 +882,13 @@ static struct option long_options[] = {
{"dump", no_argument, &action_idx, ACTION_DUMP }, /* or an option_index ? */
/* other options */
+ {"binary", required_argument, 0, 'B' },
+ {"foreground", no_argument, 0, 'f' },
{"help", no_argument, 0, 'h' },
+ {"log", required_argument, 0, 'l' },
+ {"pidfile", required_argument, 0, 'p' },
{"socket", required_argument, 0, 's' },
+ {"timeout", required_argument, 0, 't' },
{"version", no_argument, 0, 'V' },
{0, 0, 0, 0 }
};
@@ -928,21 +933,21 @@ int main(int argc, char *argv[])
ls.lvm_binary = optarg;
server = 1;
break;
- case 'V':
+ case 'V': /* --version */
printf("lvmpolld version: " LVM_VERSION "\n");
exit(EXIT_SUCCESS);
- case 'f':
+ case 'f': /* --foreground */
s.foreground = 1;
server = 1;
break;
- case 'h':
+ case 'h': /* --help */
_usage(argv[0], stdout);
exit(EXIT_SUCCESS);
- case 'l':
+ case 'l': /* --log */
ls.log_config = optarg;
server = 1;
break;
- case 'p':
+ case 'p': /* --pidfile */
s.pidfile = optarg;
server = 1;
break;
9 years
master - lvmpolld: introduce client functionality
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b91e1ea95ec3b1...
Commit: b91e1ea95ec3b1196eade0bbd9f539bf3c7c460a
Parent: 04c77bd8863b071b9e376c76708af6cede596a45
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 18:47:25 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:27 2015 +0200
lvmpolld: introduce client functionality
as of now lvmpolld works as client utility for
querying running instance of lvmpolld server
on metadata, state, etc.
Currently the only request implemented is the '--dump'.
It prints out full lvmpolld state (mimics lvmdump -p command).
---
WHATS_NEW | 1 +
daemons/lvmpolld/lvmpolld-core.c | 231 ++++++++++++++++++++++++++++++++------
2 files changed, 197 insertions(+), 35 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e92c01a..13a034b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.120 -
===============================
+ add lvmpolld client mode for querying running server instance for status info.
Fix some libdaemon socket creation and reuse error paths.
Daemons (libdaemon) support exit on idle also in non-systemd environment.
Provide make dist and make rpm targets
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c
index ad6f5f7..5385a04 100644
--- a/daemons/lvmpolld/lvmpolld-core.c
+++ b/daemons/lvmpolld/lvmpolld-core.c
@@ -18,6 +18,7 @@
#include "daemon-server.h"
#include "daemon-log.h"
+#include <getopt.h>
#include <poll.h>
#include <wait.h>
@@ -61,21 +62,23 @@ static const char *_strerror_r(int errnum, struct lvmpolld_thread_data *data)
#endif
}
-static void usage(const char *prog, FILE *file)
+static void _usage(const char *prog, FILE *file)
{
fprintf(file, "Usage:\n"
- "%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path]\n\n"
+ "%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path]\n"
+ "%s --dump [-s path]\n"
" -V Show version info\n"
" -h Show this help information\n"
" -f Don't fork, run in the foreground\n"
+ " --dump Dump full lvmpolld state\n"
" -l Logging message level (-l {all|wire|debug})\n"
" -p Set path to the pidfile\n"
- " -s Set path to the socket to listen on\n"
+ " -s Set path to the communication socket\n"
" -B Path to lvm2 binary\n"
- " -t Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog);
+ " -t Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog, prog);
}
-static int init(struct daemon_state *s)
+static int _init(struct daemon_state *s)
{
struct lvmpolld_state *ls = s->private;
ls->log = s->log;
@@ -109,35 +112,35 @@ static int init(struct daemon_state *s)
return 1;
}
-static void lvmpolld_stores_lock(struct lvmpolld_state *ls)
+static void _lvmpolld_stores_lock(struct lvmpolld_state *ls)
{
pdst_lock(ls->id_to_pdlv_poll);
pdst_lock(ls->id_to_pdlv_abort);
}
-static void lvmpolld_stores_unlock(struct lvmpolld_state *ls)
+static void _lvmpolld_stores_unlock(struct lvmpolld_state *ls)
{
pdst_unlock(ls->id_to_pdlv_abort);
pdst_unlock(ls->id_to_pdlv_poll);
}
-static void lvmpolld_global_lock(struct lvmpolld_state *ls)
+static void _lvmpolld_global_lock(struct lvmpolld_state *ls)
{
- lvmpolld_stores_lock(ls);
+ _lvmpolld_stores_lock(ls);
pdst_locked_lock_all_pdlvs(ls->id_to_pdlv_poll);
pdst_locked_lock_all_pdlvs(ls->id_to_pdlv_abort);
}
-static void lvmpolld_global_unlock(struct lvmpolld_state *ls)
+static void _lvmpolld_global_unlock(struct lvmpolld_state *ls)
{
pdst_locked_unlock_all_pdlvs(ls->id_to_pdlv_abort);
pdst_locked_unlock_all_pdlvs(ls->id_to_pdlv_poll);
- lvmpolld_stores_unlock(ls);
+ _lvmpolld_stores_unlock(ls);
}
-static int fini(struct daemon_state *s)
+static int _fini(struct daemon_state *s)
{
int done;
const struct timespec t = { .tv_nsec = 250000000 }; /* .25 sec */
@@ -147,18 +150,18 @@ static int fini(struct daemon_state *s)
DEBUGLOG(s, "sending cancel requests");
- lvmpolld_global_lock(ls);
+ _lvmpolld_global_lock(ls);
pdst_locked_send_cancel(ls->id_to_pdlv_poll);
pdst_locked_send_cancel(ls->id_to_pdlv_abort);
- lvmpolld_global_unlock(ls);
+ _lvmpolld_global_unlock(ls);
DEBUGLOG(s, "waiting for background threads to finish");
while(1) {
- lvmpolld_stores_lock(ls);
+ _lvmpolld_stores_lock(ls);
done = !pdst_locked_get_active_count(ls->id_to_pdlv_poll) &&
!pdst_locked_get_active_count(ls->id_to_pdlv_abort);
- lvmpolld_stores_unlock(ls);
+ _lvmpolld_stores_unlock(ls);
if (done)
break;
nanosleep(&t, NULL);
@@ -166,10 +169,10 @@ static int fini(struct daemon_state *s)
DEBUGLOG(s, "destroying internal data structures");
- lvmpolld_stores_lock(ls);
+ _lvmpolld_stores_lock(ls);
pdst_locked_destroy_all_pdlvs(ls->id_to_pdlv_poll);
pdst_locked_destroy_all_pdlvs(ls->id_to_pdlv_abort);
- lvmpolld_stores_unlock(ls);
+ _lvmpolld_stores_unlock(ls);
pdst_destroy(ls->id_to_pdlv_poll);
pdst_destroy(ls->id_to_pdlv_abort);
@@ -199,12 +202,12 @@ static void update_idle_state(struct lvmpolld_state *ls)
if (!ls->idle)
return;
- lvmpolld_stores_lock(ls);
+ _lvmpolld_stores_lock(ls);
ls->idle->is_idle = !pdst_locked_get_active_count(ls->id_to_pdlv_poll) &&
!pdst_locked_get_active_count(ls->id_to_pdlv_abort);
- lvmpolld_stores_unlock(ls);
+ _lvmpolld_stores_unlock(ls);
DEBUGLOG(ls, "%s: %s %s%s", PD_LOG_PREFIX, "daemon is", ls->idle->is_idle ? "" : "not ", "idle");
}
@@ -703,7 +706,7 @@ static response dump_state(client_handle h, struct lvmpolld_state *ls, request r
buffer_init(b);
- lvmpolld_global_lock(ls);
+ _lvmpolld_global_lock(ls);
buffer_append(b, "# Registered polling operations\n\n");
buffer_append(b, "poll {\n");
@@ -715,12 +718,12 @@ static response dump_state(client_handle h, struct lvmpolld_state *ls, request r
pdst_locked_dump(ls->id_to_pdlv_abort, b);
buffer_append(b, "}");
- lvmpolld_global_unlock(ls);
+ _lvmpolld_global_unlock(ls);
return res;
}
-static response handler(struct daemon_state s, client_handle h, request r)
+static response _handler(struct daemon_state s, client_handle h, request r)
{
struct lvmpolld_state *ls = s.private;
const char *rq = daemon_request_str(r, "request", "NONE");
@@ -755,16 +758,149 @@ static int process_timeout_arg(const char *str, unsigned *max_timeouts)
return 1;
}
+/* Client functionality */
+typedef int (*action_fn_t) (void *args);
+
+struct log_line_baton {
+ const char *prefix;
+};
+
+daemon_handle _lvmpolld = { .error = 0 };
+
+static daemon_handle _lvmpolld_open(const char *socket)
+{
+ daemon_info lvmpolld_info = {
+ .path = "lvmpolld",
+ .socket = socket ?: DEFAULT_RUN_DIR "/lvmpolld.socket",
+ .protocol = LVMPOLLD_PROTOCOL,
+ .protocol_version = LVMPOLLD_PROTOCOL_VERSION
+ };
+
+ return daemon_open(lvmpolld_info);
+}
+
+static void _log_line(const char *line, void *baton) {
+ struct log_line_baton *b = baton;
+ fprintf(stdout, "%s%s\n", b->prefix, line);
+}
+
+static int printout_raw_response(const char *prefix, const char *msg)
+{
+ struct log_line_baton b = { .prefix = prefix };
+ char *buf;
+ char *pos;
+
+ buf = dm_strdup(msg);
+ pos = buf;
+
+ if (!buf)
+ return 0;
+
+ while (pos) {
+ char *next = strchr(pos, '\n');
+ if (next)
+ *next = 0;
+ _log_line(pos, &b);
+ pos = next ? next + 1 : 0;
+ }
+ dm_free(buf);
+
+ return 1;
+}
+
+/* place all action implementations below */
+
+static int action_dump(void *args __attribute__((unused)))
+{
+ daemon_request req;
+ daemon_reply repl;
+ int r = 0;
+
+ req = daemon_request_make(LVMPD_REQ_DUMP);
+ if (!req.cft) {
+ fprintf(stderr, "Failed to create lvmpolld " LVMPD_REQ_DUMP " request.\n");
+ goto out_req;
+ }
+
+ repl = daemon_send(_lvmpolld, req);
+ if (repl.error) {
+ fprintf(stderr, "Failed to send a request or receive response.\n");
+ goto out_rep;
+ }
+
+ /*
+ * This is dumb copy & paste from libdaemon log routines.
+ */
+ if (!printout_raw_response(" ", repl.buffer.mem)) {
+ fprintf(stderr, "Failed to print out the response.\n");
+ goto out_rep;
+ }
+
+ r = 1;
+
+out_rep:
+ daemon_reply_destroy(repl);
+out_req:
+ daemon_request_destroy(req);
+
+ return r;
+}
+
+enum action_index {
+ ACTION_DUMP = 0,
+ ACTION_MAX /* keep at the end */
+};
+
+static const action_fn_t const actions[] = { [ACTION_DUMP] = action_dump };
+
+static int _make_action(enum action_index idx, void *args)
+{
+ return idx < ACTION_MAX ? actions[idx](args) : 0;
+}
+
+static int _lvmpolld_client(const char *socket, unsigned action)
+{
+ int r;
+
+ _lvmpolld = _lvmpolld_open(socket);
+
+ if (_lvmpolld.error || _lvmpolld.socket_fd < 0) {
+ fprintf(stderr, "Failed to establish connection with lvmpolld.\n");
+ return 0;
+ }
+
+ r = _make_action(action, NULL);
+
+ daemon_close(_lvmpolld);
+
+ return r ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+static int action_idx = ACTION_MAX;
+static struct option long_options[] = {
+ /* Have actions always at the beginning of the array. */
+ {"dump", no_argument, &action_idx, ACTION_DUMP }, /* or an option_index ? */
+
+ /* other options */
+ {"help", no_argument, 0, 'h' },
+ {"socket", required_argument, 0, 's' },
+ {"version", no_argument, 0, 'V' },
+ {0, 0, 0, 0 }
+};
+
int main(int argc, char *argv[])
{
- signed char opt;
+ int opt;
+ int option_index = 0;
+ int client = 0, server = 0;
+ unsigned action = ACTION_MAX;
struct timeval timeout;
daemon_idle di = { .ptimeout = &timeout };
struct lvmpolld_state ls = { .log_config = "" };
daemon_state s = {
- .daemon_fini = fini,
- .daemon_init = init,
- .handler = handler,
+ .daemon_fini = _fini,
+ .daemon_init = _init,
+ .handler = _handler,
.name = "lvmpolld",
.pidfile = getenv("LVM_LVMPOLLD_PIDFILE") ?: LVMPOLLD_PIDFILE,
.private = &ls,
@@ -773,28 +909,42 @@ int main(int argc, char *argv[])
.socket_path = getenv("LVM_LVMPOLLD_SOCKET") ?: LVMPOLLD_SOCKET,
};
- while ((opt = getopt(argc, argv, "?fhVl:p:s:B:t:")) != EOF) {
+ while ((opt = getopt_long(argc, argv, "?fhVl:p:s:B:t:", long_options, &option_index)) != -1) {
switch (opt) {
+ case 0 :
+ if (action < ACTION_MAX) {
+ fprintf(stderr, "Can't perform more actions. Action already requested: %s\n",
+ long_options[action].name);
+ _usage(argv[0], stderr);
+ exit(EXIT_FAILURE);
+ }
+ action = action_idx;
+ client = 1;
+ break;
case '?':
- usage(argv[0], stderr);
- exit(0);
+ _usage(argv[0], stderr);
+ exit(EXIT_SUCCESS);
case 'B': /* --binary */
ls.lvm_binary = optarg;
+ server = 1;
break;
case 'V':
printf("lvmpolld version: " LVM_VERSION "\n");
- exit(1);
+ exit(EXIT_SUCCESS);
case 'f':
s.foreground = 1;
+ server = 1;
break;
case 'h':
- usage(argv[0], stdout);
- exit(0);
+ _usage(argv[0], stdout);
+ exit(EXIT_SUCCESS);
case 'l':
ls.log_config = optarg;
+ server = 1;
break;
case 'p':
s.pidfile = optarg;
+ server = 1;
break;
case 's': /* --socket */
s.socket_path = optarg;
@@ -802,16 +952,27 @@ int main(int argc, char *argv[])
case 't': /* --timeout in seconds */
if (!process_timeout_arg(optarg, &di.max_timeouts)) {
fprintf(stderr, "Invalid value of timeout parameter");
- exit(1);
+ exit(EXIT_FAILURE);
}
/* 0 equals to wait indefinitely */
if (di.max_timeouts)
s.idle = ls.idle = &di;
+ server = 1;
break;
}
}
+ if (client && server) {
+ fprintf(stderr, "Invalid combination of client and server parameters.\n\n");
+ _usage(argv[0], stdout);
+ exit(EXIT_FAILURE);
+ }
+
+ if (client)
+ return _lvmpolld_client(s.socket_path, action);
+
+ /* Server */
daemon_start(s);
- return 0;
+ return EXIT_SUCCESS;
}
9 years
master - pvmove.c: relocate id components extraction
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=04c77bd8863b07...
Commit: 04c77bd8863b071b9e376c76708af6cede596a45
Parent: 67657f1ff938b2afd17ab0ce6476a561725a6781
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 17:06:14 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:21 2015 +0200
pvmove.c: relocate id components extraction
we don't want to fail properly set pvmove after metadata
update. failure to copy id components could end with dangling
mirror moving PV segments but no monitoring from lvmpolld or
classical polldaemon.
---
tools/pvmove.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 202c87c..94a5ffc 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -686,13 +686,13 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
/* init_pvmove(1); */
/* vg->status |= PVMOVE; */
+ if (!_copy_id_components(cmd, lv_mirr, vg_name, lv_mirr_name, lvid))
+ goto out;
+
if (flags & PVMOVE_FIRST_TIME)
if (!_update_metadata(cmd, vg, lv_mirr, lvs_changed, exclusive))
goto_out;
- if (!_copy_id_components(cmd, lv_mirr, vg_name, lv_mirr_name, lvid))
- goto out;
-
/* LVs are all in status LOCKED */
r = ECMD_PROCESSED;
out:
9 years
master - lvpoll.c: harden the checks for proper LV name
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=67657f1ff938b2...
Commit: 67657f1ff938b2afd17ab0ce6476a561725a6781
Parent: ba120640b2db0acf166d60046cd3b0afdf7774b0
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 16:35:00 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:10 2015 +0200
lvpoll.c: harden the checks for proper LV name
lvpoll now process passed LV name properly. It respects
LVM_VG_NAME env. variable and is able to process LV name
passed in various formats:
- VG/LV
- LV name only (with LVM_VG_NAME set)
- /dev/mapper/VG-LV
- /dev/VG/LV
---
tools/lvpoll.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/lvpoll.c b/tools/lvpoll.c
index 945e5d1..0ed2d45 100644
--- a/tools/lvpoll.c
+++ b/tools/lvpoll.c
@@ -83,11 +83,17 @@ static int poll_lv(struct cmd_context *cmd, const char *lv_name)
{
struct daemon_parms parms = { 0 };
struct poll_operation_id id = {
- .vg_name = extract_vgname(cmd, lv_name),
- .lv_name = strchr(lv_name, '/') + 1,
- .display_name = lv_name
+ .display_name = skip_dev_dir(cmd, lv_name, NULL)
};
+ if (!id.display_name)
+ return_EINVALID_CMD_LINE;
+
+ id.lv_name = id.display_name;
+
+ if (!validate_lvname_param(cmd, &id.vg_name, &id.lv_name))
+ return_EINVALID_CMD_LINE;
+
if (!_set_daemon_parms(cmd, &parms))
return_EINVALID_CMD_LINE;
@@ -106,8 +112,8 @@ int lvpoll(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (!argc || !strchr(argv[0], '/')) {
- log_error("Provide full VG/LV name");
+ if (!argc) {
+ log_error("Provide LV name");
return EINVALID_CMD_LINE;
}
9 years
master - lvpoll.c: replace arg_count with arg_is_set
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ba120640b2db0a...
Commit: ba120640b2db0acf166d60046cd3b0afdf7774b0
Parent: 0d15217a6c08d99314324469f42ad9b8cd0baccc
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 16:45:02 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:33:04 2015 +0200
lvpoll.c: replace arg_count with arg_is_set
didn't need to count the occurence but check if set
---
tools/lvpoll.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/lvpoll.c b/tools/lvpoll.c
index 6db0ade..945e5d1 100644
--- a/tools/lvpoll.c
+++ b/tools/lvpoll.c
@@ -52,7 +52,7 @@ static int _set_daemon_parms(struct cmd_context *cmd, struct daemon_parms *parms
const char *poll_oper = arg_str_value(cmd, polloperation_ARG, "");
parms->interval = arg_uint_value(cmd, interval_ARG, 0);
- parms->aborting = arg_count(cmd, abort_ARG);
+ parms->aborting = arg_is_set(cmd, abort_ARG);
parms->progress_display = 1;
parms->wait_before_testing = (arg_sign_value(cmd, interval_ARG, SIGN_NONE) == SIGN_PLUS);
@@ -74,7 +74,7 @@ static int _set_daemon_parms(struct cmd_context *cmd, struct daemon_parms *parms
return 0;
}
- cmd->handles_missing_pvs = arg_count(cmd, handlemissingpvs_ARG);
+ cmd->handles_missing_pvs = arg_is_set(cmd, handlemissingpvs_ARG);
return 1;
}
@@ -96,7 +96,7 @@ static int poll_lv(struct cmd_context *cmd, const char *lv_name)
int lvpoll(struct cmd_context *cmd, int argc, char **argv)
{
- if (!arg_count(cmd, polloperation_ARG)) {
+ if (!arg_is_set(cmd, polloperation_ARG)) {
log_error("--polloperation parameter is mandatory");
return EINVALID_CMD_LINE;
}
9 years
master - example.conf.in: apply previous improvements to example.conf
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0d15217a6c08d9...
Commit: 0d15217a6c08d99314324469f42ad9b8cd0baccc
Parent: 9f0095fa2c2c3ceb542be7d3da54072dd6c2bef5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri May 15 14:28:30 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:32:58 2015 +0200
example.conf.in: apply previous improvements to example.conf
---
conf/example.conf.in | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index cc02e98..e809488 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -939,14 +939,16 @@ global {
# This configuration option does not have a default value defined.
# system_id_file = ""
- # Indicates whether to use lvmpolld instead of classical polldaemon (a process
- # forked off an initiating lvm command) or not. When set to 1 and native systemd
- # service is installed in the system lvm starts using lvmpolld. lvmpolld gets
- # auto-activated by systemd when a message lands on the respective lvmpolld socket.
- # All commands that would require polling of in-progress operation are therefore
- # spawned in lvmpolld's service cgroup.
- #
- # When set to 0 lvm falls back to classical polling.
+ # Use lvmpolld to supervise long running LVM commands.
+ # When enabled, control of long running LVM commands is transferred
+ # from the original LVM command to the lvmpolld daemon. This allows
+ # the operation to continue independent of the original LVM command.
+ # After lvmpolld takes over, the LVM command displays the progress
+ # of the ongoing operation. lvmpolld itself runs LVM commands to manage
+ # the progress of ongoing operations. lvmpolld can be used as a native
+ # systemd service, which allows it to be started on demand, and to use
+ # its own control group. When this option is disabled, LVM commands will
+ # supervise long running operations by forking themselves.
use_lvmpolld = @DEFAULT_USE_LVMPOLLD@
}
9 years
master - config_settings.h: improve lvmpolld config description
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f0095fa2c2c3c...
Commit: 9f0095fa2c2c3ceb542be7d3da54072dd6c2bef5
Parent: bf19bbbd5596ea55111678c56087672ee1b72c11
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri May 15 14:26:50 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:32:51 2015 +0200
config_settings.h: improve lvmpolld config description
---
lib/config/config_settings.h | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index cfcc72e..4e1c126 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -937,13 +937,16 @@ cfg(activation_checks_CFG, "checks", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, D
"this only when there seems to be a problem.\n")
cfg(global_use_lvmpolld_CFG, "use_lvmpolld", global_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_USE_LVMPOLLD, vsn(2, 2, 120), NULL, 0, NULL,
- "Indicates whether to use lvmpolld instead of classical polldaemon (a process\n"
- "forked off an initiating lvm command) or not. When set to 1 and native systemd\n"
- "service is installed in the system lvm starts using lvmpolld. lvmpolld gets\n"
- "auto-activated by systemd when a message lands on the respective lvmpolld socket.\n"
- "All commands that would require polling of in-progress operation are therefore\n"
- "spawned in lvmpolld's service cgroup.\n"
- "When set to 0 lvm falls back to classical polling.\n")
+ "Use lvmpolld to supervise long running LVM commands.\n"
+ "When enabled, control of long running LVM commands is transferred\n"
+ "from the original LVM command to the lvmpolld daemon. This allows\n"
+ "the operation to continue independent of the original LVM command.\n"
+ "After lvmpolld takes over, the LVM command displays the progress\n"
+ "of the ongoing operation. lvmpolld itself runs LVM commands to manage\n"
+ "the progress of ongoing operations. lvmpolld can be used as a native\n"
+ "systemd service, which allows it to be started on demand, and to use\n"
+ "its own control group. When this option is disabled, LVM commands will\n"
+ "supervise long running operations by forking themselves.\n")
cfg(activation_udev_sync_CFG, "udev_sync", activation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_UDEV_SYNC, vsn(2, 2, 51), NULL, 0, NULL,
"Use udev notifications to synchronize udev and LVM.\n"
9 years
master - lvm.8.in: add reference to lvpoll built-in command
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bf19bbbd5596ea...
Commit: bf19bbbd5596ea55111678c56087672ee1b72c11
Parent: 4f1c1f3d6bfa08b554caea0aae5590613c5ef05b
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Fri May 15 13:38:55 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Fri May 15 20:32:39 2015 +0200
lvm.8.in: add reference to lvpoll built-in command
---
man/lvm.8.in | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/man/lvm.8.in b/man/lvm.8.in
index 28769d2..89b7efe 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -53,6 +53,8 @@ being created in the filesystem for them.
.TP
\fBhelp\fP \(em Display the help text.
.TP
+\fBlvpoll\fP \(em Internal command used by lvmpolld to complete some Logical Volume operations.
+.TP
\fBpvdata\fP \(em Not implemented in LVM2.
.TP
\fBsegtypes\fP \(em Display recognised Logical Volume segment types.
9 years