]> sourceware.org Git - lvm2.git/commitdiff
lvscan: Implement a --cache mode.
authorPetr Rockai <prockai@redhat.com>
Mon, 21 Jul 2014 01:55:46 +0000 (03:55 +0200)
committerPetr Rockai <prockai@redhat.com>
Tue, 22 Jul 2014 20:48:21 +0000 (22:48 +0200)
tools/commands.h
tools/lvscan.c

index 1f9d03ca2e3aa43f965d031c33fc4907b05550e9..6e115d91713b175589742ec8ab1603ef9c5c3f22 100644 (file)
@@ -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)",
index 2641054981791bf9045632741507c71631d0d437..df8a12efd63cc691b0bb83b7a6d69e98bf2ca904 100644 (file)
 
 #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;
        }
This page took 0.498511 seconds and 5 git commands to generate.