public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib/metadata metadata.c
@ 2009-08-10 17:15 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-08-10 17:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-08-10 17:15:02

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove useless _pv_write wrapper.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.277&r2=1.278

--- LVM2/lib/metadata/metadata.c	2009/08/01 17:08:44	1.277
+++ LVM2/lib/metadata/metadata.c	2009/08/10 17:15:01	1.278
@@ -45,10 +45,6 @@
 					uint64_t *label_sector,
 					int warnings, int scan_label_only);
 
-static int _pv_write(struct cmd_context *cmd __attribute((unused)),
-		     struct physical_volume *pv,
-	     	     struct dm_list *mdas, int64_t label_sector);
-
 static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
 			 			const char *pv_name);
 
@@ -2995,18 +2991,10 @@
 	return _get_pvs(cmd, NULL);
 }
 
-/* FIXME: liblvm todo - make into function that takes handle */
 int pv_write(struct cmd_context *cmd __attribute((unused)),
 	     struct physical_volume *pv,
 	     struct dm_list *mdas, int64_t label_sector)
 {
-	return _pv_write(cmd, pv, mdas, label_sector);
-}
-
-static int _pv_write(struct cmd_context *cmd __attribute((unused)),
-		     struct physical_volume *pv,
-	     	     struct dm_list *mdas, int64_t label_sector)
-{
 	if (!pv->fmt->ops->pv_write) {
 		log_error("Format does not support writing physical volumes");
 		return 0;
@@ -3037,7 +3025,7 @@
 		return 0;
 	}
 
-	if (!_pv_write(cmd, pv, NULL, INT64_C(-1))) {
+	if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
 		log_error("Failed to clear metadata from physical "
 			  "volume \"%s\" after removal from \"%s\"",
 			  pv_dev_name(pv), old_vg_name);


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-03-12 14:43 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2012-03-12 14:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-12 14:43:12

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Removing call of release_vg(NULL)
	
	Since we are in error path were vg must be always NULL,
	skip call of release_vg() like we do in other places.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.498&r2=1.499

--- LVM2/lib/metadata/metadata.c	2012/03/12 14:18:29	1.498
+++ LVM2/lib/metadata/metadata.c	2012/03/12 14:43:12	1.499
@@ -3021,7 +3021,6 @@
 		    (!use_precommitted &&
 		     !(vg = mda->ops->vg_read(fid, vgname, mda, 0)))) {
 			inconsistent = 1;
-			release_vg(vg);
 			continue;
 		}
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-03-01  9:46 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2012-03-01  9:46 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-01 09:46:38

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Fix leak of FID structure

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.494&r2=1.495

--- LVM2/lib/metadata/metadata.c	2012/02/29 02:35:36	1.494
+++ LVM2/lib/metadata/metadata.c	2012/03/01 09:46:38	1.495
@@ -2775,8 +2775,7 @@
 	return 1;
 }
 
-/* Make orphan PVs look like a VG. FIXME multiple runs will leak memory
- * allocated to PVs into the orphan VG pool which is now global. */
+/* Make orphan PVs look like a VG. */
 static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
 					     int warnings,
 					     const char *orphan_vgname)
@@ -2785,6 +2784,7 @@
 	struct lvmcache_vginfo *vginfo;
 	struct volume_group *vg = NULL;
 	struct _vg_read_orphan_baton baton;
+	struct pv_list *pvl;
 
 	lvmcache_label_scan(cmd, 0);
 	lvmcache_seed_infos_from_lvmetad(cmd);
@@ -2796,6 +2796,8 @@
 		return_NULL;
 
 	vg = fmt->orphan_vg;
+	dm_list_iterate_items(pvl, &vg->pvs)
+		pv_set_fid(pvl->pv, NULL);
 	dm_list_init(&vg->pvs);
 	vg->pv_count = 0;
 
@@ -2803,7 +2805,7 @@
 	baton.vg = vg;
 
 	if (!lvmcache_foreach_pv(vginfo, _vg_read_orphan_pv, &baton))
-                return_NULL;
+		return_NULL;
 
 	return vg;
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-02-29  0:19 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2012-02-29  0:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2012-02-29 00:19:15

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Fix a whitespace bug in the last checkin.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.492&r2=1.493

--- LVM2/lib/metadata/metadata.c	2012/02/29 00:18:27	1.492
+++ LVM2/lib/metadata/metadata.c	2012/02/29 00:19:14	1.493
@@ -2796,7 +2796,7 @@
 		return_NULL;
 
 	vg = fmt->orphan_vg;
-        dm_list_init(&vg->pvs);
+	dm_list_init(&vg->pvs);
 	vg->pv_count = 0;
 
 	baton.warnings = warnings;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-02-29  0:18 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2012-02-29  0:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2012-02-29 00:18:27

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Attempt a fix for lvm shell accumulating copies of orphan PVs with each "pvs"
	invocation.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.491&r2=1.492

--- LVM2/lib/metadata/metadata.c	2012/02/28 11:12:58	1.491
+++ LVM2/lib/metadata/metadata.c	2012/02/29 00:18:27	1.492
@@ -2775,7 +2775,8 @@
 	return 1;
 }
 
-/* Make orphan PVs look like a VG */
+/* Make orphan PVs look like a VG. FIXME multiple runs will leak memory
+ * allocated to PVs into the orphan VG pool which is now global. */
 static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
 					     int warnings,
 					     const char *orphan_vgname)
@@ -2795,6 +2796,8 @@
 		return_NULL;
 
 	vg = fmt->orphan_vg;
+        dm_list_init(&vg->pvs);
+	vg->pv_count = 0;
 
 	baton.warnings = warnings;
 	baton.vg = vg;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-02-28 11:10 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2012-02-28 11:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-28 11:10:45

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Check error from _lv_each_dependency
	
	_lv_mark_if_partial_collect cannot fail, however it's good to keep
	checking here as we do in all other cases.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.489&r2=1.490

--- LVM2/lib/metadata/metadata.c	2012/02/28 10:11:36	1.489
+++ LVM2/lib/metadata/metadata.c	2012/02/28 11:10:45	1.490
@@ -2186,7 +2186,8 @@
 	}
 
 	baton.partial = 0;
-	_lv_each_dependency(lv, _lv_mark_if_partial_collect, &baton);
+	if (!_lv_each_dependency(lv, _lv_mark_if_partial_collect, &baton))
+		return_0;
 
 	if (baton.partial)
 		lv->status |= PARTIAL_LV;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-02-27  9:54 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2012-02-27  9:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-27 09:51:32

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Just reindent with tabs

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.486&r2=1.487

--- LVM2/lib/metadata/metadata.c	2012/02/23 13:11:10	1.486
+++ LVM2/lib/metadata/metadata.c	2012/02/27 09:51:31	1.487
@@ -1896,12 +1896,12 @@
 
 struct lv_segment *last_seg(const struct logical_volume *lv)
 {
-       struct lv_segment *seg;
+	struct lv_segment *seg;
 
-       dm_list_iterate_back_items(seg, &lv->segments)
-               return seg;
+	dm_list_iterate_back_items(seg, &lv->segments)
+		return seg;
 
-       return NULL;
+	return NULL;
 }
 
 int vg_remove_mdas(struct volume_group *vg)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-02-12 20:19 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2012-02-12 20:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2012-02-12 20:19:40

Modified files:
	lib/metadata   : metadata.c 

Log message:
	remove unused bits after fid changes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.478&r2=1.479

--- LVM2/lib/metadata/metadata.c	2012/02/10 02:53:05	1.478
+++ LVM2/lib/metadata/metadata.c	2012/02/12 20:19:39	1.479
@@ -1616,8 +1616,6 @@
 				  unsigned metadataignore)
 {
 	const struct format_type *fmt = cmd->fmt;
-	struct format_instance_ctx fic;
-	struct format_instance *fid;
 	struct dm_pool *mem = fmt->cmd->mem;
 	struct physical_volume *pv = _alloc_pv(mem, dev);
 	unsigned mda_index;
@@ -2746,8 +2744,6 @@
 					     int warnings,
 					     const char *orphan_vgname)
 {
-	struct format_instance_ctx fic;
-	struct format_instance *fid;
 	const struct format_type *fmt;
 	struct lvmcache_vginfo *vginfo;
 	struct volume_group *vg = NULL;
@@ -2768,8 +2764,6 @@
 	lvmcache_foreach_pv(vginfo, _vg_read_orphan_pv, &baton);
 
 	return vg;
-bad:
-	return NULL;
 }
 
 static int _update_pv_list(struct dm_pool *pvmem, struct dm_list *all_pvs, struct volume_group *vg)
