From: Petr Rockai Date: Mon, 21 Jul 2014 01:55:46 +0000 (+0200) Subject: lvscan: Implement a --cache mode. X-Git-Tag: v2_02_108~8 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=a9ea014e5152b806f57f6099311b64a2c03ca482;p=lvm2.git lvscan: Implement a --cache mode. --- diff --git a/tools/commands.h b/tools/commands.h index 1f9d03ca2..6e115d917 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -581,6 +581,7 @@ xx(lvscan, "lvscan " "\n" "\t[-a|--all]\n" "\t[-b|--blockdevice] " "\n" + "\t[--cache]\n" "\t[--commandprofile ProfileName]\n" "\t[-d|--debug] " "\n" "\t[-h|-?|--help] " "\n" @@ -591,7 +592,7 @@ xx(lvscan, "\t[--version]\n", all_ARG, blockdevice_ARG, ignorelockingfailure_ARG, partial_ARG, - readonly_ARG) + readonly_ARG, cache_ARG) xx(pvchange, "Change attributes of physical volume(s)", diff --git a/tools/lvscan.c b/tools/lvscan.c index 264105498..df8a12efd 100644 --- a/tools/lvscan.c +++ b/tools/lvscan.c @@ -15,6 +15,28 @@ #include "tools.h" +static int _lvscan_single_lvmetad(struct cmd_context *cmd, struct logical_volume *lv) +{ + struct pv_list *pvl; + struct dm_list pvs; + + if (!lvmetad_used()) { + log_verbose("Ignoring lvscan --cache because lvmetad is not in use."); + return ECMD_PROCESSED; + } + + dm_list_init(&pvs); + + if (!get_pv_list_for_lv(lv->vg->vgmem, lv, &pvs)) + return ECMD_FAILED; + + dm_list_iterate_items(pvl, &pvs) + if (!lvmetad_pvscan_single(cmd, pvl->pv->dev, NULL)) + return ECMD_FAILED; + + return ECMD_PROCESSED; +} + static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle __attribute__((unused))) { @@ -24,6 +46,9 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv, const char *active_str, *snapshot_str; + if (arg_count(cmd, cache_ARG)) + return _lvscan_single_lvmetad(cmd, lv); + if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; @@ -58,7 +83,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv, int lvscan(struct cmd_context *cmd, int argc, char **argv) { - if (argc) { + if (argc && !arg_count(cmd, cache_ARG)) { log_error("No additional command line arguments allowed"); return EINVALID_CMD_LINE; }