]> sourceware.org Git - lvm2.git/commitdiff
pvchange, pvresize: move exported VG check
authorDavid Teigland <teigland@redhat.com>
Thu, 10 Mar 2016 19:28:47 +0000 (13:28 -0600)
committerDavid Teigland <teigland@redhat.com>
Thu, 10 Mar 2016 19:37:42 +0000 (13:37 -0600)
Allow pvchange and pvresize to process exported VGs,
and have them check for the exported state in their
single function.

Previously, the exported VG state would trigger a
failure in vg_read()/ignore_vg() because the VGs are
being read with READ_FOR_UPDATE.  Because these commands
read all VGs to search for the intended PVs, any
exported VG would trigger a failure, even if it was
not related to the intended PV.

tools/pvchange.c
tools/pvresize.c

index 5f99016873894ca5d0e285e59d895c32d0b1de6a..e103ebe665135e322be893a3460cd0b282b28c35 100644 (file)
@@ -35,6 +35,11 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
 
        params->total++;
 
+       if (vg && vg_is_exported(vg)) {
+               log_error("Volume group %s is exported", vg->name);
+               goto bad;
+       }
+
        /* If in a VG, must change using volume group. */
        if (!is_orphan(pv)) {
                if (tagargs && !(vg->fid->fmt->features & FMT_TAGS)) {
@@ -230,7 +235,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
 
        set_pv_notify(cmd);
 
-       ret = process_each_pv(cmd, argc, argv, NULL, 0, READ_FOR_UPDATE, handle, _pvchange_single);
+       ret = process_each_pv(cmd, argc, argv, NULL, 0, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, handle, _pvchange_single);
 
        if (!argc)
                unlock_vg(cmd, VG_GLOBAL);
index 13122907ed06a32fa0abaf7e5b47facdf99e5845..9931cc6841631d443bef8823ac4d000ccd580469 100644 (file)
@@ -36,6 +36,11 @@ static int _pvresize_single(struct cmd_context *cmd,
        }
        params->total++;
 
+       if (vg && vg_is_exported(vg)) {
+               log_error("Volume group %s is exported", vg->name);
+               return ECMD_FAILED;
+       }
+
        /*
         * Needed to change a property on an orphan PV.
         * i.e. the global lock is only needed for orphans.
@@ -89,8 +94,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
 
        handle->custom_handle = &params;
 
-       ret = process_each_pv(cmd, argc, argv, NULL, 0, READ_FOR_UPDATE, handle,
-                             _pvresize_single);
+       ret = process_each_pv(cmd, argc, argv, NULL, 0, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, handle, _pvresize_single);
 
        log_print_unless_silent("%d physical volume(s) resized / %d physical volume(s) "
                                "not resized", params.done, params.total - params.done);
This page took 0.042566 seconds and 5 git commands to generate.