@@ -3557,7 +3551,6 @@
 					int warnings, int scan_label_only)
 {
 	struct physical_volume *pv;
-	struct format_instance_ctx fic;
 	struct label *label;
 	struct lvmcache_info *info;
 	struct device *dev;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2012-01-25  8:50 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2012-01-25  8:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-25 08:50:10

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Thin dependency scan support
	
	Go through pool_lv and metadata_lv LVs when doing recursive scan.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.474&r2=1.475

--- LVM2/lib/metadata/metadata.c	2011/11/18 19:31:10	1.474
+++ LVM2/lib/metadata/metadata.c	2012/01/25 08:50:10	1.475
@@ -2056,6 +2056,10 @@
 			return_0;
 		if (lvseg->rlog_lv && !fn(lvseg->rlog_lv, data))
 			return_0;
+		if (lvseg->pool_lv && !fn(lvseg->pool_lv, data))
+			return_0;
+		if (lvseg->metadata_lv && !fn(lvseg->metadata_lv, data))
+			return_0;
 		for (s = 0; s < lvseg->area_count; ++s) {
 			if (seg_type(lvseg, s) == AREA_LV && !fn(seg_lv(lvseg,s), data))
 				return_0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2011-04-01 14:54 prajnoha
  0 siblings, 0 replies; 73+ messages in thread
From: prajnoha @ 2011-04-01 14:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-04-01 14:54:21

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Cleanup fid finalization code in free_vg and allow exactly the same fid to be set again for a PV/VG.
	
	Actually, we can call vg_set_fid(vg, NULL) instead of calling
	destroy_instance for all PV structs and a VG struct - it's the same
	code we already have in the vg_set_fid.
	
	Also, allow exactly the same fid to be set again for the same PV/VG
	Before, this could end up with the fid destroyed because we destroyed
	existing fid first and then we used the new one and we didn't care
	whether existing one == new one by chance.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.452&r2=1.453

--- LVM2/lib/metadata/metadata.c	2011/03/30 13:35:51	1.452
+++ LVM2/lib/metadata/metadata.c	2011/04/01 14:54:20	1.453
@@ -3243,19 +3243,10 @@
 
 void free_vg(struct volume_group *vg)
 {
-	struct pv_list *pvl;
-
 	if (!vg)
 		return;
 
-	dm_list_iterate_items(pvl, &vg->pvs)
-		pvl->pv->fid->fmt->ops->destroy_instance(pvl->pv->fid);
-
-	dm_list_iterate_items(pvl, &vg->removed_pvs)
-		pvl->pv->fid->fmt->ops->destroy_instance(pvl->pv->fid);
-
-	if (vg->fid)
-		vg->fid->fmt->ops->destroy_instance(vg->fid);
+	vg_set_fid(vg, NULL);
 
 	if (vg->cmd && vg->vgmem == vg->cmd->mem) {
 		log_error(INTERNAL_ERROR "global memory pool used for VG %s",
@@ -4048,12 +4039,13 @@
 void pv_set_fid(struct physical_volume *pv,
 		struct format_instance *fid)
 {
+	if (fid)
+		fid->ref_count++;
+
 	if (pv->fid)
 		pv->fid->fmt->ops->destroy_instance(pv->fid);
 
 	pv->fid = fid;
-	if (fid)
-		fid->ref_count++;
 }
 
 void vg_set_fid(struct volume_group *vg,
@@ -4061,15 +4053,19 @@
 {
 	struct pv_list *pvl;
 
-	if (vg->fid)
-		vg->fid->fmt->ops->destroy_instance(vg->fid);
-
-	vg->fid = fid;
 	if (fid)
 		fid->ref_count++;
 
 	dm_list_iterate_items(pvl, &vg->pvs)
 		pv_set_fid(pvl->pv, fid);
+
+	dm_list_iterate_items(pvl, &vg->removed_pvs)
+		pv_set_fid(pvl->pv, fid);
+
+	if (vg->fid)
+		vg->fid->fmt->ops->destroy_instance(vg->fid);
+
+	vg->fid = fid;
 }
 
 static int _convert_key_to_string(const char *key, size_t key_len,


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2011-03-30 13:35 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2011-03-30 13:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-30 13:35:52

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Use created hash tables for quick check of LV, PV.
	
	Instead of searching linear list of all LVs, PVs - use created hash tables
	also for quick mapping between LV.
	
	(Note - for small number of PVs or LVs the overhead of the hash is bigger).
	
	TODO: Use hash tables in volume_group structure directly.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.451&r2=1.452

--- LVM2/lib/metadata/metadata.c	2011/03/29 21:57:56	1.451
+++ LVM2/lib/metadata/metadata.c	2011/03/30 13:35:51	1.452
@@ -2182,6 +2182,12 @@
 	}
 }
 
+struct validate_hash {
+	struct dm_hash_table *lvname;
+	struct dm_hash_table *lvid;
+	struct dm_hash_table *pvid;
+};
+
 /*
  * Check that an LV and all its PV references are correctly listed in vg->lvs
  * and vg->pvs, respectively. This only looks at a single LV, but *not* at the
@@ -2191,21 +2197,14 @@
 static int _lv_validate_references_single(struct logical_volume *lv, void *data)
 {
 	struct volume_group *vg = lv->vg;
+	struct validate_hash *vhash = data;
 	struct lv_segment *lvseg;
-	struct pv_list *pvl;
-	struct lv_list *lvl;
+	struct physical_volume *pv;
 	int s;
 	int r = 1;
-	int ok = 0;
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		if (lvl->lv == lv) {
-			ok = 1;
-			break;
-		}
-	}
-
-	if (!ok) {
+	if (lv != dm_hash_lookup_binary(vhash->lvid, &lv->lvid.id[1],
+					sizeof(lv->lvid.id[1]))) {
 		log_error(INTERNAL_ERROR
 			  "Referenced LV %s not listed in VG %s.",
 			  lv->name, vg->name);
@@ -2214,22 +2213,16 @@
 
 	dm_list_iterate_items(lvseg, &lv->segments) {
 		for (s = 0; s < lvseg->area_count; ++s) {
-			if (seg_type(lvseg, s) == AREA_PV) {
-				ok = 0;
-				/* look up the reference in vg->pvs */
-				dm_list_iterate_items(pvl, &vg->pvs) {
-					if (pvl->pv == seg_pv(lvseg, s)) {
-						ok = 1;
-						break;
-					}
-				}
-
-				if (!ok) {
-					log_error(INTERNAL_ERROR
-						  "Referenced PV %s not listed in VG %s.",
-						  pv_dev_name(seg_pv(lvseg, s)), vg->name);
-					r = 0;
-				}
+			if (seg_type(lvseg, s) != AREA_PV)
+				continue;
+			pv = seg_pv(lvseg, s);
+			/* look up the reference in vg->pvs */
+			if (pv != dm_hash_lookup_binary(vhash->pvid, &pv->id,
+							sizeof(pv->id))) {
+				log_error(INTERNAL_ERROR
+					  "Referenced PV %s not listed in VG %s.",
+					  pv_dev_name(pv), vg->name);
+				r = 0;
 			}
 		}
 	}
@@ -2247,9 +2240,7 @@
 	uint32_t hidden_lv_count = 0, lv_count = 0, lv_visible_count = 0;
 	uint32_t pv_count = 0;
 	uint32_t num_snapshots = 0;
-	struct dm_hash_table *lvname_hash;
-	struct dm_hash_table *lvid_hash;
-	struct dm_hash_table *pvid_hash;
+	struct validate_hash vhash = { NULL };
 
 	if (vg->alloc == ALLOC_CLING_BY_TAGS) {
 		log_error(INTERNAL_ERROR "VG %s allocation policy set to invalid cling_by_tags.",
@@ -2258,7 +2249,7 @@
 	}
 
 	/* FIXME Also check there's no data/metadata overlap */
-	if (!(pvid_hash = dm_hash_create(vg->pv_count))) {
+	if (!(vhash.pvid = dm_hash_create(vg->pv_count))) {
 		log_error("Failed to allocate pvid hash.");
 		return 0;
 	}
@@ -2283,7 +2274,7 @@
 			r = 0;
 		}
 
-		if (dm_hash_lookup_binary(pvid_hash, &pvl->pv->id,
+		if (dm_hash_lookup_binary(vhash.pvid, &pvl->pv->id,
 					  sizeof(pvl->pv->id))) {
 			if (!id_write_format(&pvl->pv->id, uuid,
 					     sizeof(uuid)))
@@ -2295,7 +2286,7 @@
 			r = 0;
 		}
 
-		if (!dm_hash_insert_binary(pvid_hash, &pvl->pv->id,
+		if (!dm_hash_insert_binary(vhash.pvid, &pvl->pv->id,
 					   sizeof(pvl->pv->id), pvl->pv)) {
 			log_error("Failed to hash pvid.");
 			r = 0;
@@ -2303,7 +2294,6 @@
 		}
 	}
 
-	dm_hash_destroy(pvid_hash);
 
 	if (!check_pv_segments(vg)) {
 		log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
@@ -2370,28 +2360,29 @@
 
 	/* Avoid endless loop if lv->segments list is corrupt */
 	if (!r)
-		return r;
+		goto out;
 
-	if (!(lvname_hash = dm_hash_create(lv_count))) {
+	if (!(vhash.lvname = dm_hash_create(lv_count))) {
 		log_error("Failed to allocate lv_name hash");
-		return 0;
+		r = 0;
+		goto out;
 	}
 
-	if (!(lvid_hash = dm_hash_create(lv_count))) {
+	if (!(vhash.lvid = dm_hash_create(lv_count))) {
 		log_error("Failed to allocate uuid hash");
-		dm_hash_destroy(lvname_hash);
-		return 0;
+		r = 0;
+		goto out;
 	}
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
-		if (dm_hash_lookup(lvname_hash, lvl->lv->name)) {
+		if (dm_hash_lookup(vhash.lvname, lvl->lv->name)) {
 			log_error(INTERNAL_ERROR
 				  "Duplicate LV name %s detected in %s.",
 				  lvl->lv->name, vg->name);
 			r = 0;
 		}
 
-		if (dm_hash_lookup_binary(lvid_hash, &lvl->lv->lvid.id[1],
+		if (dm_hash_lookup_binary(vhash.lvid, &lvl->lv->lvid.id[1],
 					  sizeof(lvl->lv->lvid.id[1]))) {
 			if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
 					     sizeof(uuid)))
@@ -2408,13 +2399,13 @@
 			r = 0;
 		}
 
-		if (!dm_hash_insert(lvname_hash, lvl->lv->name, lvl)) {
+		if (!dm_hash_insert(vhash.lvname, lvl->lv->name, lvl)) {
 			log_error("Failed to hash lvname.");
 			r = 0;
 			break;
 		}
 
-		if (!dm_hash_insert_binary(lvid_hash, &lvl->lv->lvid.id[1],
+		if (!dm_hash_insert_binary(vhash.lvid, &lvl->lv->lvid.id[1],
 					   sizeof(lvl->lv->lvid.id[1]), lvl->lv)) {
 			log_error("Failed to hash lvid.");
 			r = 0;
@@ -2422,10 +2413,7 @@
 		}
 	}
 
-	dm_hash_destroy(lvname_hash);
-	dm_hash_destroy(lvid_hash);
-
-	if (!_lv_postorder_vg(vg, _lv_validate_references_single, NULL)) {
+	if (!_lv_postorder_vg(vg, _lv_validate_references_single, &vhash)) {
 		stack;
 		r = 0;
 	}
@@ -2459,6 +2447,13 @@
 
 	if (vg_max_lv_reached(vg))
 		stack;
+out:
+	if (vhash.lvid)
+		dm_hash_destroy(vhash.lvid);
+	if (vhash.lvname)
+		dm_hash_destroy(vhash.lvname);
+	if (vhash.pvid)
+		dm_hash_destroy(vhash.pvid);
 
 	return r;
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2011-03-10 22:39 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2011-03-10 22:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-10 22:39:37

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Missed merge fix in vg_validate patch

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.440&r2=1.441

--- LVM2/lib/metadata/metadata.c	2011/03/10 14:40:32	1.440
+++ LVM2/lib/metadata/metadata.c	2011/03/10 22:39:36	1.441
@@ -2380,8 +2380,8 @@
 			break;
 		}
 
-		if (!dm_hash_insert_binary(lvid_hash, lvl->lv->lvid.id,
-					   sizeof(lvl->lv->lvid.id), lvl->lv)) {
+		if (!dm_hash_insert_binary(lvid_hash, &lvl->lv->lvid.id[1],
+					   sizeof(lvl->lv->lvid.id[1]), lvl->lv)) {
 			log_error("Failed to hash lvid.");
 			r = 0;
 			break;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2011-02-21 12:13 prajnoha
  0 siblings, 0 replies; 73+ messages in thread
From: prajnoha @ 2011-02-21 12:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-02-21 12:13:40

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Add format instance support for pv_read code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.428&r2=1.429

--- LVM2/lib/metadata/metadata.c	2011/02/21 12:12:32	1.428
+++ LVM2/lib/metadata/metadata.c	2011/02/21 12:13:40	1.429
@@ -37,6 +37,7 @@
 static struct physical_volume *_pv_read(struct cmd_context *cmd,
 					struct dm_pool *pvmem,
 					const char *pv_name,
+					struct format_instance *fid,
 					struct dm_list *mdas,
 					uint64_t *label_sector,
 					int warnings, int scan_label_only);
@@ -166,6 +167,7 @@
 	dm_list_add(&vg->pvs, &pvl->list);
 	vg->pv_count++;
 	pvl->pv->vg = vg;
+	pvl->pv->fid = vg->fid;
 }
 
 void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
@@ -1823,7 +1825,7 @@
 	struct physical_volume *pv;
 
 	dm_list_init(&mdas);
-	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, &mdas, NULL, 1, 0))) {
+	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, &mdas, NULL, 1, 0))) {
 		log_error("Physical volume %s not found", pv_name);
 		return NULL;
 	}
@@ -1832,7 +1834,7 @@
 		/* If a PV has no MDAs - need to search all VGs for it */
 		if (!scan_vgs_for_pvs(cmd, 1))
 			return_NULL;
-		if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
+		if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, NULL, 1, 0))) {
 			log_error("Physical volume %s not found", pv_name);
 			return NULL;
 		}
@@ -2657,7 +2659,8 @@
 	}
 
 	dm_list_iterate_items(info, &vginfo->infos) {
-		if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), NULL, NULL, warnings, 0))) {
+		if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), vg->fid,
+				    NULL, NULL, warnings, 0))) {
 			continue;
 		}
 		if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
@@ -3377,18 +3380,20 @@
 				struct dm_list *mdas, uint64_t *label_sector,
 				int warnings, int scan_label_only)
 {
-	return _pv_read(cmd, cmd->mem, pv_name, mdas, label_sector, warnings, scan_label_only);
+	return _pv_read(cmd, cmd->mem, pv_name, NULL, mdas, label_sector, warnings, scan_label_only);
 }
 
 /* FIXME Use label functions instead of PV functions */
 static struct physical_volume *_pv_read(struct cmd_context *cmd,
 					struct dm_pool *pvmem,
 					const char *pv_name,
+					struct format_instance *fid,
 					struct dm_list *mdas,
 					uint64_t *label_sector,
 					int warnings, int scan_label_only)
 {
 	struct physical_volume *pv;
+	struct format_instance_ctx fic;
 	struct label *label;
 	struct lvmcache_info *info;
 	struct device *dev;
@@ -3427,6 +3432,18 @@
 	if (!alloc_pv_segment_whole_pv(pvmem, pv))
 		goto_bad;
 
+	if (fid)
+		fid_add_mdas(fid, &info->mdas, (const char *) &pv->id, ID_LEN);
+	else {
+		fic.type = FMT_INSTANCE_PV | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+		fic.context.pv_id = (const char *) &pv->id;
+		if (!(pv->fid = pv->fmt->ops->create_instance(pv->fmt, &fic))) {
+			log_error("_pv_read: Couldn't create format instance "
+				  "for PV %s", pv_name);
+			goto bad;
+		}
+	}
+
 	return pv;
 bad:
 	_free_pv(pvmem, pv);
@@ -4244,5 +4261,5 @@
 	struct dm_list mdas;
 
 	dm_list_init(&mdas);
-	return _pv_read(cmd, cmd->mem, pv_name, &mdas, NULL, 1, 0);
+	return _pv_read(cmd, cmd->mem, pv_name, NULL, &mdas, NULL, 1, 0);
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2011-02-14 19:27 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2011-02-14 19:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2011-02-14 19:27:05

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Fix an lv_postorder bug where it failed to clear temporary flags, making it
	impossible to use twice with the same LV(s). Discovered by Milan.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.420&r2=1.421

--- LVM2/lib/metadata/metadata.c	2011/01/12 20:42:51	1.420
+++ LVM2/lib/metadata/metadata.c	2011/02/14 19:27:05	1.421
@@ -1969,18 +1969,6 @@
 			       int (*fn)(struct logical_volume *lv, void *data),
 			       void *data);
 
-static int _lv_postorder_level(struct logical_volume *lv, void *data)
-{
-	struct _lv_postorder_baton *baton = data;
-	if (lv->status & POSTORDER_OPEN_FLAG)
-		return 1; // a data structure loop has closed...
-	lv->status |= POSTORDER_OPEN_FLAG;
-	int r =_lv_postorder_visit(lv, baton->fn, baton->data);
-	lv->status &= ~POSTORDER_OPEN_FLAG;
-	lv->status |= POSTORDER_FLAG;
-	return r;
-};
-
 static int _lv_each_dependency(struct logical_volume *lv,
 			       int (*fn)(struct logical_volume *lv, void *data),
 			       void *data)
@@ -2022,6 +2010,12 @@
 	return 1;
 }
 
+static int _lv_postorder_level(struct logical_volume *lv, void *data)
+{
+	struct _lv_postorder_baton *baton = data;
+	return _lv_postorder_visit(lv, baton->fn, baton->data);
+};
+
 static int _lv_postorder_visit(struct logical_volume *lv,
 			       int (*fn)(struct logical_volume *lv, void *data),
 			       void *data)
@@ -2031,13 +2025,20 @@
 
 	if (lv->status & POSTORDER_FLAG)
 		return 1;
+	if (lv->status & POSTORDER_OPEN_FLAG)
+		return 1; // a data structure loop has closed...
+	lv->status |= POSTORDER_OPEN_FLAG;
 
 	baton.fn = fn;
 	baton.data = data;
 	r = _lv_each_dependency(lv, _lv_postorder_level, &baton);
+
 	if (r)
 		r = fn(lv, data);
 
+	lv->status &= ~POSTORDER_OPEN_FLAG;
+	lv->status |= POSTORDER_FLAG;
+
 	return r;
 }
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-12-14 17:07 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2010-12-14 17:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-12-14 17:07:36

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Add a validation step for pvmoveN internal LVs to vg_validate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.416&r2=1.417

--- LVM2/lib/metadata/metadata.c	2010/12/10 22:39:55	1.416
+++ LVM2/lib/metadata/metadata.c	2010/12/14 17:07:35	1.417
@@ -2157,6 +2157,7 @@
 {
 	struct pv_list *pvl, *pvl2;
 	struct lv_list *lvl, *lvl2;
+	struct lv_segment *seg;
 	char uuid[64] __attribute__((aligned(8)));
 	int r = 1;
 	uint32_t hidden_lv_count = 0, lv_count = 0, lv_visible_count = 0;
@@ -2318,6 +2319,26 @@
 		}
 	}
 
