diff options
author | Ondrej Kozina <okozina@redhat.com> | 2016-03-10 13:02:30 +0100 |
---|---|---|
committer | Ondrej Kozina <okozina@redhat.com> | 2016-03-10 13:02:30 +0100 |
commit | 3d3d55f54d22137ad2cd6d9be4dc0df0f526f06c (patch) | |
tree | 885a99f3fdb0b48a00751d07fd3f11bfd3a7a021 | |
parent | 321a8b5a2fe15cfc84800392fa569b90d23ee4c0 (diff) | |
download | lvm2-3d3d55f54d22137ad2cd6d9be4dc0df0f526f06c.tar.gz |
lvmpolld: store info about initiating lvm command
-rw-r--r-- | daemons/lvmpolld/lvmpolld-core.c | 3 | ||||
-rw-r--r-- | daemons/lvmpolld/lvmpolld-data-utils.c | 10 | ||||
-rw-r--r-- | daemons/lvmpolld/lvmpolld-data-utils.h | 3 | ||||
-rw-r--r-- | daemons/lvmpolld/lvmpolld-protocol.h | 1 |
4 files changed, 13 insertions, 4 deletions
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c index e3b542d13..30d87cf87 100644 --- a/daemons/lvmpolld/lvmpolld-core.c +++ b/daemons/lvmpolld/lvmpolld-core.c @@ -618,10 +618,11 @@ static struct lvmpolld_lv *construct_pdlv(request req, struct lvmpolld_state *ls { const char **cmdargv, **cmdenvp; struct lvmpolld_lv *pdlv; + const char *cmdline = daemon_request_str(req, LVMPD_PARM_CMDLINE, NULL); unsigned handle_missing_pvs = daemon_request_int(req, LVMPD_PARM_HANDLE_MISSING_PVS, 0); pdlv = pdlv_create(ls, id, vgname, lvname, sysdir, type, - interval, uinterval, pdst, + interval, uinterval, pdst, cmdline, abort_polling ? NULL : parse_percents); if (!pdlv) { diff --git a/daemons/lvmpolld/lvmpolld-data-utils.c b/daemons/lvmpolld/lvmpolld-data-utils.c index d1599f4eb..0103f7835 100644 --- a/daemons/lvmpolld/lvmpolld-data-utils.c +++ b/daemons/lvmpolld/lvmpolld-data-utils.c @@ -91,12 +91,13 @@ struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id, const char *vgname, const char *lvname, const char *sysdir, enum poll_type type, const char *sinterval, unsigned pdtimeout, - struct lvmpolld_store *pdst, + struct lvmpolld_store *pdst, const char *cmd_line, lvmpolld_parse_output_fn_t parse_fn) { char *lvmpolld_id = dm_strdup(id), /* copy */ *full_lvname = _construct_full_lvname(vgname, lvname), /* copy */ - *lvm_system_dir_env = _construct_lvm_system_dir_env(sysdir); /* copy */ + *lvm_system_dir_env = _construct_lvm_system_dir_env(sysdir), /* copy */ + *cmdline = cmd_line ? dm_strdup(cmd_line) : NULL; /* copy */ struct lvmpolld_lv tmp = { .ls = ls, @@ -109,6 +110,7 @@ struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id, .pdtimeout = pdtimeout < MIN_POLLING_TIMEOUT ? MIN_POLLING_TIMEOUT : pdtimeout, .cmd_state = { .retcode = -1, .signal = 0 }, .pdst = pdst, + .cmdline = cmdline, .init_rq_count = 1, .parse_output_fn = parse_fn }, *pdlv = (struct lvmpolld_lv *) dm_malloc(sizeof(struct lvmpolld_lv)); @@ -128,6 +130,7 @@ err: dm_free((void *)lvmpolld_id); dm_free((void *)lvm_system_dir_env); dm_free((void *)tmp.sinterval); + dm_free((void *)cmdline); dm_free((void *)pdlv); return NULL; @@ -141,6 +144,7 @@ void pdlv_destroy(struct lvmpolld_lv *pdlv) dm_free((void *)pdlv->lvm_system_dir_env); dm_free((void *)pdlv->cmdargv); dm_free((void *)pdlv->cmdenvp); + dm_free((void *)pdlv->cmdline); pthread_mutex_destroy(&pdlv->lock); @@ -281,6 +285,8 @@ static void _pdlv_locked_dump(struct buffer *buff, const struct lvmpolld_lv *pdl buffer_append(buff, tmp); if (dm_snprintf(tmp, sizeof(tmp), "\t\tpercent_complete=%.1f\n", dm_percent_to_float(pdlv->percent)) > 0) buffer_append(buff, tmp); + if (dm_snprintf(tmp, sizeof(tmp), "\t\tinitiating_lvm_cmd=\"%s\"\n", pdlv->cmdline ?: "<undefined>") > 0) + buffer_append(buff, tmp); /* lvm_commmand-section { */ buffer_append(buff, "\t\tlvm_command {\n"); diff --git a/daemons/lvmpolld/lvmpolld-data-utils.h b/daemons/lvmpolld/lvmpolld-data-utils.h index 90522b328..db536ead8 100644 --- a/daemons/lvmpolld/lvmpolld-data-utils.h +++ b/daemons/lvmpolld/lvmpolld-data-utils.h @@ -50,6 +50,7 @@ struct lvmpolld_lv { */ struct lvmpolld_state *const ls; const enum poll_type type; + const char *const cmdline; /* full lvm2 command which initiated polling */ const char *const lvid; const char *const lvmpolld_id; const char *const lvname; /* full vg/lv name */ @@ -104,7 +105,7 @@ struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id, const char *vgname, const char *lvname, const char *sysdir, enum poll_type type, const char *sinterval, unsigned pdtimeout, - struct lvmpolld_store *pdst, + struct lvmpolld_store *pdst, const char *cmd_line, lvmpolld_parse_output_fn_t parse_fn); /* only call with appropriate struct lvmpolld_store lock held */ diff --git a/daemons/lvmpolld/lvmpolld-protocol.h b/daemons/lvmpolld/lvmpolld-protocol.h index 95853902c..ead333559 100644 --- a/daemons/lvmpolld/lvmpolld-protocol.h +++ b/daemons/lvmpolld/lvmpolld-protocol.h @@ -29,6 +29,7 @@ #define LVMPD_REQ_PVMOVE PVMOVE_POLL #define LVMPD_PARM_ABORT "abort" +#define LVMPD_PARM_CMDLINE "cmdline" #define LVMPD_PARM_HANDLE_MISSING_PVS "handle_missing_pvs" #define LVMPD_PARM_INTERVAL "interval" #define LVMPD_PARM_LVID "lvid" |