]> sourceware.org Git - lvm2.git/commitdiff
cmdline: Add --ignoreskippedcluster.
authorAlasdair G Kergon <agk@redhat.com>
Tue, 1 Oct 2013 20:20:10 +0000 (21:20 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 1 Oct 2013 20:20:10 +0000 (21:20 +0100)
Accept --ignoreskippedcluster with pvs, vgs, lvs, pvdisplay, vgdisplay,
lvdisplay, vgchange and lvchange to avoid the 'Skipping clustered
VG' errors when requesting information about a clustered VG
without using clustered locking and still exit with success.

The messages can still be seen with -v.

20 files changed:
WHATS_NEW
lib/commands/toolcontext.c
lib/commands/toolcontext.h
lib/metadata/metadata.c
man/lvchange.8.in
man/lvdisplay.8.in
man/lvm.8.in
man/lvs.8.in
man/pvdisplay.8.in
man/pvs.8.in
man/vgchange.8.in
man/vgdisplay.8.in
man/vgs.8.in
tools/args.h
tools/commands.h
tools/lvmcmdline.c
tools/pvdisplay.c
tools/reporter.c
tools/toollib.c
tools/toollib.h

index b813eb61b3fa1318f6452576fa3fea152dfb8d5a..cfcd8c9b76d62f3309158bf6e7b048089a1d78cf 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,12 +1,13 @@
 Version 2.02.103 - 
 ======================================
+  Add --ignoreskippedcluster for exit status success when clustered VGs skipped.
   Fix 3min udev timeout so that it is applied for all LVM volumes.
   Fix RAID calculation for sufficient allocatable space.
   Conversion from linear to mirror or RAID1 now honors mirror_segtype_default.
   Add thin-performance configuration profile.
   Add lvm.conf allocation/thin_pool_chunk_size_calculation option.
   Fix contiguous & cling allocation policies for parity RAID.  (2.02.100)
-  Set use_lvmetad=0 on lvmconf --enable-cluster, reset to default on --disable-cluster.
+  Have lvmconf --enable/disable-cluster reset/set use_lvmetad.
   Don't install separate command symlink in binary directory for 'lvm devtypes'.
   Add seg_size_pe field to reports.
   Support start+length notation with command line PE ranges.
index 4f53f0e9c865647b8691e9b4fc230c0a631657b5..2732094ae70b6b4d20bd7960081b3b2045a121a5 100644 (file)
@@ -1396,6 +1396,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
        cmd->handles_missing_pvs = 0;
        cmd->handles_unknown_segments = 0;
        cmd->independent_metadata_areas = 0;
+       cmd->ignore_clustered_vgs = 0;
        cmd->hosttags = 0;
        dm_list_init(&cmd->arg_value_groups);
        dm_list_init(&cmd->formats);
index cd916054700e627331abc77011f4d93eea7dfc4f..74b11771dd1def509bc5e788e7b562212b5a34dc 100644 (file)
@@ -90,6 +90,7 @@ struct cmd_context {
        unsigned auto_set_activation_skip:1;
        unsigned si_unit_consistency:1;
        unsigned metadata_read_only:1;
+       unsigned ignore_clustered_vgs:1;
        unsigned threaded:1;            /* Set if running within a thread e.g. clvmd */
 
        unsigned independent_metadata_areas:1;  /* Active formats have MDAs outside PVs */
index 1e34f83b3cfc77deb4179ac804605bbcad26d585..4ffd5020396592f210635637aeed3469a56604f4 100644 (file)
@@ -4005,7 +4005,10 @@ static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
 
        if ((status & CLUSTERED) &&
            (vg_is_clustered(vg)) && !locking_is_clustered()) {
-               log_error("Skipping clustered volume group %s", vg->name);
+               if (!vg->cmd->ignore_clustered_vgs)
+                       log_error("Skipping clustered volume group %s", vg->name);
+               else
+                       log_verbose("Skipping clustered volume group %s", vg->name);
                /* Return because other flags are considered undefined. */
                return FAILED_CLUSTERED;
        }
@@ -4123,7 +4126,10 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
        }
 
        if (vg_is_clustered(vg) && !locking_is_clustered()) {
-               log_error("Skipping clustered volume group %s", vg->name);
+               if (!cmd->ignore_clustered_vgs)
+                       log_error("Skipping clustered volume group %s", vg->name);
+               else
+                       log_verbose("Skipping clustered volume group %s", vg->name);
                failure |= FAILED_CLUSTERED;
                goto bad;
        }
index ea8a6ef95aee462edec7e9f490cc17da49d674c6..49337e4d1219ab8e1de60124a6db3a100dcdd949 100644 (file)
@@ -27,6 +27,7 @@ lvchange \- change attributes of a logical volume
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
 .RB [ \-\-ignoremonitoring ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-monitor
 .RI { y | n }]
 .RB [ \-\-poll
index 84f21d390a23d389a1c533d06a4543c0fa57c1b0..49654bce1fd6cb0ae3789f5a102628a941075791 100644 (file)
@@ -8,6 +8,7 @@ lvdisplay \- display attributes of a logical volume
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-maps ]
 .RB [ \-\-nosuffix ]
 .RB [ \-P | \-\-partial ]
@@ -26,6 +27,7 @@ lvdisplay \- display attributes of a logical volume
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-noheadings ]
 .RB [ \-\-nosuffix ]
 .RB [ \-o | \-\-options
index da471ab95c6094d7c6018fb1fd5d84b73f2ecdee..13e66d09efa31e5230090008a8164775aec59854 100644 (file)
@@ -216,6 +216,11 @@ This lets you proceed with read-only metadata operations such as
 One use for this is in a system init script if the lock directory
 is mounted read-only when the script runs.
 .TP
+.B \-\-ignoreskippedcluster
+Use to avoid exiting with an non-zero status code if the command is run
+without clustered locking and some clustered Volume Groups have to be
+skipped over.
+.TP
 .B \-\-addtag \fITag
 Add the tag \fITag\fP to a PV, VG or LV.
 Supply this argument multiple times to add more than one tag at once.
index 85f7d33fa87db2fbe466b76f995008feb866744a..8427acaba78b0c98b640bce795f9e4a6f483f62e 100644 (file)
@@ -8,6 +8,7 @@ lvs \- report information about logical volumes
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-nameprefixes ]
 .RB [ \-\-noheadings ]
 .RB [ \-\-nosuffix ]