+	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (!(lvl->lv->status & PVMOVE))
+			continue;
+		dm_list_iterate_items(seg, &lvl->lv->segments) {
+			if (seg_is_mirrored(seg)) {
+				if (seg->area_count != 2) {
+					log_error(INTERNAL_ERROR
+						  "Segment %d in %s is not 2-way.",
+						  loop_counter1, lvl->lv->name);
+					r = 0;
+				}
+			} else if (seg->area_count != 1) {
+				log_error(INTERNAL_ERROR
+					  "Segment %d in %s has wrong number of areas: %d.",
+					  loop_counter1, lvl->lv->name, seg->area_count);
+				r = 0;
+			}
+		}
+	}
+
 	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS) &&
 	    (!vg->max_lv || !vg->max_pv)) {
 		log_error(INTERNAL_ERROR "Volume group %s has limited PV/LV count"


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-11-30 11:15 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2010-11-30 11:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-11-30 11:15:55

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Avoid the automatic MISSING_PV recovery path in commands with special
	MISSING_PV handling (cmd->handles_missing_pvs is set).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.412&r2=1.413

--- LVM2/lib/metadata/metadata.c	2010/11/29 18:35:37	1.412
+++ LVM2/lib/metadata/metadata.c	2010/11/30 11:15:54	1.413
@@ -2614,6 +2614,14 @@
 {
 	struct pv_list *pvl;
 
+        /*
+         * Skip these checks in case the tool is going to deal with missing
+         * PVs, especially since the resulting messages can be pretty
+         * confusing.
+         */
+        if (correct_vg->cmd->handles_missing_pvs)
+            return;
+
 	dm_list_iterate_items(pvl, &correct_vg->pvs)
 		if (pv->dev == pvl->pv->dev && is_missing_pv(pvl->pv)) {
 			log_warn("Missing device %s reappeared, updating "


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-10-25 13:35 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2010-10-25 13:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-25 13:35:13

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Fix constness warning for _vg_read_by_vgid() uuid usage

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.406&r2=1.407

--- LVM2/lib/metadata/metadata.c	2010/10/25 11:20:56	1.406
+++ LVM2/lib/metadata/metadata.c	2010/10/25 13:35:13	1.407
@@ -3154,7 +3154,7 @@
 	lvid = (const union lvid *) lvid_s;
 
 	log_very_verbose("Finding volume group for uuid %s", lvid_s);
-	if (!(vg = _vg_read_by_vgid(cmd, (char *)lvid->id[0].uuid, precommitted))) {
+	if (!(vg = _vg_read_by_vgid(cmd, (const char *)lvid->id[0].uuid, precommitted))) {
 		log_error("Volume group for uuid not found: %s", lvid_s);
 		return NULL;
 	}


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-30 16:47 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-07-30 16:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-07-30 16:47:27

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove irrelevant comments relating to vg_mda_copies.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.389&r2=1.390

--- LVM2/lib/metadata/metadata.c	2010/07/09 16:57:44	1.389
+++ LVM2/lib/metadata/metadata.c	2010/07/30 16:47:27	1.390
@@ -1199,11 +1199,6 @@
 
 int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies)
 {
-	/* FIXME: add checks, etc, and set the value */
-	/*
-	 * FIXME: Before we set a larger value, we may need to
-	 * enable some mdas on PVS
-	 */
 	vg->mda_copies = mda_copies;
 
 	/* FIXME Use log_verbose when this is due to specific cmdline request. */


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-09 16:57 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-07-09 16:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-07-09 16:57:44

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Add log_error when strdup fails in {vg|lv}_change_tag().
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.388&r2=1.389

--- LVM2/lib/metadata/metadata.c	2010/07/09 15:34:45	1.388
+++ LVM2/lib/metadata/metadata.c	2010/07/09 16:57:44	1.389
@@ -723,7 +723,9 @@
 
 	if (add_tag) {
 		if (!(tag_new = dm_pool_strdup(lv->vg->vgmem, tag))) {
-			return_0;
+			log_error("Failed to duplicate tag %s from %s/%s",
+				  tag, lv->vg->name, lv->name);
+			return 0;
 		}
 		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag_new)) {
 			log_error("Failed to add tag %s to %s/%s",
@@ -751,7 +753,9 @@
 
 	if (add_tag) {
 		if (!(tag_new = dm_pool_strdup(vg->vgmem, tag))) {
-			return_0;
+			log_error("Failed to duplicate tag %s from %s",
+				  tag, vg->name);
+			return 0;
 		}
 		if (!str_list_add(vg->vgmem, &vg->tags, tag_new)) {
 			log_error("Failed to add tag %s to volume group %s",


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-08 17:41 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-07-08 17:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-07-08 17:41:46

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Init mda->list in mda_copy.
	
	This patch should be no functional change as all callers initialize
	mda->list.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.385&r2=1.386

--- LVM2/lib/metadata/metadata.c	2010/07/07 18:59:45	1.385
+++ LVM2/lib/metadata/metadata.c	2010/07/08 17:41:46	1.386
@@ -4207,7 +4207,7 @@
 		}
 	}
 
-	/* FIXME mda 'list' left invalid here */
+	dm_list_init(&mda_new->list);
 
 	return mda_new;
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-06 20:09 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-07-06 20:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-07-06 20:09:38

Modified files:
	lib/metadata   : metadata.c 

Log message:
	fix code in 2nd mda unignore loop to match 1st loop

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.382&r2=1.383

--- LVM2/lib/metadata/metadata.c	2010/07/06 17:29:50	1.382
+++ LVM2/lib/metadata/metadata.c	2010/07/06 20:09:38	1.383
@@ -1133,8 +1133,8 @@
 		}
 
 	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use)
-		if (mda_is_ignored(mda) &&
-		    dm_bit(mda_to_unignore_bs, num_to_unignore - 1)) {
+		if (mda_is_ignored(mda) && (--mda_free_count,
+		    dm_bit(mda_to_unignore_bs, mda_free_count))) {
 			mda_set_ignored(mda, 0);
 			if (!--num_to_unignore)
 				goto out;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-06 17:29 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-07-06 17:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-07-06 17:29:50

Modified files:
	lib/metadata   : metadata.c 

Log message:
	s/flags/mda/

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.381&r2=1.382

--- LVM2/lib/metadata/metadata.c	2010/07/06 17:27:32	1.381
+++ LVM2/lib/metadata/metadata.c	2010/07/06 17:29:50	1.382
@@ -1074,7 +1074,7 @@
 	int r = 1;
 
 	log_debug("Adjusting ignored mdas for %s: %" PRIu32 " of %" PRIu32 " mdas in use "
-		  "but %" PRIu32 " required.  Changing %" PRIu32 " flags.",
+		  "but %" PRIu32 " required.  Changing %" PRIu32 " mda.",
 		  vg->name, mda_used_count, vg_mda_count(vg), vg_mda_copies(vg), num_to_ignore);
 
 	if (!num_to_ignore)
@@ -1115,7 +1115,7 @@
 		return 1;
 
 	log_debug("Adjusting ignored mdas for %s: %" PRIu32 " of %" PRIu32 " mdas in use "
-		  "but %" PRIu32 " required.  Changing %" PRIu32 " flags.",
+		  "but %" PRIu32 " required.  Changing %" PRIu32 " mda.",
 		  vg->name, mda_used_count, mda_count, vg_mda_copies(vg), num_to_unignore);
 
 	if (!(mda_to_unignore_bs = _bitset_with_random_bits(vg->vgmem, mda_free_count,


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-06 17:27 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-07-06 17:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-07-06 17:27:32

Modified files:
	lib/metadata   : metadata.c 

Log message:
	shorten mesg

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.380&r2=1.381

--- LVM2/lib/metadata/metadata.c	2010/07/06 17:26:08	1.380
+++ LVM2/lib/metadata/metadata.c	2010/07/06 17:27:32	1.381
@@ -1073,7 +1073,7 @@
 	dm_bitset_t mda_to_ignore_bs;
 	int r = 1;
 
-	log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " of %" PRIu32 " mdas in use "
+	log_debug("Adjusting ignored mdas for %s: %" PRIu32 " of %" PRIu32 " mdas in use "
 		  "but %" PRIu32 " required.  Changing %" PRIu32 " flags.",
 		  vg->name, mda_used_count, vg_mda_count(vg), vg_mda_copies(vg), num_to_ignore);
 
@@ -1114,7 +1114,7 @@
 	if (!num_to_unignore)
 		return 1;
 
-	log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " of %" PRIu32 " mdas in use "
+	log_debug("Adjusting ignored mdas for %s: %" PRIu32 " of %" PRIu32 " mdas in use "
 		  "but %" PRIu32 " required.  Changing %" PRIu32 " flags.",
 		  vg->name, mda_used_count, mda_count, vg_mda_copies(vg), num_to_unignore);
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-07-06 17:26 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-07-06 17:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-07-06 17:26:09

Modified files:
	lib/metadata   : metadata.c 

Log message:
	fix jumbled args in 'Adjusting' message

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.379&r2=1.380

--- LVM2/lib/metadata/metadata.c	2010/07/05 22:23:15	1.379
+++ LVM2/lib/metadata/metadata.c	2010/07/06 17:26:08	1.380
@@ -1116,7 +1116,7 @@
 
 	log_debug("Adjusting ignored mdas on vg %s: %" PRIu32 " of %" PRIu32 " mdas in use "
 		  "but %" PRIu32 " required.  Changing %" PRIu32 " flags.",
-		  vg->name, vg_mda_copies(vg), mda_count, mda_used_count, num_to_unignore);
+		  vg->name, mda_used_count, mda_count, vg_mda_copies(vg), num_to_unignore);
 
 	if (!(mda_to_unignore_bs = _bitset_with_random_bits(vg->vgmem, mda_free_count,
 							    num_to_unignore, &vg->cmd->rand_seed)))


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-30 19:55 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-30 19:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-30 19:55:44

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Check for missing_pv in vg_remove loop.
	
	If a pv is missing, we should just skip it rather than checking the
	device size and failing the vgremove.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.376&r2=1.377

--- LVM2/lib/metadata/metadata.c	2010/06/30 19:28:35	1.376
+++ LVM2/lib/metadata/metadata.c	2010/06/30 19:55:43	1.377
@@ -566,6 +566,9 @@
 	/* init physical volumes */
 	dm_list_iterate_items(pvl, &vg->removed_pvs) {
 		pv = pvl->pv;
+		if (is_missing_pv(pv))
+			continue;
+
 		log_verbose("Removing physical volume \"%s\" from "
 			    "volume group \"%s\"", pv_dev_name(pv), vg->name);
 		pv->vg_name = vg->fid->fmt->orphan_vg_name;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-30 14:54 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-06-30 14:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-06-30 14:54:30

Modified files:
	lib/metadata   : metadata.c 

Log message:
	revert that

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.372&r2=1.373

--- LVM2/lib/metadata/metadata.c	2010/06/30 14:52:29	1.372
+++ LVM2/lib/metadata/metadata.c	2010/06/30 14:54:29	1.373
@@ -1111,7 +1111,7 @@
 	 * below check and retain correctness.
 	 */
 	if ((!dm_list_size(&vg->fid->metadata_areas_in_use) ||
-	    (!vg_mda_used_count(vg)) && vg_mda_count(vg)))
+	    !vg_mda_used_count(vg)) && vg_mda_count(vg))
 		ret = _vg_unignore_mdas(vg, 1);
 
 	if (!ret)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-30 14:52 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-06-30 14:52 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-06-30 14:52:30

Modified files:
	lib/metadata   : metadata.c 

Log message:
	suppress useless compiler warning

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.371&r2=1.372

--- LVM2/lib/metadata/metadata.c	2010/06/30 14:48:07	1.371
+++ LVM2/lib/metadata/metadata.c	2010/06/30 14:52:29	1.372
@@ -1111,7 +1111,7 @@
 	 * below check and retain correctness.
 	 */
 	if ((!dm_list_size(&vg->fid->metadata_areas_in_use) ||
-	    !vg_mda_used_count(vg)) && vg_mda_count(vg))
+	    (!vg_mda_used_count(vg)) && vg_mda_count(vg)))
 		ret = _vg_unignore_mdas(vg, 1);
 
 	if (!ret)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-30 14:48 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-30 14:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-30 14:48:08

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Only attempt to guarantee 1 mda ignored if there's at least one mda in the vg.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.370&r2=1.371

--- LVM2/lib/metadata/metadata.c	2010/06/30 14:27:40	1.370
+++ LVM2/lib/metadata/metadata.c	2010/06/30 14:48:07	1.371
@@ -1110,8 +1110,8 @@
 	 * and another not ignored; function needs refactoring to simplify the
 	 * below check and retain correctness.
 	 */
-	if (!dm_list_size(&vg->fid->metadata_areas_in_use) ||
-	    !vg_mda_used_count(vg) && vg_mda_count(vg))
+	if ((!dm_list_size(&vg->fid->metadata_areas_in_use) ||
+	    !vg_mda_used_count(vg)) && vg_mda_count(vg))
 		ret = _vg_unignore_mdas(vg, 1);
 
 	if (!ret)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-30 14:27 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-06-30 14:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-06-30 14:27:40

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Only attempt to guarantee 1 mda ignored if there's at least one mda in the vg.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.369&r2=1.370

--- LVM2/lib/metadata/metadata.c	2010/06/30 13:51:13	1.369
+++ LVM2/lib/metadata/metadata.c	2010/06/30 14:27:40	1.370
@@ -1111,7 +1111,7 @@
 	 * below check and retain correctness.
 	 */
 	if (!dm_list_size(&vg->fid->metadata_areas_in_use) ||
-	    !vg_mda_used_count(vg))
+	    !vg_mda_used_count(vg) && vg_mda_count(vg))
 		ret = _vg_unignore_mdas(vg, 1);
 
 	if (!ret)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-28 20:38 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-28 20:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:38:56

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Update check in vg_split_mdas to account for ignored mdas list.
	
	The check in vg_split_mdas will trigger an error if the 'from' vg
	list is empty.  However, this might be ok in some instances now
	that we have ignored mdas.  Relax this check so an error is triggered
	only in the case where there's truly no more mdas in the 'from'
	vg.
	
	One example of where this makes a difference is with vgreduce.
	If we try to vgreduce a PV with un-ignored mdas, this should trigger
	the balancing function to un-ignore mdas on another PV in the VG.
	However, we don't get to vg_write() before we fail because this
	list size check fails, and we see an error message indicating:
	"Cannot remove final metadata area ..."
	
	Another example is with vgsplit into a new VG, where the PVs
	being moved contain all ignored mdas.  We must move the mdas on
	fid->metadata_areas_ignored from 'vg_from' to 'vg_to'.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.361&r2=1.362

--- LVM2/lib/metadata/metadata.c	2010/06/28 20:38:39	1.361
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:38:56	1.362
@@ -1366,20 +1366,12 @@
 	return 1;
 }
 
-/*
- * Separate metadata areas after splitting a VG.
- * Also accepts orphan VG as destination (for vgreduce).
- */
-int vg_split_mdas(struct cmd_context *cmd __attribute((unused)),
-		  struct volume_group *vg_from, struct volume_group *vg_to)
+static int _move_mdas(struct volume_group *vg_from, struct volume_group *vg_to,
+		      struct dm_list *mdas_from, struct dm_list *mdas_to)
 {
 	struct metadata_area *mda, *mda2;
-	struct dm_list *mdas_from, *mdas_to;
 	int common_mda = 0;
 
-	mdas_from = &vg_from->fid->metadata_areas_in_use;
-	mdas_to = &vg_to->fid->metadata_areas_in_use;
-
 	dm_list_iterate_items_safe(mda, mda2, mdas_from) {
 		if (!mda->ops->mda_in_vg) {
 			common_mda = 1;
@@ -1393,9 +1385,35 @@
 				dm_list_move(mdas_to, &mda->list);
 		}
 	}
+	return common_mda;
+}
+
+/*
+ * Separate metadata areas after splitting a VG.
+ * Also accepts orphan VG as destination (for vgreduce).
+ */
+int vg_split_mdas(struct cmd_context *cmd __attribute((unused)),
+		  struct volume_group *vg_from, struct volume_group *vg_to)
+{
+	struct dm_list *mdas_from_in_use, *mdas_to_in_use;
+	struct dm_list *mdas_from_ignored, *mdas_to_ignored;
+	int common_mda = 0;
 
-	if (dm_list_empty(mdas_from) ||
-	    (!is_orphan_vg(vg_to->name) && dm_list_empty(mdas_to)))
+	mdas_from_in_use = &vg_from->fid->metadata_areas_in_use;
+	mdas_from_ignored = &vg_from->fid->metadata_areas_ignored;
+	mdas_to_in_use = &vg_to->fid->metadata_areas_in_use;
+	mdas_to_ignored = &vg_to->fid->metadata_areas_ignored;
+
+	common_mda = _move_mdas(vg_from, vg_to,
+				mdas_from_in_use, mdas_to_in_use);
+	common_mda = _move_mdas(vg_from, vg_to,
+				mdas_from_ignored, mdas_to_ignored);
+
+	if ((dm_list_empty(mdas_from_in_use) &&
+	     dm_list_empty(mdas_from_ignored)) ||
+	    ((!is_orphan_vg(vg_to->name) &&
+	      dm_list_empty(mdas_to_in_use) &&
+	      dm_list_empty(mdas_to_ignored))))
 		return common_mda;
 
 	return 1;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-28 20:38 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-28 20:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:38:40

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Ensure fid mda lists are populated correctly during vgextend.
	
	The vgextend path calls add_pv_to_vg().  Inside add_pv_to_vg(),
	we must ensure we pass the correct mdas list into pv_setup(), as
	copies of mdas are placed on the vg->fid list.  If we don't place
	the mdas on the correct vg->fid list, the various counts may be
	incorrect and the metadata balance algorithm will not work when
	called from vg_write() path.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.360&r2=1.361

--- LVM2/lib/metadata/metadata.c	2010/06/28 20:37:54	1.360
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:38:39	1.361
@@ -174,6 +174,7 @@
 	struct format_instance *fid = vg->fid;
 	struct dm_pool *mem = vg->vgmem;
 	char uuid[64] __attribute((aligned(8)));
+	struct dm_list *mdas;
 
 	log_verbose("Adding physical volume '%s' to volume group '%s'",
 		    pv_name, vg->name);
@@ -217,9 +218,24 @@
 	 */
 	pv->pe_alloc_count = 0;
 
+	/*
+	 * FIXME: this does not work entirely correctly in the case where a PV
+	 * has 2 mdas and only one is ignored; ideally all non-ignored mdas
+	 * should be placed on metadata_areas list and ignored on the
+	 * metadata_areas_ignored list; however this requires another
+	 * fairly complex refactoring to remove the 'mdas' parameter from both
+	 * pv_setup and pv_write.  For now, we only put ignored mdas on the
+	 * metadata_areas_ignored list if all mdas in the PV are ignored;
+	 * otherwise, we use the non-ignored list.
+	 */
+	if (!pv_mda_used_count(pv))
+		mdas = &fid->metadata_areas_ignored;
+	else
+		mdas = &fid->metadata_areas_in_use;
+
 	if (!fid->fmt->ops->pv_setup(fid->fmt, UINT64_C(0), 0,
 				     vg->extent_size, 0, 0, 0UL, UINT64_C(0),
-				     &fid->metadata_areas_in_use, pv, vg)) {
+				     mdas, pv, vg)) {
 		log_error("Format-specific setup of physical volume '%s' "
 			  "failed.", pv_name);
 		return 0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-28 20:37 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-28 20:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:37:54

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Implement _vg_adjust_ignored_mdas and call from vg_write() path.
	
	Compare the value of the newly added vg_mda_copies field
	(--vgmetadatacopies parameter) with the current count of
	in-use mdas and ignoring or unignoring mdas as necessary to
	get to the target count.  Also, as a safety check before
	returning, ensure we have at least one mda enabled.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.359&r2=1.360

--- LVM2/lib/metadata/metadata.c	2010/06/28 20:36:56	1.359
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:37:54	1.360
@@ -58,6 +58,8 @@
 static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
 				    uint64_t status);
 
+static int _vg_adjust_ignored_mdas(struct volume_group *vg);
+
 const char _really_init[] =
     "Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
 
@@ -989,6 +991,93 @@
 	return 1;
 }
 
+static int _vg_ignore_mdas(struct volume_group *vg, uint32_t num_to_ignore)
+{
+	struct metadata_area *mda;
+
+	if (!num_to_ignore)
+		return 1;
+	/* FIXME: flip bits on random mdas */
+	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
+		if (!mda_is_ignored(mda)) {
+			mda_set_ignored(mda, 1);
+			num_to_ignore--;
+		}
+		if (!num_to_ignore)
+			return 1;
+	}
+	log_error("Unable to find %"PRIu32" metadata areas to ignore "
+		  "on volume group %s", num_to_ignore, vg->name);
+	return 0;
+}
+
+static int _vg_unignore_mdas(struct volume_group *vg, uint32_t num_to_unignore)
+{
+	struct metadata_area *mda, *tmda;
+
+	if (!num_to_unignore)
+		return 1;
+	/* FIXME: flip bits on random mdas */
+	dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_ignored) {
+		if (mda_is_ignored(mda)) {
+			mda_set_ignored(mda, 0);
+			dm_list_move(&vg->fid->metadata_areas_in_use,
+				     &mda->list);
+			num_to_unignore--;
+		}
+		if (!num_to_unignore)
+			return 1;
+	}
+	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
+		if (mda_is_ignored(mda)) {
+			mda_set_ignored(mda, 0);
+			num_to_unignore--;
+		}
+		if (!num_to_unignore)
+			return 1;
+	}
+	log_error("Unable to find %"PRIu32" metadata areas to un-ignore "
+		  "on volume group %s", num_to_unignore, vg->name);
+	return 0;
+}
+
+static int _vg_adjust_ignored_mdas(struct volume_group *vg)
+{
+	uint32_t mda_copies, count;
+	int ret = 1;
+
+	mda_copies = vg_mda_used_count(vg);
+	if (!vg->mda_copies)
+		goto skip_adjust;
+
+	if (mda_copies > vg->mda_copies) {
+		ret = _vg_ignore_mdas(vg, mda_copies - vg->mda_copies);
+	} else if (mda_copies < vg->mda_copies) {
+		/* not an error to have vg_mda_count larger than total mdas */
+		if (vg->mda_copies >= vg_mda_count(vg))
+			count = vg_mda_count(vg) - vg_mda_used_count(vg);
+		else
+			count = vg->mda_copies - mda_copies;
+		ret = _vg_unignore_mdas(vg, count);
+	}
+	if (!ret)
+		return ret;
+
+skip_adjust:
+	/*
+	 * Ensure at least one mda in use.
+	 * FIXME: check size of fid->metadata_areas_in_use; reason is because
+	 * of how pv_setup works in the case of a pv with 2 mdas, one ignored
+	 * and another not ignored; function needs refactoring to simplify the
+	 * below check and retain correctness.
+	 */
+	if (!dm_list_size(&vg->fid->metadata_areas_in_use) ||
+	    !vg_mda_used_count(vg)) {
+		ret = _vg_unignore_mdas(vg, 1);
+	}
+	return ret;
+}
+
 uint32_t vg_mda_copies(const struct volume_group *vg)
 {
 	return vg->mda_copies;
@@ -2378,6 +2467,7 @@
 		return 0;
 	}
 
+	_vg_adjust_ignored_mdas(vg);
 
 	if (dm_list_empty(&vg->fid->metadata_areas_in_use)) {
 		log_error("Aborting vg_write: No metadata areas to write to!");


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-28 20:35 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-28 20:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:35:49

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Before committing each mda, arrange mdas so ignored mdas get committed first.
	
	Arrange mdas so mdas that are to be ignored come first.  This is an
	optimization that ensures consistency on disk for the longest period of time.
	This was noted by agk in review of the v4 patchset of pvchange-based mda
	balance.
	
	Note the following example for an explanation of the background:
	Assume the initial state on disk is as follows:
	PV0 (v1, non-ignored)
	PV1 (v1, non-ignored)
	PV2 (v1, non-ignored)
	PV3 (v1, non-ignored)
	
	If we did not sort the list, we would have a commit sequence something like
	this:
	PV0 (v2, non-ignored)
	PV1 (v2, ignored)
	PV2 (v2, ignored)
	PV3 (v2, non-ignored)
	
	After the commit of PV0's mdas, we'd have an on-disk state like this:
	PV0 (v2, non-ignored)
	PV1 (v1, non-ignored)
	PV2 (v1, non-ignored)
	PV3 (v1, non-ignored)
	
	This is an inconsistent state of the disk. If the machine fails, the next
	time it was brought back up, the auto-correct mechanism in vg_read would
	update the metadata on PV1-PV3.  However, if possible we try to avoid
	inconsistent on-disk states.  Clearly, because we did not sort, we have
	a greater chance of on-disk inconsistency - from the time the commit of
	PV0 is complete until the time PV3 is complete.
	
	We could improve the amount of time the on-disk state is consistent by simply
	sorting the commit order as follows:
	PV1 (v2, ignored)
	PV2 (v2, ignored)
	PV0 (v2, non-ignored)
	PV3 (v2, non-ignored)
	
	Thus, after the first PV is committed (in this case PV1), on-disk we would
	have:
	PV0 (v1, non-ignored)
	PV1 (v2, ignored)
	PV2 (v1, non-ignored)
	PV3 (v1, non-ignored)
	
	This is clearly a consistent state.  PV1 will be read but the mda will be
	ignored.  All other PVs contain v1 metadata, and no auto-correct will be
	required.  In fact, if we commit all PVs with ignored mdas first, we'll
	only have an inconsistent state when we start writing non-ignored PVs,
	and thus the chances we'll get an inconsistent state on disk is much
	less with the sorted method.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.356&r2=1.357

--- LVM2/lib/metadata/metadata.c	2010/06/28 20:35:33	1.356
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:35:49	1.357
@@ -2426,10 +2426,21 @@
 
 static int _vg_commit_mdas(struct volume_group *vg)
 {
-	struct metadata_area *mda;
+	struct metadata_area *mda, *tmda;
+	struct dm_list ignored;
 	int failed = 0;
 	int cache_updated = 0;
 
+	/* Rearrange the metadata_areas_in_use so ignored mdas come first. */
+	dm_list_init(&ignored);
+	dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_in_use) {
+		if (mda_is_ignored(mda))
+			dm_list_move(&ignored, &mda->list);
+	}
+	dm_list_iterate_items_safe(mda, tmda, &ignored) {
+		dm_list_move(&vg->fid->metadata_areas_in_use, &mda->list);
+	}
+
 	/* Commit to each copy of the metadata area */
 	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
 		failed = 0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-06-28 20:35 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-06-28 20:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:35:34

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Refactor vg_commit() to add _vg_commit_mdas().
	
	Factor out calling mda->ops->vg_commit() for each mda.
	No functional change.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.355&r2=1.356

--- LVM2/lib/metadata/metadata.c	2010/06/28 20:35:17	1.355
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:35:33	1.356
@@ -2424,18 +2424,11 @@
 	return 1;
 }
 
-/* Commit pending changes */
-int vg_commit(struct volume_group *vg)
+static int _vg_commit_mdas(struct volume_group *vg)
 {
 	struct metadata_area *mda;
-	int cache_updated = 0;
 	int failed = 0;
-
-	if (!vgname_is_locked(vg->name)) {
-		log_error(INTERNAL_ERROR "Attempt to write new VG metadata "
-			  "without locking %s", vg->name);
-		return cache_updated;
-	}
+	int cache_updated = 0;
 
 	/* Commit to each copy of the metadata area */
 	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
@@ -2451,6 +2444,21 @@
 			cache_updated = 1;
 		}
 	}
