mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
lvmpolld: store info about initiating lvm command
This commit is contained in:
parent
321a8b5a2f
commit
3d3d55f54d
@ -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) {
|
||||
|
@ -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");
|
||||
|
@ -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 */
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user