diff options
author | Alasdair Kergon <agk@redhat.com> | 2012-03-02 16:58:41 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2012-03-02 16:58:41 +0000 |
commit | d06f64dd29a689ab0e97659a37ccb83819b75c3a (patch) | |
tree | e02578d71ce48575496b0d5a9b77aa7154423faa /tools | |
parent | 6a5706a3a52607d1d7a2517aad4ba2727e0986e2 (diff) | |
download | lvm2-d06f64dd29a689ab0e97659a37ccb83819b75c3a.tar.gz lvm2-d06f64dd29a689ab0e97659a37ccb83819b75c3a.tar.xz lvm2-d06f64dd29a689ab0e97659a37ccb83819b75c3a.zip |
Allow multiple device names with pvscan --lvmetad.
Hold global lock in pvscan --lvmetad. (This might need refinement.)
Add PV name to "PV gone" messages.
Adjust some log message severities. (More changes needed.)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/commands.h | 2 | ||||
-rw-r--r-- | tools/pvremove.c | 2 | ||||
-rw-r--r-- | tools/pvscan.c | 39 |
3 files changed, 33 insertions, 10 deletions
diff --git a/tools/commands.h b/tools/commands.h index 3a968bde..21f1adc1 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -670,7 +670,7 @@ xx(pvscan, "\t[-P|--partial] " "\n" "\t[-s|--short] " "\n" "\t[-u|--uuid] " "\n" - "\t[--lvmetad DevicePath] " "\n" + "\t[--lvmetad DevicePath [DevicePath...]] " "\n" "\t[-v|--verbose] " "\n" "\t[--version]\n", diff --git a/tools/pvremove.c b/tools/pvremove.c index efd8cb7f..f90f88a2 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -129,7 +129,7 @@ static int pvremove_single(struct cmd_context *cmd, const char *pv_name, } /* FIXME Avoid error if we expect that daemon might not know device */ - if (!lvmetad_pv_gone(dev->dev)) + if (!lvmetad_pv_gone(dev)) goto_out; log_print("Labels on physical volume \"%s\" successfully wiped", diff --git a/tools/pvscan.c b/tools/pvscan.c index 7cc9d433..3a7c8ba9 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -99,6 +99,35 @@ static void _pvscan_display_single(struct cmd_context *cmd, pv_pe_size(pv))); } +static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv) +{ + int ret = ECMD_PROCESSED; + + if (!argc) { + log_error("List of Physical Volumes to tell lvmetad to cache required."); + return EINVALID_CMD_LINE; + } + + if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) { + log_error("Unable to obtain global lock."); + return ECMD_FAILED; + } + + log_verbose("Using physical volume(s) on command line"); + while (argc--) { + if (!pvscan_lvmetad_single(cmd, *argv++)) { + ret = ECMD_FAILED; + break; + } + if (sigint_caught()) + break; + } + + unlock_vg(cmd, VG_GLOBAL); + + return ret; +} + int pvscan(struct cmd_context *cmd, int argc, char **argv) { int new_pvs_found = 0; @@ -115,20 +144,14 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv) pv_max_name_len = 0; vg_max_name_len = 0; - if (arg_count(cmd, lvmetad_ARG)) { - if (!pvscan_lvmetad(cmd, argc, argv)) { - stack; - return ECMD_FAILED; - } - return ECMD_PROCESSED; - } + if (arg_count(cmd, lvmetad_ARG)) + return _pvscan_lvmetad(cmd, argc, argv); if (arg_count(cmd, novolumegroup_ARG) && arg_count(cmd, exported_ARG)) { log_error("Options -e and -n are incompatible"); return EINVALID_CMD_LINE; } - if (arg_count(cmd, exported_ARG) || arg_count(cmd, novolumegroup_ARG)) log_warn("WARNING: only considering physical volumes %s", arg_count(cmd, exported_ARG) ? "of exported volume group(s)" : "in no volume group"); |