+	return cache_updated;
+}
+
+/* Commit pending changes */
+int vg_commit(struct volume_group *vg)
+{
+	int cache_updated = 0;
+
+	if (!vgname_is_locked(vg->name)) {
+		log_error(INTERNAL_ERROR "Attempt to write new VG metadata "
+			  "without locking %s", vg->name);
+		return cache_updated;
+	}
+
+	cache_updated = _vg_commit_mdas(vg);
 
 	if (cache_updated) {
 		/* Instruct remote nodes to upgrade cached metadata. */


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-04-08 15:18 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-04-08 15:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-04-08 15:18:35

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Check for duplicate paths (pvids) on the commandline of vgcreate.
	
	A user specifying duplicate paths on the cmdline of vgcreate will
	get a message similar to the following:
	vgcreate vgtest2 /dev/loop3 /dev/loop5
	Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop5 not /dev/loop3
	Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop3 not /dev/loop5
	Internal error: Duplicate PV id jk1lXs-Kzwy-OKlX-q6bh-aFFK-MQQ0-6oPgu8 detected for /dev/loop3 in vgtest2.
	
	This is caught by vg_validate(), but it would be good to find
	this condition earlier in the vgcreate code.  add_pv_to_vg()
	currently checks by pvname, but does not look for duplcate pvids.
	This patch adds the check for duplicate pvids and results in new
	error output as follows:
	vgcreate vgtest2 /dev/loop3 /dev/loop5
	Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop5 not /dev/loop3
	Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop3 not /dev/loop5
	Physical volume '/dev/loop5 (jk1lXs-Kzwy-OKlX-q6bh-aFFK-MQQ0-6oPgu8)' listed more than once.
	Unable to add physical volume '/dev/loop5' to volume group 'vgtest2'.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.331&r2=1.332

--- LVM2/lib/metadata/metadata.c	2010/04/06 14:04:57	1.331
+++ LVM2/lib/metadata/metadata.c	2010/04/08 15:18:35	1.332
@@ -52,6 +52,9 @@
 static struct pv_list *_find_pv_in_vg(const struct volume_group *vg,
 				      const char *pv_name);
 
+static struct pv_list *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
+					      const struct id *id);
+
 static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
 				    uint64_t status);
 
