diff options
author | Ondrej Kozina <okozina@redhat.com> | 2015-02-16 17:23:20 +0100 |
---|---|---|
committer | Ondrej Kozina <okozina@redhat.com> | 2015-04-01 11:01:22 +0200 |
commit | 0a00ceaea4ec53a758760c2c03e6b13c562ba8e0 (patch) | |
tree | 53359fbd95aa9051a27bc141514845fdc6a9f54a | |
parent | 956bcf5ebf80083f2b364964e669747cdfccea26 (diff) | |
download | lvm2-0a00ceaea4ec53a758760c2c03e6b13c562ba8e0.tar.gz |
lvpoll: poll by vg/lv fullname instead of by uuid
removed --uuid parameter. the use case with lvpoll command
was invalid
since we can poll pvmove operation by vg/lv name now. It's useless
to maintain custom code in lvpoll and we can use wait_for_single_lv
code from polldaemon.
-rw-r--r-- | tools/commands.h | 3 | ||||
-rw-r--r-- | tools/lvpoll.c | 114 |
2 files changed, 23 insertions, 94 deletions
diff --git a/tools/commands.h b/tools/commands.h index 5fe15df4e..abb60b152 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -819,7 +819,6 @@ xx(lvpoll, "Resume poll operation on logical volume", 0, "\t[--abort]\n" - "\t[-u|--uuid]\n" "\t[-p|--poll-operation\n" "\t[-d|--debug]\n " "\t[-h|-?|--help]\n" @@ -829,7 +828,7 @@ xx(lvpoll, "\t[-v|--verbose]\n " "\t[--version]\n", - abort_ARG, handlemissingpvs_ARG, interval_ARG, polloperation_ARG, uuidstr_ARG, + abort_ARG, handlemissingpvs_ARG, interval_ARG, polloperation_ARG, test_ARG) xx(pvremove, diff --git a/tools/lvpoll.c b/tools/lvpoll.c index 012abb8af..beb66e7b0 100644 --- a/tools/lvpoll.c +++ b/tools/lvpoll.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * Copyright (C) 2015 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -19,57 +19,35 @@ #include "polling_ops.h" static struct poll_functions _pvmove_fns = { + .get_copy_lv = poll_get_copy_lv, + .get_copy_vg = poll_get_copy_vg, .poll_progress = poll_mirror_progress, .update_metadata = pvmove_update_metadata, .finish_copy = finish_pvmove }; static struct poll_functions _convert_fns = { + .get_copy_lv = poll_get_copy_lv, + .get_copy_vg = poll_get_copy_vg, .poll_progress = poll_mirror_progress, - .finish_copy = finish_lvconvert_mirror + .finish_copy = lvconvert_mirror_finish }; static struct poll_functions _merge_fns = { + .get_copy_lv = poll_get_copy_lv, + .get_copy_vg = poll_get_copy_vg, .poll_progress = poll_merge_progress, .finish_copy = finish_lvconvert_merge }; static struct poll_functions _thin_merge_fns = { + .get_copy_lv = poll_get_copy_lv, + .get_copy_vg = poll_get_copy_vg, .poll_progress = poll_thin_merge_progress, .finish_copy = finish_lvconvert_merge }; -static int poll_lv_by_lvid(struct cmd_context *cmd, - struct volume_group *vg, - struct daemon_parms *parms, - union lvid *lvid) -{ - int finished; - struct logical_volume *lv; - struct lv_list *lvl; - - dm_list_iterate_items(lvl, &vg->lvs) { - lv = lvl->lv; - /* PVMOVE LVs have lv_uuid zeroed, any operation initiated by lvconvert has lv_type == 0 */ - if ((parms->lv_type && !(lv->status & parms->lv_type)) || - (*lvid->id[1].uuid && - !id_equal(&lvid->id[1], &lv->lvid.id[1]))) - continue; - - log_verbose("Found requested LV"); - - /* I don't care about device name */ - if (!check_lv_status(cmd, vg, lv, "none", parms, &finished)) - return 0; - - if (!finished) - parms->outstanding_count++; - } - - return 1; -} - -static int set_daemon_parms(struct cmd_context *cmd, struct daemon_parms *parms) +static int _set_daemon_parms(struct cmd_context *cmd, struct daemon_parms *parms) { const char *poll_oper = arg_str_value(cmd, polloperation_ARG, ""); @@ -101,71 +79,23 @@ static int set_daemon_parms(struct cmd_context *cmd, struct daemon_parms *parms) return 1; } -static int poll_vg(struct cmd_context *cmd, const char *vgname) +static int poll_lv(struct cmd_context *cmd, const char *lv_name) { - int finished = 0, r; - struct volume_group *vg; - union lvid lvid; 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 + }; - if (!set_daemon_parms(cmd, &parms)) - return EINVALID_CMD_LINE; - - strncpy(lvid.s, arg_str_value(cmd, uuidstr_ARG, ""), sizeof(union lvid)); - lvid.s[sizeof(lvid.s) - 1] = '\0'; - - if (!id_valid(lvid.id)) { - log_error("Invalid VG UUID format"); + if (!_set_daemon_parms(cmd, &parms)) return EINVALID_CMD_LINE; - } - - if (lvid.s[ID_LEN] && !id_valid(&lvid.id[1])) { - log_error("Invalid LV UUID format"); - return EINVALID_CMD_LINE; - } - - while (!finished) { - parms.outstanding_count = 0; - if (parms.wait_before_testing) - sleep_and_rescan_devices(&parms); - - dev_close_all(); - - vg = vg_read_for_update(cmd, vgname, NULL, 0); - if (vg_read_error(vg)) { - release_vg(vg); - log_error("ABORTING: Can't reread VG %s", vgname); - return ECMD_FAILED; - } - - /* TODO: eventually replace with process_each_lv_in_vg */ - r = poll_lv_by_lvid(cmd, vg, &parms, &lvid); - - unlock_and_release_vg(cmd, vg, vg->name); - - if (!r) - return ECMD_FAILED; - - /* TODO: remove as it's perhaps useless now */ - assert(!(parms.outstanding_count > 1)); - - finished = !parms.outstanding_count; - - if (!parms.wait_before_testing && !finished) - sleep_and_rescan_devices(&parms); - } - - return ECMD_PROCESSED; + return wait_for_single_lv(cmd, &id, &parms) ? ECMD_PROCESSED : ECMD_FAILED; } int lvpoll(struct cmd_context *cmd, int argc, char **argv) { - if (!arg_count(cmd, uuidstr_ARG)) { - log_error("--uuid parameter is mandatory"); - return EINVALID_CMD_LINE; - } - if (!arg_count(cmd, polloperation_ARG)) { log_error("--poll-operation parameter is mandatory"); return EINVALID_CMD_LINE; @@ -176,13 +106,13 @@ int lvpoll(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - if (!argc) { - log_error("Provide vgname"); + if (!argc || !strchr(argv[0], '/')) { + log_error("Provide full VG/LV name"); return EINVALID_CMD_LINE; } log_print_unless_silent("LVM_SYSTEM_DIR=%s", getenv("LVM_SYSTEM_DIR") ?: "<not set>"); log_verbose("cmdline: %s", cmd->cmd_line); - return poll_vg(cmd, argv[0]); + return poll_lv(cmd, argv[0]); } |