]> sourceware.org Git - lvm2.git/blobdiff - tools/pvscan.c
Reinstate accidentally-deleted line.
[lvm2.git] / tools / pvscan.c
index 775ba291ffa2dea81567d490e0ca02cbe8ca2662..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, };
@@ -94,11 +97,38 @@ static void _pvscan_display_single(struct cmd_context *cmd,
                  display_size(cmd, (uint64_t) (pv_pe_count(pv) -
                                                pv_pe_alloc_count(pv)) *
                                           pv_pe_size(pv)));
-       return;
 }
 
-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;
@@ -114,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;
@@ -153,7 +186,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
                /* Also check for MD use? */
 /*******
                if (MAJOR(pv_create_kdev_t(pv[p]->pv_name)) != MD_MAJOR) {
-                       log_print
+                       log_warn
                            ("WARNING: physical volume \"%s\" belongs to a meta device",
                             pv[p]->pv_name);
                }
@@ -167,7 +200,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
                        size_new += pv_size(pv);
                        size_total += pv_size(pv);
                } else
-                       size_total += pv_pe_count(pv) * pv_pe_size(pv);
+                       size_total += (uint64_t) pv_pe_count(pv) * pv_pe_size(pv);
        }
 
        /* find maximum pv name length */
@@ -184,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.024701 seconds and 5 git commands to generate.