@@ -160,6 +163,7 @@
 	struct pv_list *pvl;
 	struct format_instance *fid = vg->fid;
 	struct dm_pool *mem = vg->vgmem;
+	char uuid[64] __attribute((aligned(8)));
 
 	log_verbose("Adding physical volume '%s' to volume group '%s'",
 		    pv_name, vg->name);
@@ -211,9 +215,14 @@
 		return 0;
 	}
 
-	if (_find_pv_in_vg(vg, pv_name)) {
-		log_error("Physical volume '%s' listed more than once.",
-			  pv_name);
+	if (_find_pv_in_vg(vg, pv_name) ||
+	    _find_pv_in_vg_by_uuid(vg, &pv->id)) {
+		if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
+			stack;
+			uuid[0] = '\0';
+		}
+		log_error("Physical volume '%s (%s)' listed more than once.",
+			  pv_name, uuid);
 		return 0;
 	}
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-04-06 14:03 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-04-06 14:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-04-06 14:03:44

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Add pv to vg->pvs after check for maximum value of vg->extent_count.
	
	In add_pv_to_vg(), we should only add the pv to vg->pvs after all
	internal checks have passed.  The check for vg->extent_count exeeding
	maximum was after we added the pv to the list, so this function could
	return a state of vg->pvs that did not reflect other parameters such
	as vg->pv_count.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.329&r2=1.330

--- LVM2/lib/metadata/metadata.c	2010/04/01 13:08:06	1.329
+++ LVM2/lib/metadata/metadata.c	2010/04/06 14:03:43	1.330
@@ -220,9 +220,6 @@
 	if (!alloc_pv_segment_whole_pv(mem, pv))
 		return_0;
 
-	pvl->pv = pv;
-	dm_list_add(&vg->pvs, &pvl->list);
-
 	if ((uint64_t) vg->extent_count + pv->pe_count > UINT32_MAX) {
 		log_error("Unable to add %s to %s: new extent count (%"
 			  PRIu64 ") exceeds limit (%" PRIu32 ").",
@@ -232,6 +229,9 @@
 		return 0;
 	}
 
+	pvl->pv = pv;
+	dm_list_add(&vg->pvs, &pvl->list);
+
 	vg->pv_count++;
 	vg->extent_count += pv->pe_count;
 	vg->free_count += pv->pe_count;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-04-01 13:08 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-04-01 13:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-04-01 13:08:07

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Avoid endless loop if lv->segments list is corrupted

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.328&r2=1.329

--- LVM2/lib/metadata/metadata.c	2010/04/01 11:45:36	1.328
+++ LVM2/lib/metadata/metadata.c	2010/04/01 13:08:06	1.329
@@ -2191,6 +2191,12 @@
 		if (lv_is_visible(lvl->lv))
 			lv_visible_count++;
 
+		if (!check_lv_segments(lvl->lv, 0)) {
+			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
+				  lvl->lv->name);
+			r = 0;
+		}
+
 		if (lvl->lv->status & VISIBLE_LV)
 			continue;
 
@@ -2224,6 +2230,10 @@
 		r = 0;
 	}
 
+	/* Avoid endless loop if lv->segments list is corrupt */
+	if (!r)
+		return r;
+
 	loop_counter1 = loop_counter2 = 0;
 	/* FIXME Use temp hash table instead? */
 	dm_list_iterate_items(lvl, &vg->lvs) {
@@ -2253,12 +2263,6 @@
 			}
 		}
 
-		if (!check_lv_segments(lvl->lv, 0)) {
-			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
-				  lvl->lv->name);
-			r = 0;
-		}
-
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
@@ -2928,6 +2932,9 @@
 			vg_release(vg);
 			return NULL;
 		}
+	}
+
+	dm_list_iterate_items(lvl, &vg->lvs) {
 		/*
 		 * Checks that cross-reference other LVs.
 		 */


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-04-01 11:45 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2010-04-01 11:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-04-01 11:45:37

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Improve vg_validate to detect some loops in lists.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.327&r2=1.328

--- LVM2/lib/metadata/metadata.c	2010/04/01 11:43:26	1.327
+++ LVM2/lib/metadata/metadata.c	2010/04/01 11:45:36	1.328
@@ -2253,6 +2253,12 @@
 			}
 		}
 
+		if (!check_lv_segments(lvl->lv, 0)) {
+			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
+				  lvl->lv->name);
+			r = 0;
+		}
+
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-02-24 18:15 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-02-24 18:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-02-24 18:15:58

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag()
	
	We need to allocate memory for the tag and copy the tag value before we
	add it to the list of tags.  We could put this inside lvm2app since the
	tools keep their memory around until vg_write/vg_commit is called, but
	we put it inside the internal library to minimize code in lvm2app.
	We need to copy the tag passed in by the caller to ensure the lifetime of
	the memory until the {vg|lv} handle is released.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.316&r2=1.317

--- LVM2/lib/metadata/metadata.c	2010/02/24 18:15:49	1.316
+++ LVM2/lib/metadata/metadata.c	2010/02/24 18:15:57	1.317
@@ -667,6 +667,8 @@
 
 int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
 {
+	char *tag_new;
+
 	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
 		log_error("Logical volume %s/%s does not support tags",
 			  lv->vg->name, lv->name);
@@ -674,7 +676,10 @@
 	}
 
 	if (add_tag) {
-		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
+		if (!(tag_new = dm_pool_strdup(lv->vg->vgmem, tag))) {
+			return_0;
+		}
+		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag_new)) {
 			log_error("Failed to add tag %s to %s/%s",
 				  tag, lv->vg->name, lv->name);
 			return 0;
@@ -691,13 +696,18 @@
 
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
 {
+	char *tag_new;
+
 	if (!(vg->fid->fmt->features & FMT_TAGS)) {
 		log_error("Volume group %s does not support tags", vg->name);
 		return 0;
 	}
 
 	if (add_tag) {
-		if (!str_list_add(vg->vgmem, &vg->tags, tag)) {
+		if (!(tag_new = dm_pool_strdup(vg->vgmem, tag))) {
+			return_0;
+		}
+		if (!str_list_add(vg->vgmem, &vg->tags, tag_new)) {
 			log_error("Failed to add tag %s to volume group %s",
 				  tag, vg->name);
 			return 0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-01-21 21:04 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-01-21 21:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-01-21 21:04:44

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove useless memory allocation for pv->vg_name in _alloc_pv().
	
	All this seems to do is provide a memory leak so remove it.
	The only caller of _alloc_pv() later explicitly sets
	pv->vg_name = fmt->orphan_vg_name so clearly this allocation
	should be removed.  I also saw no where in the code where
	strncpy was used to assign pv->vg_name - only direct assignments
	and strdup's.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.310&r2=1.311

--- LVM2/lib/metadata/metadata.c	2010/01/21 21:04:20	1.310
+++ LVM2/lib/metadata/metadata.c	2010/01/21 21:04:44	1.311
@@ -1443,11 +1443,6 @@
 	if (!pv)
 		return_NULL;
 
-	if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN))) {
-		dm_pool_free(mem, pv);
-		return NULL;
-	}
-
 	pv->pe_size = 0;
 	pv->pe_start = 0;
 	pv->pe_count = 0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-01-21 21:04 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2010-01-21 21:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-01-21 21:04:21

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Correct 'void *' usage in pvcreate_single.
	
	Remove needless cast.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.309&r2=1.310

--- LVM2/lib/metadata/metadata.c	2010/01/07 14:29:53	1.309
+++ LVM2/lib/metadata/metadata.c	2010/01/21 21:04:20	1.310
@@ -1348,7 +1348,7 @@
 					 const char *pv_name,
 					 struct pvcreate_params *pp)
 {
-	void *pv;
+	struct physical_volume *pv;
 	struct device *dev;
 	struct dm_list mdas;
 	struct pvcreate_params default_pp;
@@ -1418,8 +1418,7 @@
 
 	log_very_verbose("Writing physical volume data to disk \"%s\"",
 			 pv_name);
-	if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas,
-		       pp->labelsector))) {
+	if (!(pv_write(cmd, pv, &mdas, pp->labelsector))) {
 		log_error("Failed to write physical volume \"%s\"", pv_name);
 		goto error;
 	}


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2010-01-07 14:29 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2010-01-07 14:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-01-07 14:29:53

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Just add '.' at the end of error message.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.308&r2=1.309

--- LVM2/lib/metadata/metadata.c	2010/01/05 16:09:34	1.308
+++ LVM2/lib/metadata/metadata.c	2010/01/07 14:29:53	1.309
@@ -2116,7 +2116,7 @@
 		}
 
 		if (strcmp(pvl->pv->vg_name, vg->name)) {
-			log_error(INTERNAL_ERROR "VG name for PV %s is corrupted",
+			log_error(INTERNAL_ERROR "VG name for PV %s is corrupted.",
 				  pv_dev_name(pvl->pv));
 			r = 0;
 		}


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-12-16 19:26 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2009-12-16 19:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-12-16 19:26:21

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Revert unintended change that slipped in with last checkin.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.303&r2=1.304

--- LVM2/lib/metadata/metadata.c	2009/12/16 19:22:12	1.303
+++ LVM2/lib/metadata/metadata.c	2009/12/16 19:26:20	1.304
@@ -3520,7 +3520,6 @@
 
 	/* Found vgname so cannot reserve. */
 	unlock_vg(cmd, vgname);
-	log_error("A volume group called '%s' already exists.", vg_name);
 	return FAILED_EXIST;
 }
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-11-19 13:44 mornfall
  0 siblings, 0 replies; 73+ messages in thread
From: mornfall @ 2009-11-19 13:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-11-19 13:44:37

Modified files:
	lib/metadata   : metadata.c 

Log message:
	In case we refuse to continue due to missing PVs, print a hint about using
	vgreduce --removemissing to remedy the situation.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.296&r2=1.297

--- LVM2/lib/metadata/metadata.c	2009/11/19 12:13:37	1.296
+++ LVM2/lib/metadata/metadata.c	2009/11/19 13:44:37	1.297
@@ -3378,8 +3378,8 @@
 
 	if (!cmd->handles_missing_pvs && vg_missing_pv_count(vg) &&
 	    (lock_flags & LCK_WRITE)) {
-		log_error("Cannot change VG %s while PVs are missing!",
-			  vg->name);
+		log_error("Cannot change VG %s while PVs are missing.", vg->name);
+		log_error("Consider vgreduce --removemissing.");
 		failure |= FAILED_INCONSISTENT; /* FIXME new failure code here? */
 		goto_bad;
 	}


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-10-05 20:02 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-10-05 20:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-05 20:02:30

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Add pvcreate_params to vg_extend_single_pv.
	
	Should be no functional change.  If this parameter is set to NULL, just fail
	the extend if the device is not already a PV.  If non-NULL, try pvcreate_single
	before failing.  Note that pvcreate_single() handles the log_error in case
	of failure so we just return 0 if pvcreate_single() fails.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.285&r2=1.286

--- LVM2/lib/metadata/metadata.c	2009/10/05 20:02:04	1.285
+++ LVM2/lib/metadata/metadata.c	2009/10/05 20:02:30	1.286
@@ -559,16 +559,23 @@
  * Parameters:
  * - vg: handle of volume group to extend by 'pv_name'
  * - pv_name: device path of PV to add to VG
+ * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
  *
  */
