Skip to contentSkip to conversation

master - vgcfgrestore: Retain allocatable PV attribute.

PATCH Alasdair Kergon 1 participant 1 message Jan 14, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=01228b692be6850645b91811bbf30366241b036c
Commit:        01228b692be6850645b91811bbf30366241b036c
Parent:        9e9c7575413dca7a1ac7a5f363d1c7a464f86c3d
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Thu Jan 14 00:46:45 2016 +0000
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Thu Jan 14 00:46:45 2016 +0000

vgcfgrestore: Retain allocatable PV attribute.

pvchange -xn was getting lost.
All PVs were set to allocatable again after restore.

Moved setting ALLOCATABLE_PV outside pv_setup().

---
 WHATS_NEW                     |    1 +
 lib/format1/format1.c         |    6 +-----
 lib/format_text/format-text.c |    4 ----
 lib/metadata/metadata.c       |    4 ++++
 4 files changed, 6 insertions(+), 9 deletions(-)
WHATS_NEW +1 -0
index aff000f..885226a 100644
@@ -1,5 +1,6 @@
 Version 2.02.140 -
 ===================================
+  Fix vgcfgrestore to respect allocatable attribute of PVs.
   Add report/mark_hidden_devices to lvm.conf.
   Use brackets consistently in report fields to mark hidden devices.
   Restore background polling processing during auto-activation (2.02.119).
lib/format1/format1.c +1 -5
index 1b86ef5..c717184 100644
@@ -383,7 +383,6 @@ static int _format1_pv_setup(const struct format_type *fmt,
 			     struct physical_volume *pv,
 			     struct volume_group *vg)
 {
-	int r;
 	struct pvcreate_restorable_params rp = {.restorefile = NULL,
 						.id = {{0}},
 						.idp = NULL,
@@ -393,10 +392,7 @@ static int _format1_pv_setup(const struct format_type *fmt,
 						.extent_count = 0,
 						.extent_size = vg->extent_size};
 
-	if ((r = _format1_pv_initialise(fmt, -1, 0, 0, &rp, pv)))
-		pv->status |= ALLOCATABLE_PV;
-
-	return r;
+	return _format1_pv_initialise(fmt, -1, 0, 0, &rp, pv);
 }
 
 static int _format1_lv_setup(struct format_instance *fid, struct logical_volume *lv)
lib/format_text/format-text.c +0 -4
index 9aad0fe..02d3459 100644
@@ -1818,10 +1818,6 @@ static int _text_pv_setup(const struct format_type *fmt,
 		pv->pe_count = (uint32_t) pe_count;
 	}
 
-	/* Unlike LVM1, we don't store this outside a VG */
-	/* FIXME Default from config file? vgextend cmdline flag? */
-	pv->status |= ALLOCATABLE_PV;
-
 	return 1;
 }
 
lib/metadata/metadata.c +4 -0
index a1d2e2b..0336d5d 100644
@@ -227,6 +227,10 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
 	 */
 	pv->pe_alloc_count = 0;
 
+	/* LVM1 stores this outside a VG; LVM2 only stores it inside */
+	/* FIXME Default from config file? vgextend cmdline flag? */
+	pv->status |= ALLOCATABLE_PV;
+
 	if (!fid->fmt->ops->pv_setup(fid->fmt, pv, vg)) {
 		log_error("Format-specific setup of physical volume '%s' "
 			  "failed.", pv_name);