File pvchange-pvresize-move-exported-VG-check.patch of Package lvm2.3105

From 0f10823ec910c0a6015b20580f5aa26f209cea04 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 10 Mar 2016 13:28:47 -0600
Subject: [PATCH] pvchange, pvresize: move exported VG check

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.

References: bsc#969310
---
 tools/pvchange.c | 7 ++++++-
 tools/pvresize.c | 8 ++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

Index: LVM2.2.02.120/tools/pvchange.c
===================================================================
--- LVM2.2.02.120.orig/tools/pvchange.c
+++ LVM2.2.02.120/tools/pvchange.c
@@ -34,6 +34,11 @@ static int _pvchange_single(struct cmd_c
 
 	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)) {
@@ -205,7 +210,7 @@ int pvchange(struct cmd_context *cmd, in
 		}
 	}
 
-	ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, handle, _pvchange_single);
+	ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, handle, _pvchange_single);
 
 	if (!argc)
 		unlock_vg(cmd, VG_GLOBAL);
Index: LVM2.2.02.120/tools/pvresize.c
===================================================================
--- LVM2.2.02.120.orig/tools/pvresize.c
+++ LVM2.2.02.120/tools/pvresize.c
@@ -35,6 +35,11 @@ static int _pvresize_single(struct cmd_c
 		return ECMD_FAILED;
 	}
 	params->total++;
+    
+    if (vg && vg_is_exported(vg)) {
+        log_error("Volume group %s is exported", vg->name);
+        return ECMD_FAILED;
+    }
 
 	if (!pv_resize_single(cmd, vg, pv, params->new_size))
 		return_ECMD_FAILED;
@@ -76,7 +81,7 @@ int pvresize(struct cmd_context *cmd, in
 
 	handle->custom_handle = &params;
 
-	ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, handle,
+	ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, handle,
 			      _pvresize_single);
 
 	log_print_unless_silent("%d physical volume(s) resized / %d physical volume(s) "
openSUSE Build Service is sponsored by