-static int vg_extend_single_pv(struct volume_group *vg, char *pv_name)
+static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
+			       struct pvcreate_params *pp)
 {
 	struct physical_volume *pv;
 
-	if (!(pv = pv_by_path(vg->fid->fmt->cmd, pv_name))) {
+	pv = pv_by_path(vg->fid->fmt->cmd, pv_name);
+	if (!pv && !pp) {
 		log_error("%s not identified as an existing "
 			  "physical volume", pv_name);
 		return 0;
+	} else if (!pv && pp) {
+		pv = pvcreate_single(vg->cmd, pv_name, pp);
+		if (!pv)
+			return 0;
 	}
 	if (!add_pv_to_vg(vg, pv_name, pv))
 		return 0;
@@ -584,7 +591,7 @@
 
 	/* attach each pv */
 	for (i = 0; i < pv_count; i++) {
-		if (!vg_extend_single_pv(vg, pv_names[i]))
+		if (!vg_extend_single_pv(vg, pv_names[i], NULL))
 			goto bad;
 	}
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-10-05 20:02 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-10-05 20:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-05 20:02:04

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Refactor vg_extend - add vg_extend_single_pv.
	
	Simple refactor to setup future changes related to implicit pvcreates.
	Should be no functional change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.284&r2=1.285

--- LVM2/lib/metadata/metadata.c	2009/09/15 18:35:14	1.284
+++ LVM2/lib/metadata/metadata.c	2009/10/05 20:02:04	1.285
@@ -553,22 +553,38 @@
 	return ret;
 }
 
+/*
+ * Extend a VG by a single PV / device path
+ *
+ * Parameters:
+ * - vg: handle of volume group to extend by 'pv_name'
+ * - pv_name: device path of PV to add to VG
+ *
+ */
+static int vg_extend_single_pv(struct volume_group *vg, char *pv_name)
+{
+	struct physical_volume *pv;
+
+	if (!(pv = pv_by_path(vg->fid->fmt->cmd, pv_name))) {
+		log_error("%s not identified as an existing "
+			  "physical volume", pv_name);
+		return 0;
+	}
+	if (!add_pv_to_vg(vg, pv_name, pv))
+		return 0;
+	return 1;
+}
+
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
 {
 	int i;
-	struct physical_volume *pv;
 
 	if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
 		return 0;
 
 	/* attach each pv */
 	for (i = 0; i < pv_count; i++) {
-		if (!(pv = pv_by_path(vg->fid->fmt->cmd, pv_names[i]))) {
-			log_error("%s not identified as an existing "
-				  "physical volume", pv_names[i]);
-			goto bad;
-		}
-		if (!add_pv_to_vg(vg, pv_names[i], pv))
+		if (!vg_extend_single_pv(vg, pv_names[i]))
 			goto bad;
 	}
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-09-02 21:39 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-09-02 21:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:39:49

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Update vg_remove_single_* functions to use the removed_pvs list.
	
	Now that we've split vg_remove_single into two routines, in the first routine
	that only manipulates memory, we move the PVs from the vg->pvs list to the
	vg->removed_pvs list.  Then later, we iterate through this list to write the
	removed PVs to disk, which removes them from the volume group and places them
	into the internal ORPHAN VG.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.281&r2=1.282

--- LVM2/lib/metadata/metadata.c	2009/09/02 21:39:29	1.281
+++ LVM2/lib/metadata/metadata.c	2009/09/02 21:39:49	1.282
@@ -471,6 +471,7 @@
 int vg_remove_check(struct volume_group *vg)
 {
 	unsigned lv_count;
+	struct pv_list *pvl, *tpvl;
 
 	if (vg_read_error(vg) || vg_missing_pv_count(vg)) {
 		log_error("Volume group \"%s\" not found, is inconsistent "
@@ -494,6 +495,10 @@
 	if (!archive(vg))
 		return 0;
 
+	dm_list_iterate_items_safe(pvl, tpvl, &vg->pvs) {
+		dm_list_del(&pvl->list);
+		dm_list_add(&vg->removed_pvs, &pvl->list);
+	}
 	return 1;
 }
 
@@ -515,7 +520,7 @@
 	}
 
 	/* init physical volumes */
-	dm_list_iterate_items(pvl, &vg->pvs) {
+	dm_list_iterate_items(pvl, &vg->removed_pvs) {
 		pv = pvl->pv;
 		log_verbose("Removing physical volume \"%s\" from "
 			    "volume group \"%s\"", pv_dev_name(pv), vg->name);


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-28 20:41 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2009-07-28 20:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-28 20:41:42

Modified files:
	lib/metadata   : metadata.c 

Log message:
	\n

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.272&r2=1.273

--- LVM2/lib/metadata/metadata.c	2009/07/28 15:14:56	1.272
+++ LVM2/lib/metadata/metadata.c	2009/07/28 20:41:41	1.273
@@ -3046,7 +3046,7 @@
 int vg_check_write_mode(vg_t *vg)
 {
 	if (vg->open_mode != 'w') {
-		log_errno(EPERM, "Attempt to modify a read-only VG\n");
+		log_errno(EPERM, "Attempt to modify a read-only VG");
 		return 0;
 	}
 	return 1;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-26 12:41 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-07-26 12:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 12:41:36

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Use vg_size in vg_set_extent_size.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.268&r2=1.269

--- LVM2/lib/metadata/metadata.c	2009/07/26 12:41:09	1.268
+++ LVM2/lib/metadata/metadata.c	2009/07/26 12:41:36	1.269
@@ -758,7 +758,7 @@
 	}
 
 	if (new_size > vg->extent_size) {
-		if ((uint64_t) vg->extent_size * vg->extent_count % new_size) {
+		if ((uint64_t) vg_size(vg) % new_size) {
 			/* FIXME Adjust used PV sizes instead */
 			log_error("New extent size is not a perfect fit");
 			return 0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-26  1:53 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-07-26  1:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 01:53:30

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Allow pvcreate_single to be called with NULL for default pvcreate params.
	
	Passing NULL for pvcreate parameters gives you default parameters for
	pvcreate_single.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.262&r2=1.263

--- LVM2/lib/metadata/metadata.c	2009/07/26 01:53:09	1.262
+++ LVM2/lib/metadata/metadata.c	2009/07/26 01:53:30	1.263
@@ -1089,12 +1089,37 @@
 	return 1;
 }
 
+static void fill_default_pvcreate_params(struct pvcreate_params *pp)
+{
+	memset(pp, 0, sizeof(*pp));
+	pp->zero = 0;
+	pp->size = 0;
+	pp->data_alignment = UINT64_C(0);
+	pp->pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
+	pp->pvmetadatasize = DEFAULT_PVMETADATASIZE;
+	pp->labelsector = DEFAULT_LABELSECTOR;
+	pp->idp = 0;
+	pp->pe_start = 0;
+	pp->extent_count = 0;
+	pp->extent_size = 0;
+	pp->restorefile = 0;
+	pp->force = PROMPT;
+	pp->yes = 0;
+}
+
 int pvcreate_single(struct cmd_context *cmd, const char *pv_name, void *handle)
 {
-	struct pvcreate_params *pp = (struct pvcreate_params *) handle;
+	struct pvcreate_params *pp;
 	void *pv;
 	struct device *dev;
 	struct dm_list mdas;
+	struct pvcreate_params default_pp;
+
+	fill_default_pvcreate_params(&default_pp);
+	if (!handle)
+		pp = &default_pp;
+	else
+		pp = (struct pvcreate_params *) handle;
 
 	if (pp->idp) {
 		if ((dev = device_from_pvid(cmd, pp->idp)) &&


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-26  1:52 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-07-26  1:52 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 01:52:19

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove unneeded pv_create wrapper function.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.260&r2=1.261

--- LVM2/lib/metadata/metadata.c	2009/07/24 15:15:26	1.260
+++ LVM2/lib/metadata/metadata.c	2009/07/26 01:52:19	1.261
@@ -44,16 +44,6 @@
 					uint64_t *label_sector,
 					int warnings, int scan_label_only);
 
-static struct physical_volume *_pv_create(const struct format_type *fmt,
-				  struct device *dev,
-				  struct id *id, uint64_t size,
-				  unsigned long data_alignment,
-				  uint64_t pe_start,
-				  uint32_t existing_extent_count,
-				  uint32_t existing_extent_size,
-				  int pvmetadatacopies,
-				  uint64_t pvmetadatasize, struct dm_list *mdas);
-
 static int _pv_write(struct cmd_context *cmd __attribute((unused)),
 		     struct physical_volume *pv,
 	     	     struct dm_list *mdas, int64_t label_sector);
@@ -964,44 +954,6 @@
 	return 1;
 }
 
-/**
- * pv_create - initialize a physical volume for use with a volume group
- * @fmt: format type
- * @dev: PV device to initialize
- * @id: PV UUID to use for initialization
- * @size: size of the PV in sectors
- * @data_alignment: requested alignment of data
- * @pe_start: physical extent start
- * @existing_extent_count
- * @existing_extent_size
- * @pvmetadatacopies
- * @pvmetadatasize
- * @mdas
- *
- * Returns:
- *   PV handle - physical volume initialized successfully
- *   NULL - invalid parameter or problem initializing the physical volume
- *
- * Note:
- *   FIXME - liblvm todo - tidy up arguments for external use (fmt, mdas, etc)
- */
-pv_t *pv_create(const struct cmd_context *cmd,
-		struct device *dev,
-		struct id *id, uint64_t size,
-		unsigned long data_alignment,
-		uint64_t pe_start,
-		uint32_t existing_extent_count,
-		uint32_t existing_extent_size,
-		int pvmetadatacopies,
-		uint64_t pvmetadatasize, struct dm_list *mdas)
-{
-	return _pv_create(cmd->fmt, dev, id, size, data_alignment, pe_start,
-			  existing_extent_count,
-			  existing_extent_size,
-			  pvmetadatacopies,
-			  pvmetadatasize, mdas);
-}
-
 static void _free_pv(struct dm_pool *mem, struct physical_volume *pv)
 {
 	dm_pool_free(mem, pv);
@@ -1035,8 +987,28 @@
 	return pv;
 }
 
-/* Sizes in sectors */
-static struct physical_volume *_pv_create(const struct format_type *fmt,
+/**
+ * pv_create - initialize a physical volume for use with a volume group
+ *
+ * @fmt: format type
+ * @dev: PV device to initialize
+ * @size: size of the PV in sectors
+ * @data_alignment: requested alignment of data
+ * @pe_start: physical extent start
+ * @existing_extent_count
+ * @existing_extent_size
+ * @pvmetadatacopies
+ * @pvmetadatasize
+ * @mdas
+ *
+ * Returns:
+ *   PV handle - physical volume initialized successfully
+ *   NULL - invalid parameter or problem initializing the physical volume
+ *
+ * Note:
+ *   FIXME: shorten argument list and replace with explict 'set' functions
+ */
+struct physical_volume *pv_create(const struct cmd_context *cmd,
 				  struct device *dev,
 				  struct id *id, uint64_t size,
 				  unsigned long data_alignment,
@@ -1046,6 +1018,7 @@
 				  int pvmetadatacopies,
 				  uint64_t pvmetadatasize, struct dm_list *mdas)
 {
+	const struct format_type *fmt = cmd->fmt;
 	struct dm_pool *mem = fmt->cmd->mem;
 	struct physical_volume *pv = _alloc_pv(mem, dev);
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-24 15:15 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-07-24 15:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-24 15:15:26

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Eliminate compile warning introduced by previous commit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.259&r2=1.260

--- LVM2/lib/metadata/metadata.c	2009/07/24 15:01:43	1.259
+++ LVM2/lib/metadata/metadata.c	2009/07/24 15:15:26	1.260
@@ -513,7 +513,6 @@
 {
 	int i;
 	struct physical_volume *pv;
-	struct cmd_context *cmd = vg->cmd;
 
 	if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
 		return 0;


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-16 20:18 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-07-16 20:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-16 20:18:16

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove 'is already' message from vg_set_* functions.
	
	These messages are unnecessary in the set functions.  We check for this
	condition and print a message in the vgchange tool but not the library
	functions.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.257&r2=1.258

--- LVM2/lib/metadata/metadata.c	2009/07/16 03:25:26	1.257
+++ LVM2/lib/metadata/metadata.c	2009/07/16 20:18:16	1.258
@@ -741,11 +741,8 @@
 		return 0;
 	}
 
-	if (new_size == vg->extent_size) {
-		log_verbose("Physical extent size of VG %s is already %s",
-			  vg->name, display_size(vg->cmd, (uint64_t) new_size));
+	if (new_size == vg->extent_size)
 		return 1;
-	}
 
 	if (new_size & (new_size - 1)) {
 		log_error("Physical extent size must be a power of 2.");
@@ -932,11 +929,9 @@
 		return 0;
 	}
 
-	if (alloc == vg->alloc) {
-		log_verbose("Volume group allocation policy is already %s",
-			  get_alloc_string(vg->alloc));
+	if (alloc == vg->alloc)
 		return 1;
-	}
+
 	vg->alloc = alloc;
 	return 1;
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-07-01 17:03 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-07-01 17:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-01 17:03:39

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Don't segfault in vg_release when vg->cmd is NULL.
	
	Sun May  3 13:06:14 CEST 2009  Petr Rockai <me@mornfall.net>
	* Don't segfault in vg_release when vg->cmd is NULL.
	
	Author: Petr Rockai <prockai@redhat.com>
	Committer: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.229&r2=1.230

--- LVM2/lib/metadata/metadata.c	2009/07/01 17:00:51	1.229
+++ LVM2/lib/metadata/metadata.c	2009/07/01 17:03:38	1.230
@@ -2165,7 +2165,7 @@
 	if (!vg || !vg->vgmem)
 		return;
 
-	if (vg->vgmem == vg->cmd->mem)
+	if (vg->cmd && vg->vgmem == vg->cmd->mem)
 		log_error("Internal error: global memory pool used for VG %s",
 			  vg->name);
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-06-10 16:14 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-06-10 16:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-06-10 16:14:40

Modified files:
	lib/metadata   : metadata.c 

Log message:
	In the new _vg_read_for_update(), we always do the check for CLUSTERED vg
	status flag after reading the volume group.  Thus, no need to set the flag
	in vg_read() or clear it later before calling _vg_bad_status_bits().
	
	Also, add back in the !lockingfailed() as part of the CLUSTERED flag check.
	It's unclear why it was removed when the check was moved from
	_vg_bad_status_bits() to inside _vg_lock_and_read().
	There was an open question about the last check in the 'if' stmt for
	lockingfailed() with a previous patch submitted.  However, I would
	defer that right now as it is a separate item and this patch should
	be no functional change by including the !lockingfailed().
	
	Petr acked this patch on 5/26 I just forgot to check it in.
	
	Acked-by: Petr Rockai <prockai@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.225&r2=1.226

--- LVM2/lib/metadata/metadata.c	2009/06/09 14:29:10	1.225
+++ LVM2/lib/metadata/metadata.c	2009/06/10 16:14:40	1.226
@@ -2772,7 +2772,8 @@
 		goto_bad;
 	}
 
-	if (vg_is_clustered(vg) && !locking_is_clustered()) {
+	if (vg_is_clustered(vg) && !locking_is_clustered() &&
+	    !lockingfailed()) {
 		log_error("Skipping clustered volume group %s", vg->name);
 		failure |= FAILED_CLUSTERED;
 		goto_bad;
@@ -2790,7 +2791,7 @@
 	}
 	
 
-	failure |= _vg_bad_status_bits(vg, status_flags & ~CLUSTERED);
+	failure |= _vg_bad_status_bits(vg, status_flags);
 	if (failure)
 		goto_bad;
 
@@ -2837,7 +2838,7 @@
 vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
 	      const char *vgid, uint32_t flags)
 {
-	uint32_t status = CLUSTERED;
+	uint32_t status = 0;
 	uint32_t lock_flags = LCK_VG_READ;
 
 	if (flags & READ_FOR_UPDATE) {


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-05-13  1:48 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2009-05-13  1:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-05-13 01:48:19

Modified files:
	lib/metadata   : metadata.c 

Log message:
	better variable name for snapshot counting

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.215&r2=1.216

--- LVM2/lib/metadata/metadata.c	2009/05/12 19:12:09	1.215
+++ LVM2/lib/metadata/metadata.c	2009/05/13 01:48:18	1.216
@@ -1156,13 +1156,13 @@
 unsigned snapshot_count(const struct volume_group *vg)
 {
 	struct lv_list *lvl;
-	unsigned lv_count = 0;
+	unsigned num_snapshots = 0;
 
 	dm_list_iterate_items(lvl, &vg->lvs)
 		if (lv_is_cow(lvl->lv))
-			lv_count++;
+			num_snapshots++;
 
-	return lv_count;
+	return num_snapshots;
 }
 
 /*


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-04-28 17:46 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2009-04-28 17:46 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-04-28 17:46:47

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Fix error path in vg_make_handle().
	
	Enter the error condition if either of the allocations fail, and
	don't use dm_pool_zalloc if dm_pool_create fails.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.212&r2=1.213

--- LVM2/lib/metadata/metadata.c	2009/04/22 09:31:31	1.212
+++ LVM2/lib/metadata/metadata.c	2009/04/28 17:46:47	1.213
@@ -2595,7 +2595,7 @@
 	struct dm_pool *vgmem;
 
 	if (!vg) {
-		if (!(vgmem = dm_pool_create("lvm2 vg_handle", VG_MEMPOOL_CHUNK)) &&
+		if (!(vgmem = dm_pool_create("lvm2 vg_handle", VG_MEMPOOL_CHUNK)) ||
 		    !(vg = dm_pool_zalloc(vgmem, sizeof(*vg)))) {
 			log_error("Error allocating vg handle.");
 			if (vgmem)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-04-10 10:01 mbroz
  0 siblings, 0 replies; 73+ messages in thread
From: mbroz @ 2009-04-10 10:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-10 10:01:08

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Properly release VG memory pool in metadata manipulation code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.210&r2=1.211

--- LVM2/lib/metadata/metadata.c	2009/04/10 09:59:19	1.210
+++ LVM2/lib/metadata/metadata.c	2009/04/10 10:01:08	1.211
@@ -111,7 +111,7 @@
 {
 	struct pv_list *pvl;
 	struct format_instance *fid = vg->fid;
-	struct dm_pool *mem = fid->fmt->cmd->mem;
+	struct dm_pool *mem = vg->vgmem;
 
 	log_verbose("Adding physical volume '%s' to volume group '%s'",
 		    pv_name, vg->name);
@@ -241,7 +241,7 @@
 {
 	struct volume_group *vg;
 	struct pv_list *pvl;
-	int consistent = 0;
+	int r = 0, consistent = 0;
 
 	if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
 		log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s",
@@ -257,13 +257,16 @@
 		if (id_equal(&pvl->pv->id, (const struct id *) pvid)) {
 			if (!_copy_pv(fmt->cmd->mem, pv, pvl->pv)) {
 				log_error("internal PV duplication failed");
-				return_0;
+				r = 0;
+				goto out;
 			}
-			return 1;
+			r = 1;
+			goto out;
 		}
 	}
-
-	return 0;
+out:
+	vg_release(vg);
+	return r;
 }
 
 static int validate_new_vg_name(struct cmd_context *cmd, const char *vg_name)
@@ -316,7 +319,7 @@
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name)
 {
-	struct dm_pool *mem = cmd->mem;
+	struct dm_pool *mem = vg->vgmem;
 	struct pv_list *pvl;
 
 	if (!(vg->name = dm_pool_strdup(mem, new_name))) {
@@ -1823,18 +1826,25 @@
 		    (!use_precommitted &&
 		     !(vg = mda->ops->vg_read(fid, vgname, mda)))) {
 			inconsistent = 1;
+			vg_release(vg);
 			continue;
 		}
 		if (!correct_vg) {
 			correct_vg = vg;
 			continue;
 		}
+
 		/* FIXME Also ensure contents same - checksum compare? */
 		if (correct_vg->seqno != vg->seqno) {
 			inconsistent = 1;
-			if (vg->seqno > correct_vg->seqno)
+			if (vg->seqno > correct_vg->seqno) {
+				vg_release(correct_vg);
 				correct_vg = vg;
+			}
 		}
+
+		if (vg != correct_vg)
+			vg_release(vg);
 	}
 
 	/* Ensure every PV in the VG was in the cache */
@@ -1884,14 +1894,17 @@
 
 			if (memlock())
 				inconsistent = 1;
-			else
+			else {
+				vg_release(correct_vg);
 				correct_vg = NULL;
+			}
 		} else dm_list_iterate_items(pvl, &correct_vg->pvs) {
 			if (pvl->pv->status & MISSING_PV)
 				continue;
 			if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
 				log_debug("Cached VG %s had incorrect PV list",
 					  vgname);
+				vg_release(correct_vg);
 				correct_vg = NULL;
 				break;
 			}
@@ -1931,8 +1944,10 @@
 			}
 			if (!correct_vg) {
 				correct_vg = vg;
-				if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg))
+				if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg)) {
+					vg_release(vg);
 					return_NULL;
+				}
 				continue;
 			}
 
@@ -1945,11 +1960,19 @@
 			/* FIXME Also ensure contents same - checksums same? */
 			if (correct_vg->seqno != vg->seqno) {
 				inconsistent = 1;
-				if (!_update_pv_list(cmd->mem, &all_pvs, vg))
+				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
+					vg_release(vg);
+					vg_release(correct_vg);
 					return_NULL;
-				if (vg->seqno > correct_vg->seqno)
+				}
+				if (vg->seqno > correct_vg->seqno) {
+					vg_release(correct_vg);
 					correct_vg = vg;
+				}
 			}
+
+			if (vg != correct_vg)
+				vg_release(vg);
 		}
 
 		/* Give up looking */
@@ -1964,6 +1987,7 @@
 		if (use_precommitted) {
 			log_error("Inconsistent pre-commit metadata copies "
 				  "for volume group %s", vgname);
+			vg_release(correct_vg);
 			return NULL;
 		}
 
@@ -1983,12 +2007,14 @@
 
 		if (!vg_write(correct_vg)) {
 			log_error("Automatic metadata correction failed");
+			vg_release(correct_vg);
 			return NULL;
 		}
 
 		if (!vg_commit(correct_vg)) {
 			log_error("Automatic metadata correction commit "
 				  "failed");
+			vg_release(correct_vg);
 			return NULL;
 		}
 
@@ -1997,12 +2023,16 @@
 				if (pvl->pv->dev == pvl2->pv->dev)
 					goto next_pv;
 			}
-			if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid)))
+			if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
+				vg_release(correct_vg);
 				return_NULL;
