]> sourceware.org Git - lvm2.git/blobdiff - tools/pvscan.c
Reinstate accidentally-deleted line.
[lvm2.git] / tools / pvscan.c
index 57882f67cdad7327195afe92abb508ec2a645221..cca079c8ef7f043d8ac87e784fd6b787aeb744f0 100644 (file)
 
 #include "tools.h"
 
+#include "lvmetad.h"
+#include "lvmcache.h"
+
 int pv_max_name_len = 0;
 int vg_max_name_len = 0;
 
 static void _pvscan_display_single(struct cmd_context *cmd,
                                   struct physical_volume *pv,
-                                  void *handle __attribute((unused)))
+                                  void *handle __attribute__((unused)))
 {
-       char uuid[64] __attribute((aligned(8)));
+       char uuid[64] __attribute__((aligned(8)));
        unsigned vg_name_len = 0;
 
        char pv_tmp_name[NAME_LEN] = { 0, };
@@ -96,8 +99,36 @@ static void _pvscan_display_single(struct cmd_context *cmd,
                                           pv_pe_size(pv)));
 }
 
-int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
-          char **argv __attribute((unused)))
+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 be cached by the lvmetad daemon 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;
        int pvs_found = 0;
@@ -113,6 +144,9 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
        pv_max_name_len = 0;
        vg_max_name_len = 0;
 
+       if (arg_count(cmd, cache_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;
@@ -183,8 +217,10 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
        pv_max_name_len += 2;
        vg_max_name_len += 2;
 
-       dm_list_iterate_items(pvl, pvslist)
-           _pvscan_display_single(cmd, pvl->pv, NULL);
+       dm_list_iterate_items(pvl, pvslist) {
+               _pvscan_display_single(cmd, pvl->pv, NULL);
+               free_pv_fid(pvl->pv);
+       }
 
        if (!pvs_found) {
                log_print("No matching physical volumes found");
This page took 0.027879 seconds and 5 git commands to generate.