index 6a8a0d00aa34f8bfd952b72fcc542c8eef8472b2..03c12c431ba053e67768f15d3f094fbaa44f8562 100644 (file)
@@ -7,6 +7,7 @@ pvdisplay \- display attributes of a physical volume
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-maps ]
 .RB [ \-\-nosuffix ]
 .RB [ \-s | \-\-short ]
index d1f6e8b995f3e1686339fa8512eb771ac05dfec7..67e395ba4b9b260d46ec72040c832a42fe68b587 100644 (file)
@@ -8,6 +8,7 @@ pvs \- report information about physical volumes
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-nameprefixes ]
 .RB [ \-\-noheadings ]
 .RB [ \-\-nosuffix ]
index 97042b1a8b61ca42fdc921e0f2f0e9b4e53b08a6..e687587eb5e3bbae34610a73924077fed51bc377 100644 (file)
@@ -29,6 +29,7 @@ vgchange \- change attributes of a volume group
 .RB [ \-h | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
 .RB [ \-\-ignoremonitoring ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-sysinit ]
 .RB [ \-\-noudevsync ]
 .RB [ \-l | \-\-logicalvolume
index 70c1fa71f170eeeb00e88c9e066fec84d270793b..9016a459291770ab8b106356007c25011ee4f98d 100644 (file)
@@ -10,6 +10,7 @@ vgdisplay \- display attributes of volume groups
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-nosuffix ]
 .RB [ \-P | \-\-partial ]
 .RB [ \-\-units
@@ -26,6 +27,7 @@ vgdisplay \- display attributes of volume groups
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-noheadings ]
 .RB [ \-\-nosuffix ]
 .RB [ \-o|\-\-options
index 381e3a96bc2301392d5ad682eebff9ef4acf28fc..eae60fae2a3ac672817511bf7f902a3361e654c6 100644 (file)
@@ -8,6 +8,7 @@ vgs \- report information about volume groups
 .RB [ \-d | \-\-debug ]
 .RB [ \-h | \-? | \-\-help ]
 .RB [ \-\-ignorelockingfailure ]
+.RB [ \-\-ignoreskippedcluster ]
 .RB [ \-\-nameprefixes ]
 .RB [ \-\-noheadings ]
 .RB [ \-\-nosuffix ]
index c5e4d148e26183ce22a7e3d05518d8746f9a23ac..27b97ebd31c232944e838bcc5955fed172240fd0 100644 (file)
@@ -100,6 +100,7 @@ arg(raidmaxrecoveryrate_ARG, '\0', "raidmaxrecoveryrate", size_kb_arg, 0)
 arg(profile_ARG, '\0', "profile", string_arg, 0)
 arg(detachprofile_ARG, '\0', "detachprofile", NULL, 0)
 arg(mergedconfig_ARG, '\0', "mergedconfig", NULL, 0)
+arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
index a0cd5d71d1c9baae5a0cf1df121dc8b103ab34c0..c299276adfbfed9321ea209e603c84aac56a1fd3 100644 (file)
@@ -107,6 +107,7 @@ xx(lvchange,
    "\t[--discards {ignore|nopassdown|passdown}]\n"
    "\t[--ignorelockingfailure]\n"
    "\t[--ignoremonitoring]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[-k|--setactivationskip {y|n}]\n"
    "\t[-K|--ignoreactivationskip] \n"
    "\t[--monitor {y|n}]\n"
@@ -135,6 +136,7 @@ xx(lvchange,
    addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, available_ARG,
    contiguous_ARG, deltag_ARG, discards_ARG, detachprofile_ARG, force_ARG,
    ignorelockingfailure_ARG, ignoremonitoring_ARG, ignoreactivationskip_ARG,
+   ignoreskippedcluster_ARG,
    major_ARG, minor_ARG, monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG,
    noudevsync_ARG, partial_ARG, permission_ARG, persistent_ARG, poll_ARG,
    profile_ARG, raidminrecoveryrate_ARG, raidmaxrecoveryrate_ARG,
@@ -303,6 +305,7 @@ xx(lvdisplay,
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[-m|--maps]\n"
    "\t[--nosuffix]\n"
    "\t[-P|--partial] " "\n"
@@ -317,6 +320,7 @@ xx(lvdisplay,
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--noheadings]\n"
    "\t[--nosuffix]\n"
    "\t[-o|--options [+]Field[,Field]]\n"
@@ -330,8 +334,8 @@ xx(lvdisplay,
    "\t[--version]" "\n"
    "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
 
-    aligned_ARG, all_ARG, colon_ARG, columns_ARG,
-    ignorelockingfailure_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG,
+    aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG, 
+    ignoreskippedcluster_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG,
     options_ARG, sort_ARG, partial_ARG, segments_ARG, separator_ARG,
     unbuffered_ARG, units_ARG)
 
@@ -502,6 +506,7 @@ xx(lvs,
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--nameprefixes]\n"
    "\t[--noheadings]\n"
    "\t[--nosuffix]\n"
@@ -519,7 +524,8 @@ xx(lvs,
    "\t[--version]" "\n"
    "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
 
-   aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG,
+   aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG,
+   nameprefixes_ARG,
    noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
    rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG,
    unbuffered_ARG, units_ARG, unquoted_ARG)
@@ -646,6 +652,7 @@ xx(pvdisplay,
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[-m|--maps]\n"
    "\t[--nosuffix]\n"
    "\t[-s|--short]\n"
@@ -660,6 +667,7 @@ xx(pvdisplay,
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--noheadings]\n"
    "\t[--nosuffix]\n"
    "\t[-o|--options [+]Field[,Field]]\n"
@@ -672,8 +680,8 @@ xx(pvdisplay,
    "\t[PhysicalVolumePath [PhysicalVolumePath...]]\n",
 
    aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG,
-   maps_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, separator_ARG,
-   short_ARG, sort_ARG, unbuffered_ARG, units_ARG)
+   ignoreskippedcluster_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG,
+   options_ARG, separator_ARG, short_ARG, sort_ARG, unbuffered_ARG, units_ARG)
 
 xx(pvmove,
    "Move extents from one physical volume to another",
@@ -722,6 +730,7 @@ xx(pvs,
    "\t[-d|--debug]" "\n"
    "\t[-h|-?|--help] " "\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--nameprefixes]\n"
    "\t[--noheadings]\n"
    "\t[--nosuffix]\n"
@@ -739,10 +748,10 @@ xx(pvs,
    "\t[--version]\n"
    "\t[PhysicalVolume [PhysicalVolume...]]\n",
 
-   aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG,
-   noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
-   rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG,
-   unbuffered_ARG, units_ARG, unquoted_ARG)
+   aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG,
+   nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG,
+   partial_ARG, rows_ARG, segments_ARG, separator_ARG, sort_ARG,
+   trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG)
 
 xx(pvscan,
    "List all physical volumes",
@@ -813,6 +822,7 @@ xx(vgchange,
    "\t[-h|--help] " "\n"
    "\t[--ignorelockingfailure]\n"
    "\t[--ignoremonitoring]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[-K|--ignoreactivationskip] \n"
    "\t[--monitor {y|n}]\n"
    "\t[--[vg]metadatacopies #copies] " "\n"
@@ -838,6 +848,7 @@ xx(vgchange,
    addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, activate_ARG,
    available_ARG, clustered_ARG, deltag_ARG, detachprofile_ARG,
    ignoreactivationskip_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG,
+   ignoreskippedcluster_ARG,
    logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, noudevsync_ARG,
    metadatacopies_ARG, vgmetadatacopies_ARG, partial_ARG, profile_ARG,
    physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG,
@@ -910,6 +921,7 @@ xx(vgdisplay,
    "\t[-d|--debug] " "\n"
    "\t[-h|--help] " "\n"
    "\t[--ignorelockingfailure]" "\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--nosuffix]\n"
    "\t[-P|--partial] " "\n"
    "\t[--units hHbBsSkKmMgGtTpPeE]\n"
@@ -921,6 +933,7 @@ xx(vgdisplay,
    "\t[-d|--debug] " "\n"
    "\t[-h|--help] " "\n"
    "\t[--ignorelockingfailure]" "\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--noheadings]\n"
    "\t[--nosuffix]\n"
    "\t[-o|--options [+]Field[,Field]]\n"
@@ -934,8 +947,9 @@ xx(vgdisplay,
    "\t[VolumeGroupName [VolumeGroupName...]]\n",
 
    activevolumegroups_ARG, aligned_ARG, colon_ARG, columns_ARG,
-   ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG, options_ARG,
-   partial_ARG, short_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
+   ignorelockingfailure_ARG, ignoreskippedcluster_ARG, noheadings_ARG,
+   nosuffix_ARG, options_ARG, partial_ARG, short_ARG, separator_ARG,
+   sort_ARG, unbuffered_ARG, units_ARG)
 
 xx(vgexport,
    "Unregister volume group(s) from the system",
@@ -1075,6 +1089,7 @@ xx(vgs,
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[--ignoreskippedcluster]\n"
    "\t[--nameprefixes]\n"
    "\t[--noheadings]\n"
    "\t[--nosuffix]\n"
@@ -1091,7 +1106,8 @@ xx(vgs,
    "\t[--version]\n"
    "\t[VolumeGroupName [VolumeGroupName...]]\n",
 
-   aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG,
+   aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG,
+   nameprefixes_ARG,
    noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG,
    rows_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG,
    unquoted_ARG)
index e004f6193765fd83ab6c5392589b6e5edadaf184..6fe4670173e40c7b57695600148f7867cc937f28 100644 (file)
@@ -906,6 +906,8 @@ static int _get_settings(struct cmd_context *cmd)
        else
                init_ignorelockingfailure(0);
 
+       cmd->ignore_clustered_vgs = arg_count(cmd, ignoreskippedcluster_ARG) ? 1 : 0;
+
        if (!arg_count(cmd, sysinit_ARG))
                lvmetad_connect_or_warn();
 
index c6cd4129cd3c415655b7d8b32522a92f5932ba9d..35fb75b004f3bf05f952f9ab05945bc738d34823 100644 (file)
@@ -30,11 +30,10 @@ static int _pvdisplay_single(struct cmd_context *cmd,
        if (!is_orphan(pv) && !vg) {
                vg_name = pv_vg_name(pv);
                vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
-               if (vg_read_error(vg)) {
-                       log_error("Skipping volume group %s", vg_name);
+               if (ignore_vg(vg, vg_name, 0, &ret)) {
                        release_vg(vg);
-                       /* FIXME If CLUSTERED should return ECMD_PROCESSED here */
-                       return ECMD_FAILED;
+                       stack;
+                       return ret;
                }
 
                /*
index 44a9aa8d4935d9e6dc8e00292aa0240cc65a07d5..a967f605037d20c24b6a3f5301fd72de05e10e06 100644 (file)
@@ -145,10 +145,10 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
                vg_name = pv_vg_name(pv);
 
                vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
-               if (vg_read_error(vg)) {
-                       log_error("Skipping volume group %s", vg_name);
+               if (ignore_vg(vg, vg_name, 0, &ret)) {
                        release_vg(vg);
-                       return ECMD_FAILED;
+                       stack;
+                       return ret;
                }
 
                /*
@@ -205,8 +205,12 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
                      struct volume_group *vg,
                      void *handle)
 {
-       if (vg_read_error(vg))
-               return_ECMD_FAILED;
+       int ret = ECMD_PROCESSED;
+
+       if (ignore_vg(vg, vg_name, 0, &ret)) {
+               stack;
+               return ret;
+       }
 
        return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single);
 }
@@ -215,8 +219,12 @@ static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
                         struct volume_group *vg,
                         void *handle)
 {
-       if (vg_read_error(vg))
-               return_ECMD_FAILED;
+       int ret = ECMD_PROCESSED;
+
+       if (ignore_vg(vg, vg_name, 0, &ret)) {
+               stack;
+               return ret;
+       }
 
        return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single);
 }
index 9b3e8426241377849114a09848984dcc576257bf..bc8b33ce94e45c7656e28b09df6a958649d863e1 100644 (file)
@@ -155,6 +155,29 @@ const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
        return vg_name;
 }
 
+/*
+ * Returns 1 if VG should be ignored.
+ */
+int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *ret)
+{
+       uint32_t read_error = vg_read_error(vg);
+
+       if (!read_error)
+               return 0;
+
+       if ((read_error == FAILED_INCONSISTENT) && allow_inconsistent)
+               return 0;
+
+       if (read_error == FAILED_CLUSTERED && vg->cmd->ignore_clustered_vgs)
+               log_verbose("Skipping volume group %s", vg_name);
+       else {
+               log_error("Skipping volume group %s", vg_name);
+               *ret = ECMD_FAILED;
+       }
+
+       return 1;
+}
+
 /*
  * Metadata iteration functions
  */
@@ -404,12 +427,10 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
                        return_ECMD_FAILED;
 
                if (!cmd_vg_read(cmd, &cmd_vgs)) {
-                       free_cmd_vgs(&cmd_vgs);
-                       if (ret_max < ECMD_FAILED) {
-                               log_error("Skipping volume group %s", vgname);
-                               ret_max = ECMD_FAILED;
-                       } else
+                       if (ignore_vg(cvl_vg->vg, vgname, 0, &ret_max))
                                stack;
+
+                       free_cmd_vgs(&cmd_vgs);
                        continue;
                }
 
@@ -489,10 +510,10 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
                vg_name = pv_vg_name(pv);
 
                vg = vg_read(cmd, vg_name, NULL, 0);
-               if (vg_read_error(vg)) {
+               if (ignore_vg(vg, vg_name, 0, &ret)) {
                        release_vg(vg);
-                       log_error("Skipping volume group %s", vg_name);
-                       return ECMD_FAILED;
+                       stack;
+                       return ret;
                }
 
                /*
@@ -561,13 +582,13 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
 {
        struct dm_list cmd_vgs;
        struct cmd_vg *cvl_vg;
-       int ret = 0;
+       int ret = ECMD_PROCESSED;
 
        log_verbose("Finding volume group \"%s\"", vg_name);
 
        dm_list_init(&cmd_vgs);
        if (!(cvl_vg = cmd_vg_add(cmd->mem, &cmd_vgs, vg_name, vgid, flags)))
-               return_0;
+               return_ECMD_FAILED;
 
        for (;;) {
                if (sigint_caught()) {
@@ -575,15 +596,14 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
                        stack;
                        break;
                }
-               if (!cmd_vg_read(cmd, &cmd_vgs))
+
+               if (!cmd_vg_read(cmd, &cmd_vgs)) {
                        /* Allow FAILED_INCONSISTENT through only for vgcfgrestore */
-                       if (vg_read_error(cvl_vg->vg) &&
-                           (!((flags & READ_ALLOW_INCONSISTENT) &&
-                              (vg_read_error(cvl_vg->vg) == FAILED_INCONSISTENT)))) {
-                               ret = ECMD_FAILED;
+                       if (ignore_vg(cvl_vg->vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) {
                                stack;
                                break;
                        }
+               }
 
                if (!dm_list_empty(tags) &&
                    /* Only process if a tag matches or it's on arg_vgnames */
@@ -889,8 +909,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
                                        goto_out;
                                }
                                vg = vg_read(cmd, sll->str, NULL, flags);
-                               if (vg_read_error(vg)) {
-                                       ret_max = ECMD_FAILED;
+                               if (ignore_vg(vg, sll->str, 0, &ret_max)) {
                                        release_vg(vg);
                                        stack;
                                        continue;
index d831b95e4faf9c78529d33b12b62bb205987547d..aa6f699d294407d24f1dc73dbda055d8e6c88e41 100644 (file)
@@ -25,6 +25,8 @@ int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
                    int autobackup);
 int autobackup(struct volume_group *vg);
 
+int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *ret);
+
 struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
                                uint32_t lock_type);
 
This page took 0.071464 seconds and 5 git commands to generate.