+			}
 			log_error("Removing PV %s (%s) that no longer belongs to VG %s",
 				  pv_dev_name(pvl->pv), uuid, correct_vg->name);
-			if (!pv_write_orphan(cmd, pvl->pv))
+			if (!pv_write_orphan(cmd, pvl->pv)) {
+				vg_release(correct_vg);
 				return_NULL;
+			}
       next_pv:
 			;
 		}
@@ -2019,6 +2049,7 @@
 			  "volume group %s", correct_vg->name);
 		log_error("Please restore the metadata by running "
 			  "vgcfgrestore.");
+		vg_release(correct_vg);
 		return NULL;
 	}
 
@@ -2038,6 +2069,7 @@
 	if (!check_pv_segments(vg)) {
 		log_error("Internal error: PV segments corrupted in %s.",
 			  vg->name);
+		vg_release(vg);
 		return NULL;
 	}
 
@@ -2045,6 +2077,7 @@
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error("Internal error: LV segments corrupted in %s.",
 				  lvl->lv->name);
+			vg_release(vg);
 			return NULL;
 		}
 	}
@@ -2074,7 +2107,7 @@
 {
 	const char *vgname;
 	struct dm_list *vgnames;
-	struct volume_group *vg;
+	struct volume_group *vg = NULL;
 	struct lvmcache_vginfo *vginfo;
 	struct str_list *strl;
 	int consistent = 0;
@@ -2092,11 +2125,12 @@
 			}
 			return vg;
 		}
+		vg_release(vg);
 	}
 
 	/* Mustn't scan if memory locked: ensure cache gets pre-populated! */
 	if (memlock())
-		return NULL;
+		goto out;
 
 	/* FIXME Need a genuine read by ID here - don't vg_read_internal by name! */
 	/* FIXME Disabled vgrenames while active for now because we aren't
@@ -2105,7 +2139,7 @@
 	// The slow way - full scan required to cope with vgrename
 	if (!(vgnames = get_vgnames(cmd, 2))) {
 		log_error("vg_read_by_vgid: get_vgnames failed");
-		return NULL;
+		goto out;
 	}
 
 	dm_list_iterate_items(strl, vgnames) {
@@ -2120,12 +2154,14 @@
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vgname);
-				return NULL;
+				goto out;
 			}
 			return vg;
 		}
 	}
 
+out:
+	vg_release(vg);
 	return NULL;
 }
 
@@ -2148,14 +2184,17 @@
 	log_verbose("Found volume group \"%s\"", vg->name);
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg->name);
-		return NULL;
+		goto out;
 	}
 	if (!(lvl = find_lv_in_vg_by_lvid(vg, lvid))) {
 		log_very_verbose("Can't find logical volume id %s", lvid_s);
-		return NULL;
+		goto out;
 	}
 
 	return lvl->lv;
+out:
+	vg_release(vg);
+	return NULL;
 }
 
 /**
@@ -2296,10 +2335,12 @@
 			dm_list_iterate_items(pvl, &vg->pvs) {
 				if (!(pvl_copy = _copy_pvl(cmd->mem, pvl))) {
 					log_error("PV list allocation failed");
+					vg_release(vg);
 					return 0;
 				}
 				dm_list_add(results, &pvl_copy->list);
 			}
+		vg_release(vg);
 	}
 	init_pvmove(old_pvmove);
 
@@ -2529,12 +2570,12 @@
 	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)) ||
 	    ((misc_flags & FAIL_INCONSISTENT) && !consistent)) {
 		log_error("Volume group \"%s\" not found", vg_name);
-		unlock_vg(cmd, vg_name);
+		unlock_release_vg(cmd, vg, vg_name);
 		return NULL;
 	}
 
 	if (!vg_check_status(vg, status_flags)) {
-		unlock_vg(cmd, vg_name);
+		unlock_release_vg(cmd, vg, vg_name);
 		return NULL;
 	}
 
@@ -2549,9 +2590,17 @@
 			     struct volume_group *vg,
 			     uint32_t failure)
 {
-	if (!vg && !(vg = dm_pool_zalloc(cmd->mem, sizeof(*vg)))) {
-		log_error("Error allocating vg handle.");
-		return_NULL;
+	struct dm_pool *vgmem;
+
+	if (!vg) {
+		if (!(vgmem = dm_pool_create("lvm2 vg_handle", VG_MEMPOOL_CHUNK)) &&
+		    !(vg = dm_pool_zalloc(vgmem, sizeof(*vg)))) {
+			log_error("Error allocating vg handle.");
+			if (vgmem)
+				dm_pool_destroy(vgmem);
+			return_NULL;
+		}
+		vg->vgmem = vgmem;
 	}
 
 	vg->read_status = failure;
@@ -2579,8 +2628,10 @@
 	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
 		return_NULL;
 
-	if (!consistent)
+	if (!consistent) {
+		vg_release(vg);
 		return_NULL;
+	}
 
 	return (vg_t *)vg;
 }
@@ -2600,7 +2651,7 @@
 			       const char *vgid, uint32_t lock_flags,
 			       uint32_t status_flags, uint32_t misc_flags)
 {
-	struct volume_group *vg = 0;
+	struct volume_group *vg = NULL;
 	const char *lock_name;
  	int consistent = 1;
 	int consistent_in;
@@ -2656,13 +2707,15 @@
 	}
 
 	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
-	if (!consistent && !failure)
+	if (!consistent && !failure) {
+		vg_release(vg);
 		if (!(vg = _recover_vg(cmd, lock_name, vg_name, vgid, lock_flags))) {
 			log_error("Recovery of volume group \"%s\" failed.",
 				  vg_name);
 			failure |= FAILED_INCONSISTENT;
 			goto_bad;
 		}
+	}
 	
 
 	failure |= _vg_bad_status_bits(vg, status_flags & ~CLUSTERED);


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-04-02 15:01 mbroz
  0 siblings, 0 replies; 73+ messages in thread
From: mbroz @ 2009-04-02 15:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-02 15:01:12

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Allocate new pv->vg_name from pool, it can be destroyed later.
	
	(The mempool rename will be used later by vg private mempools)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.207&r2=1.208

--- LVM2/lib/metadata/metadata.c	2009/03/16 14:34:58	1.207
+++ LVM2/lib/metadata/metadata.c	2009/04/02 15:01:11	1.208
@@ -201,15 +201,17 @@
 static int _copy_pv(struct physical_volume *pv_to,
 		    struct physical_volume *pv_from)
 {
+	struct dm_pool *pvmem = pv_from->fmt->cmd->mem;
+
 	memcpy(pv_to, pv_from, sizeof(*pv_to));
 
-	if (!str_list_dup(pv_to->fmt->cmd->mem, &pv_to->tags, &pv_from->tags)) {
-		log_error("PV tags duplication failed");
-		return 0;
-	}
+	if (!(pv_to->vg_name = dm_pool_strdup(pvmem, pv_from->vg_name)))
+		return_0;
 
-	if (!peg_dup(pv_to->fmt->cmd->mem, &pv_to->segments,
-		     &pv_from->segments))
+	if (!str_list_dup(pvmem, &pv_to->tags, &pv_from->tags))
+		return_0;
+
+	if (!peg_dup(pvmem, &pv_to->segments, &pv_from->segments))
 		return_0;
 
 	return 1;
@@ -235,8 +237,10 @@
 
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		if (id_equal(&pvl->pv->id, (const struct id *) pvid)) {
-			if (!_copy_pv(pv, pvl->pv))
+			if (!_copy_pv(pv, pvl->pv)) {
+				log_error("internal PV duplication failed");
 				return_0;
+			}
 			return 1;
 		}
 	}


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-02-23 16:53 mbroz
  0 siblings, 0 replies; 73+ messages in thread
From: mbroz @ 2009-02-23 16:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-02-23 16:53:42

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Fix validation of dataalignment value introduced in previous commit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.204&r2=1.205

--- LVM2/lib/metadata/metadata.c	2009/02/22 19:00:27	1.204
+++ LVM2/lib/metadata/metadata.c	2009/02/23 16:53:42	1.205
@@ -868,6 +868,12 @@
 		goto bad;
 	}
 
+	if (pv->size < data_alignment) {
+		log_error("%s: Data alignment must not exceed device size.",
+			  pv_dev_name(pv));
+		goto bad;
+	}
+
 	pv->fmt = fmt;
 	pv->vg_name = fmt->orphan_vg_name;
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2009-01-26 22:22 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2009-01-26 22:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-01-26 22:22:08

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Properly enforce cluster locking in as-yet-unused _vg_lock_and_read. (mornfall)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.198&r2=1.199

--- LVM2/lib/metadata/metadata.c	2009/01/26 22:13:22	1.198
+++ LVM2/lib/metadata/metadata.c	2009/01/26 22:22:07	1.199
@@ -2600,6 +2600,12 @@
 		goto_bad;
 	}
 
+	if (vg_is_clustered(vg) && !locking_is_clustered()) {
+		log_error("Skipping clustered volume group %s", vg->name);
+		failure |= FAILED_CLUSTERED;
+		goto_bad;
+	}
+
 	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
 	if (!consistent && !failure)
 		if (!(vg = _recover_vg(cmd, lock_name, vg_name, vgid, lock_flags))) {
@@ -2610,7 +2616,7 @@
 		}
 	
 
-	failure |= _vg_check_status(vg, status_flags);
+	failure |= _vg_check_status(vg, status_flags & ~CLUSTERED);
 	if (failure)
 		goto_bad;
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2008-08-13 13:42 zkabelac
  0 siblings, 0 replies; 73+ messages in thread
From: zkabelac @ 2008-08-13 13:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2008-08-13 13:42:36

Modified files:
	lib/metadata   : metadata.c 

Log message:
	get lv_list properly from vg->lst and fix compiler warning

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.185&r2=1.186

--- LVM2/lib/metadata/metadata.c	2008/08/05 12:05:25	1.185
+++ LVM2/lib/metadata/metadata.c	2008/08/13 13:42:35	1.186
@@ -296,11 +296,14 @@
 			    struct volume_group *vg,
 			    force_t force)
 {
+	struct list *lst;
 	struct lv_list *lvl;
 
-        while ((lvl = list_first(&vg->lvs)))
+	while ((lst = list_first(&vg->lvs))) {
+		lvl = list_item(lst, struct lv_list);
 		if (!lv_remove_with_dependencies(cmd, lvl->lv, force))
-			return 0;
+		    return 0;
+	}
 
 	return 1;
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2008-01-22 16:02 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2008-01-22 16:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-22 16:02:26

Modified files:
	lib/metadata   : metadata.c 

Log message:
	suppress compiler warning

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.153&r2=1.154

--- LVM2/lib/metadata/metadata.c	2008/01/22 02:48:52	1.153
+++ LVM2/lib/metadata/metadata.c	2008/01/22 16:02:26	1.154
@@ -1086,7 +1086,7 @@
 /*
  * Determine whether two vgs are compatible for merging.
  */
