]> sourceware.org Git - lvm2.git/commitdiff
pvs, pvscan: new option -A to show PVs outside the devices file
authorDavid Teigland <teigland@redhat.com>
Fri, 10 Nov 2023 22:24:45 +0000 (16:24 -0600)
committerDavid Teigland <teigland@redhat.com>
Thu, 16 Nov 2023 14:45:46 +0000 (08:45 -0600)
pvs -A|--allpvs
Show PVs that would otherwise be excluded by the devices file.

pvscan -A|--allpvs
Show PVs that would otherwise be excluded by the devices file.
For those devices that are included by the devices file,
their device ID is displayed in place of the usual "lvm2"
format and size.

(pvs -a|--all is unchanged, and shows devices not formatted as PVs.)

lib/cache/lvmcache.c
tools/args.h
tools/command-lines.in
tools/pvscan.c
tools/reporter.c

index 0cbe146c1556fa752a0e13264c33faa0e98ff8e0..f20ea4bee8d6519d16d6ebc217f90f542a4f2cd2 100644 (file)
@@ -3026,9 +3026,11 @@ void lvmcache_get_max_name_lengths(struct cmd_context *cmd,
        *pv_max_name_len = 0;
 
        dm_list_iterate_items(vginfo, &_vginfos) {
-               len = strlen(vginfo->vgname);
-               if (*vg_max_name_len < len)
-                       *vg_max_name_len = len;
+               if (!is_orphan_vg(vginfo->vgname)) {
+                       len = strlen(vginfo->vgname);
+                       if (*vg_max_name_len < len)
+                               *vg_max_name_len = len;
+               }
 
                dm_list_iterate_items(info, &vginfo->infos) {
                        len = strlen(dev_name(info->dev));
index 35dfcfd3b890faedc6695ea524b21906f190d413..ab548ae0312006496ecf1c43c1ec506f46def109 100644 (file)
@@ -1143,6 +1143,14 @@ arg(activevolumegroups_ARG, 'A', "activevolumegroups", 0, 0, 0,
     "Only select active VGs. The VG is considered active\n"
     "if at least one of its LVs is active.\n")
 
+arg(allpvs_ARG, 'A', "allpvs", 0, 0, 0,
+    "#pvs\n"
+    "Show information about PVs outside the devices file.\n"
+    "Combine with with -a|--all to include devices that are not PVs.\n"
+    "#pvscan\n"
+    "Show information about PVs outside the devices file.\n"
+    "Displays the device ID for PVs included in the devices file.\n")
+
 arg(background_ARG, 'b', "background", 0, 0, 0,
     "If the operation requires polling, this option causes the command to\n"
     "return before the operation is complete, and polling is done in the\n"
index 633ea2090f22958061ce64398b2946eaf43c0ba1..b077422a73bca6dcf51562d911aec76d7315d43e 100644 (file)
@@ -1648,7 +1648,7 @@ ID: pvremove_general
 ---
 
 pvs
-OO: --segments, OO_REPORT
+OO: --segments, --allpvs, OO_REPORT
 OP: PV|Tag ...
 IO: --partial, --ignoreskippedcluster, --trustcache
 ID: pvs_general
@@ -1658,7 +1658,7 @@ RULE: --noheadings not --headings
 
 pvscan
 OO: --ignorelockingfailure, --reportformat ReportFmt, --exported, --novolumegroup,
---short, --uuid
+--short, --uuid, --allpvs
 ID: pvscan_display
 DESC: Display PV information.
 
index 37c67f5d803b3e302b67dfad9ca77b2e92e36eb5..a9412b685300a92c65f3ae8d3da0e3fe123b64eb 100644 (file)
@@ -18,6 +18,7 @@
 #include "lib/cache/lvmcache.h"
 #include "lib/metadata/metadata.h"
 #include "lib/label/hints.h"
+#include "lib/filters/filter.h"
 #include "lib/device/online.h"
 
 #include <dirent.h>
@@ -88,7 +89,46 @@ static int _pvscan_display_pv(struct cmd_context *cmd,
                pv_len += suffix_len;
        }
 
-       if (is_orphan(pv))
+       if (arg_is_set(cmd, allpvs_ARG)) {
+               struct device *dev = pv->dev;
+               if (!cmd->enable_devices_file) {
+                       if (is_orphan(pv)) {
+                               log_print_unless_silent("PV %-*s    %-*s",
+                                               pv_len, pvdevname,
+                                               params->vg_max_name_len, " ");
+                       } else {
+                               log_print_unless_silent("PV %-*s VG %-*s",
+                                               pv_len, pvdevname,
+                                               params->vg_max_name_len, pv_vg_name(pv));
+                       }
+               } else if (!(dev->flags & DEV_MATCHED_USE_ID)) {
+                       if (is_orphan(pv)) {
+                               log_print_unless_silent("PV %-*s    %-*s %-10s %s",
+                                               pv_len, pvdevname,
+                                               params->vg_max_name_len, " ",
+                                               "-", "-");
+                       } else {
+                               log_print_unless_silent("PV %-*s VG %-*s %-10s %s",
+                                               pv_len, pvdevname,
+                                               params->vg_max_name_len, pv_vg_name(pv),
+                                               "-", "-");
+                       }
+               } else {
+                       if (is_orphan(pv)) {
+                               log_print_unless_silent("PV %-*s    %-*s %-10s %s",
+                                               pv_len, pvdevname,
+                                               params->vg_max_name_len, " ",
+                                               idtype_to_str(dev->id->idtype),
+                                               dev->id->idname ?: "none");
+                       } else {
+                               log_print_unless_silent("PV %-*s VG %-*s %-10s %s",
+                                               pv_len, pvdevname,
+                                               params->vg_max_name_len, pv_vg_name(pv),
+                                               idtype_to_str(dev->id->idtype),
+                                               dev->id->idname ?: "none");
+                       }
+               }
+       } else if (is_orphan(pv))
                log_print_unless_silent("PV %-*s    %-*s %s [%s]",
                                        pv_len, pvdevname,
                                        params->vg_max_name_len, " ",
@@ -150,6 +190,11 @@ int pvscan_display_cmd(struct cmd_context *cmd, int argc, char **argv)
                          arg_is_set(cmd, exported_ARG) ?
                          "of exported volume group(s)" : "in no volume group");
 
+       if (arg_is_set(cmd, allpvs_ARG)) {
+               cmd->filter_deviceid_skip = 1;
+               cmd->use_hints = 0;
+       }
+
        if (!(handle = init_processing_handle(cmd, NULL))) {
                log_error("Failed to initialize processing handle.");
                ret = ECMD_FAILED;
index 82b39b21205d7e493935d5fd71bf96b5d1a0844b..61af33af535ef2ad08d929addfd0451a2c9cc5b9 100644 (file)
@@ -1448,6 +1448,11 @@ int pvs(struct cmd_context *cmd, int argc, char **argv)
        if (arg_is_set(cmd, all_ARG))
                cmd->use_hints = 0;
 
+       if (arg_is_set(cmd, allpvs_ARG)) {
+               cmd->filter_deviceid_skip = 1;
+               cmd->use_hints = 0;
+       }
+
        if (arg_is_set(cmd, segments_ARG))
                type = PVSEGS;
        else
This page took 0.051059 seconds and 5 git commands to generate.