-int vgs_are_compatible(struct cmd_context *cmd,
+int vgs_are_compatible(struct cmd_context *cmd __attribute((unused)),
 		       struct volume_group *vg_from,
 		       struct volume_group *vg_to)
 {


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2008-01-16 22:52 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2008-01-16 22:52 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-16 22:52:46

Modified files:
	lib/metadata   : metadata.c 

Log message:
	fix a _get_vgs return

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.150&r2=1.151

--- LVM2/lib/metadata/metadata.c	2008/01/16 19:54:39	1.150
+++ LVM2/lib/metadata/metadata.c	2008/01/16 22:52:46	1.151
@@ -1899,7 +1899,7 @@
 	if (pvslist) {
 		if (!(results = dm_pool_alloc(cmd->mem, sizeof(*results)))) {
 			log_error("PV list allocation failed");
-			return NULL;
+			return 0;
 		}
 
 		list_init(results);


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2007-10-12 21:08 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2007-10-12 21:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-10-12 21:08:38

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove comment about allocation of pv->vg_name.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.139&r2=1.140

--- LVM2/lib/metadata/metadata.c	2007/10/12 18:37:19	1.139
+++ LVM2/lib/metadata/metadata.c	2007/10/12 21:08:38	1.140
@@ -710,12 +710,6 @@
 
 static void _free_pv(struct dm_pool *mem, struct physical_volume *pv)
 {
-	/*
-	 * FIXME: leak pv->vg_name
-	 * Adding dm_pool_free(mem, pv->vg_name) - causes warning w/'const'
-	 * Perhaps pv->vg_name should be initialized to ORPHAN, not alloc'd
-	 * memory?
-	 */
 	dm_pool_free(mem, pv);
 }
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2007-08-06 21:11 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2007-08-06 21:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-08-06 21:11:27

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Update a few comments

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.129&r2=1.130

--- LVM2/lib/metadata/metadata.c	2007/07/23 21:03:42	1.129
+++ LVM2/lib/metadata/metadata.c	2007/08/06 21:11:27	1.130
@@ -1792,13 +1792,8 @@
 	return 1;
 }
 
-/**
- * vg_lock_and_read - Attempt to lock a volume group, read, and check status
- * @cmd - command context
- * @vg_name - name of the volume group to lock and read
- * @lock_flags - locking flags to use
- * @status_flags - status flags to check
- * @misc_flags - function modifier flags
+/*
+ * vg_lock_and_read - consolidate vg locking, reading, and status flag checking
  *
  * Returns:
  * NULL - failure


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2007-07-12  4:12 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2007-07-12  4:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-07-12 04:12:04

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Refactor vg_extend error path.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125

--- LVM2/lib/metadata/metadata.c	2007/07/11 23:33:12	1.124
+++ LVM2/lib/metadata/metadata.c	2007/07/12 04:12:04	1.125
@@ -249,15 +249,17 @@
 
 	/* attach each pv */
 	for (i = 0; i < pv_count; i++)
-		if (!_add_pv_to_vg(vg, pv_names[i])) {
-			log_error("Unable to add physical volume '%s' to "
-				  "volume group '%s'.", pv_names[i], vg->name);
-			return 0;
-		}
+		if (!_add_pv_to_vg(vg, pv_names[i]))
+			goto bad;
 
 /* FIXME Decide whether to initialise and add new mdahs to format instance */
 
 	return 1;
+	
+      bad:
+	log_error("Unable to add physical volume '%s' to "
+		  "volume group '%s'.", pv_names[i], vg->name);
+	return 0;
 }
 
 const char *strip_dir(const char *vg_name, const char *dev_dir)


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2007-06-13 21:14 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2007-06-13 21:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-06-13 21:14:07

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Remove casts in pv_create and find_pv_in_vg_by_uuid

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116

--- LVM2/lib/metadata/metadata.c	2007/06/13 20:55:56	1.115
+++ LVM2/lib/metadata/metadata.c	2007/06/13 21:14:07	1.116
@@ -595,11 +595,11 @@
 		int pvmetadatacopies,
 		uint64_t pvmetadatasize, struct list *mdas)
 {
-	return (pv_t *) _pv_create(fmt, dev, id, size, pe_start, 
-					existing_extent_count,
-					existing_extent_size,
-					pvmetadatacopies,
-					pvmetadatasize, mdas);
+	return _pv_create(fmt, dev, id, size, pe_start, 
+			  existing_extent_count,
+			  existing_extent_size,
+			  pvmetadatacopies,
+			  pvmetadatasize, mdas);
 }
 
 /* Sizes in sectors */
@@ -721,7 +721,7 @@
  */
 pv_t *find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id)
 {
-	return (pv_t *) _find_pv_in_vg_by_uuid(vg, id);
+	return _find_pv_in_vg_by_uuid(vg, id);
 }
 
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2007-06-12 21:39 wysochanski
  0 siblings, 0 replies; 73+ messages in thread
From: wysochanski @ 2007-06-12 21:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-06-12 21:39:49

Modified files:
	lib/metadata   : metadata.c 

Log message:
	Change PV_HANDLE_DEREF to pv_field and add paren's

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112

--- LVM2/lib/metadata/metadata.c	2007/06/12 21:20:20	1.111
+++ LVM2/lib/metadata/metadata.c	2007/06/12 21:39:49	1.112
@@ -29,10 +29,10 @@
 #include <sys/param.h>
 
 /*
- * FIXME: Check for valid handle before dereferencing member or log error?
+ * FIXME: Check for valid handle before dereferencing field or log error?
  */
-#define PV_HANDLE_DEREF(H, M)				\
-	(((struct physical_volume *)H)->M)
+#define pv_field(handle, field)				\
+	(((struct physical_volume *)(handle))->field)
 
 static struct physical_volume *_pv_read(struct cmd_context *cmd, 
 					const char *pv_name,
@@ -1746,55 +1746,55 @@
  */
 struct id get_pv_id (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, id);
+	return pv_field(pv_handle, id);
 }
 
 const struct format_type *get_pv_format_type (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, fmt);
+	return pv_field(pv_handle, fmt);
 }
 
 struct id get_pv_vgid (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, vgid);
+	return pv_field(pv_handle, vgid);
 }
 
 struct device *get_pv_dev (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, dev);
+	return pv_field(pv_handle, dev);
 }
 
 const char *get_pv_vg_name (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, vg_name);
+	return pv_field(pv_handle, vg_name);
 }
 
 uint64_t get_pv_size(void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, size);
+	return pv_field(pv_handle, size);
 }
 
 uint32_t get_pv_status (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, status);
+	return pv_field(pv_handle, status);
 }
 
 uint32_t get_pv_pe_size (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, pe_size);
+	return pv_field(pv_handle, pe_size);
 }
 
 uint64_t get_pv_pe_start (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, pe_start);
+	return pv_field(pv_handle, pe_start);
 }
 
 uint32_t get_pv_pe_count (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, pe_count);
+	return pv_field(pv_handle, pe_count);
 }
 
 uint32_t get_pv_pe_alloc_count (void *pv_handle)
 {
-	return PV_HANDLE_DEREF(pv_handle, pe_alloc_count);
+	return pv_field(pv_handle, pe_alloc_count);
 }


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2006-10-07 23:06 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2006-10-07 23:06 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-10-07 23:06:18

Modified files:
	lib/metadata   : metadata.c 

Log message:
	rely on pv_setup functions to fix up pv->size

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100

--- LVM2/lib/metadata/metadata.c	2006/10/05 22:02:52	1.99
+++ LVM2/lib/metadata/metadata.c	2006/10/07 23:06:18	1.100
@@ -89,11 +89,8 @@
 		pv->pe_start = pe_align();
 
 	/*
-	 * The next two fields should be corrected
-	 * by fid->pv_setup.
+	 * pe_count must always be calculated by pv_setup
 	 */
-	pv->pe_count = (pv->size - pv->pe_start) / vg->extent_size;
-
 	pv->pe_alloc_count = 0;
 
 	if (!fid->fmt->ops->pv_setup(fid->fmt, UINT64_C(0), 0,


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2005-04-19 20:44 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2005-04-19 20:44 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-04-19 20:44:21

Modified files:
	lib/metadata   : metadata.c 

Log message:
	_copy_pv -> int

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2005-04-17 23:59 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2005-04-17 23:59 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-04-17 23:59:04

Modified files:
	lib/metadata   : metadata.c 

Log message:
	extract compose_log_line

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71


^ permalink raw reply	[flat|nested] 73+ messages in thread

* LVM2/lib/metadata metadata.c
@ 2004-03-26 21:07 agk
  0 siblings, 0 replies; 73+ messages in thread
From: agk @ 2004-03-26 21:07 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2004-03-26 21:07:33

Modified files:
	lib/metadata   : metadata.c 

Log message:
	indent

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59


^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2012-03-12 14:43 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-10 17:15 LVM2/lib/metadata metadata.c wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2012-03-12 14:43 zkabelac
2012-03-01  9:46 zkabelac
2012-02-29  0:19 mornfall
2012-02-29  0:18 mornfall
2012-02-28 11:10 zkabelac
2012-02-27  9:54 zkabelac
2012-02-12 20:19 agk
2012-01-25  8:50 zkabelac
2011-04-01 14:54 prajnoha
2011-03-30 13:35 zkabelac
2011-03-10 22:39 zkabelac
2011-02-21 12:13 prajnoha
2011-02-14 19:27 mornfall
2010-12-14 17:07 mornfall
2010-11-30 11:15 mornfall
2010-10-25 13:35 zkabelac
2010-07-30 16:47 wysochanski
2010-07-09 16:57 wysochanski
2010-07-08 17:41 wysochanski
2010-07-06 20:09 agk
2010-07-06 17:29 agk
2010-07-06 17:27 agk
2010-07-06 17:26 agk
2010-06-30 19:55 wysochanski
2010-06-30 14:54 agk
2010-06-30 14:52 agk
2010-06-30 14:48 wysochanski
2010-06-30 14:27 agk
2010-06-28 20:38 wysochanski
2010-06-28 20:38 wysochanski
2010-06-28 20:37 wysochanski
2010-06-28 20:35 wysochanski
2010-06-28 20:35 wysochanski
2010-04-08 15:18 wysochanski
2010-04-06 14:03 wysochanski
2010-04-01 13:08 agk
2010-04-01 11:45 agk
2010-02-24 18:15 wysochanski
2010-01-21 21:04 wysochanski
2010-01-21 21:04 wysochanski
2010-01-07 14:29 zkabelac
2009-12-16 19:26 mornfall
2009-11-19 13:44 mornfall
2009-10-05 20:02 wysochanski
2009-10-05 20:02 wysochanski
2009-09-02 21:39 wysochanski
2009-07-28 20:41 agk
2009-07-26 12:41 wysochanski
2009-07-26  1:53 wysochanski
2009-07-26  1:52 wysochanski
2009-07-24 15:15 wysochanski
2009-07-16 20:18 wysochanski
2009-07-01 17:03 wysochanski
2009-06-10 16:14 wysochanski
2009-05-13  1:48 agk
2009-04-28 17:46 wysochanski
2009-04-10 10:01 mbroz
2009-04-02 15:01 mbroz
2009-02-23 16:53 mbroz
2009-01-26 22:22 agk
2008-08-13 13:42 zkabelac
2008-01-22 16:02 agk
2008-01-16 22:52 agk
2007-10-12 21:08 wysochanski
2007-08-06 21:11 wysochanski
2007-07-12  4:12 wysochanski
2007-06-13 21:14 wysochanski
2007-06-12 21:39 wysochanski
2006-10-07 23:06 agk
2005-04-19 20:44 agk
2005-04-17 23:59 agk
2004-03-26 21:07 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).