public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2011-03-11 15:06 prajnoha
  0 siblings, 0 replies; 42+ messages in thread
From: prajnoha @ 2011-03-11 15:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-03-11 15:06:13

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Call destroy_instance for any PVs found in VG structure during vg_free call.
	
	This is necessary for proper format instance ref_count support. We iterate
	over vg->pvs and vg->removed_pvs list and the ref_count is decremented and
	then it is destroyed if not referenced anymore.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1949&r2=1.1950
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.445&r2=1.446

--- LVM2/WHATS_NEW	2011/03/11 14:56:56	1.1949
+++ LVM2/WHATS_NEW	2011/03/11 15:06:13	1.1950
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Call destroy_instance for any PVs found in VG structure during vg_free call.
   Add new free_pv_fid fn and use it throughout to free all attached fids.
   Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
   Make create_text_context fn static and move it inside create_instance fn.
--- LVM2/lib/metadata/metadata.c	2011/03/11 14:56:56	1.445
+++ LVM2/lib/metadata/metadata.c	2011/03/11 15:06:13	1.446
@@ -3243,9 +3243,20 @@
 
 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);
+
 	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] 42+ messages in thread

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

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Switch to normal log_verbose message
	
	Here it's not an error case - so do not push this message to stderr.

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

--- LVM2/WHATS_NEW	2012/03/12 14:15:04	1.2350
+++ LVM2/WHATS_NEW	2012/03/12 14:18:28	1.2351
@@ -1,5 +1,6 @@
 Version 2.02.96 - 
 ================================
+  Change message severity for creation of VG over uninitialised devices.
   Fix error path for failing toolcontext creation.
   Fix warn msg for thin pool chunk size and update man for chunksize (2.02.89).
 
--- LVM2/lib/metadata/metadata.c	2012/03/02 20:46:37	1.497
+++ LVM2/lib/metadata/metadata.c	2012/03/12 14:18:29	1.498
@@ -1468,8 +1468,8 @@
 			stack;
 	}
 
-	log_error("Writing physical volume data to disk \"%s\"",
-			 pv_name);
+	log_verbose("Writing physical volume data to disk \"%s\"",
+		    pv_name);
 
 	if (!(pv_write(cmd, pv, 1))) {
 		log_error("Failed to write physical volume \"%s\"", pv_name);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2012-02-23 00:11:01

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Check all tags and LV names are in a valid form in vg_validate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2300&r2=1.2301
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.484&r2=1.485

--- LVM2/WHATS_NEW	2012/02/22 17:55:10	1.2300
+++ LVM2/WHATS_NEW	2012/02/23 00:11:01	1.2301
@@ -1,5 +1,6 @@
 Version 2.02.93 - 
 ====================================
+  Check all tags and LV names are in a valid form in vg_validate.
   Add tmpfiles.d style configuration for lvm2 lock and run directory.
   Add configure --with-tmpfilesdir for dir holding volatile-file configuration.
   Allow 'lvconvert --repair' to operate on RAID 4/5/6
--- LVM2/lib/metadata/metadata.c	2012/02/13 11:04:00	1.484
+++ LVM2/lib/metadata/metadata.c	2012/02/23 00:11:01	1.485
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -2294,6 +2294,7 @@
 	struct pv_list *pvl;
 	struct lv_list *lvl;
 	struct lv_segment *seg;
+	struct str_list *sl;
 	char uuid[64] __attribute__((aligned(8)));
 	int r = 1;
 	uint32_t hidden_lv_count = 0, lv_count = 0, lv_visible_count = 0;
@@ -2313,6 +2314,13 @@
 		return 0;
 	}
 
+	dm_list_iterate_items(sl, &vg->tags)
+		if (!validate_tag(sl->str)) {
+			log_error(INTERNAL_ERROR "VG %s tag %s has invalid form.",
+				  vg->name, sl->str);
+			r = 0;
+		}
+
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		if (++pv_count > vg->pv_count) {
 			log_error(INTERNAL_ERROR "PV list corruption detected in VG %s.", vg->name);
@@ -2345,6 +2353,13 @@
 			r = 0;
 		}
 
+		dm_list_iterate_items(sl, &pvl->pv->tags)
+			if (!validate_tag(sl->str)) {
+				log_error(INTERNAL_ERROR "PV %s tag %s has invalid form.",
+					  pv_dev_name(pvl->pv), sl->str);
+				r = 0;
+			}
+
 		if (!dm_hash_insert_binary(vhash.pvid, &pvl->pv->id,
 					   sizeof(pvl->pv->id), pvl->pv)) {
 			log_error("Failed to hash pvid.");
@@ -2384,6 +2399,18 @@
 			r = 0;
 		}
 
+		if (!validate_name(lvl->lv->name)) {
+			log_error(INTERNAL_ERROR "LV name %s has invalid form.", lvl->lv->name);
+			r = 0;
+		}
+
+		dm_list_iterate_items(sl, &lvl->lv->tags)
+			if (!validate_tag(sl->str)) {
+				log_error(INTERNAL_ERROR "LV %s tag %s has invalid form.",
+					  lvl->lv->name, sl->str);
+				r = 0;
+			}
+
 		if (lvl->lv->status & VISIBLE_LV)
 			continue;
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-13 11:01:35

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	If the same fid is already same avoid ref_counting

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2284&r2=1.2285
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.482&r2=1.483

--- LVM2/WHATS_NEW	2012/02/13 10:58:20	1.2284
+++ LVM2/WHATS_NEW	2012/02/13 11:01:34	1.2285
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Skip pv/vg_set_fid processing if the fid is same.
   Check for foreach loop errors in _vg_read_orphans() (2.02.91).
   Clean error paths for format instance creation (2.02.91).
   Release vg in error path of _format1_vg_read() instead of just free().
--- LVM2/lib/metadata/metadata.c	2012/02/13 10:58:21	1.482
+++ LVM2/lib/metadata/metadata.c	2012/02/13 11:01:35	1.483
@@ -4149,6 +4149,9 @@
 void pv_set_fid(struct physical_volume *pv,
 		struct format_instance *fid)
 {
+	if (fid == pv->fid)
+		return;
+
 	if (fid)
 		fid->ref_count++;
 
@@ -4163,6 +4166,9 @@
 {
 	struct pv_list *pvl;
 
+	if (fid == vg->fid)
+		return;
+
 	if (fid)
 		fid->ref_count++;
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-13 10:58:21

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Add missing test for failure of lvmcache_foreach_pv

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2283&r2=1.2284
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.481&r2=1.482

--- LVM2/WHATS_NEW	2012/02/13 10:56:31	1.2283
+++ LVM2/WHATS_NEW	2012/02/13 10:58:20	1.2284
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Check for foreach loop errors in _vg_read_orphans() (2.02.91).
   Clean error paths for format instance creation (2.02.91).
   Release vg in error path of _format1_vg_read() instead of just free().
   Report allocation failure for allocation of PV structure.
--- LVM2/lib/metadata/metadata.c	2012/02/13 10:51:53	1.481
+++ LVM2/lib/metadata/metadata.c	2012/02/13 10:58:21	1.482
@@ -2754,7 +2754,9 @@
 
 	baton.warnings = warnings;
 	baton.vg = vg;
-	lvmcache_foreach_pv(vginfo, _vg_read_orphan_pv, &baton);
+
+	if (!lvmcache_foreach_pv(vginfo, _vg_read_orphan_pv, &baton))
+                return_NULL;
 
 	return vg;
 }


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-13 10:51:53

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Log error reporting for failing _alloc_pv
	
	Drop unneeded zeroing of zalloced memory region.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2280&r2=1.2281
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.480&r2=1.481

--- LVM2/WHATS_NEW	2012/02/13 05:24:57	1.2280
+++ LVM2/WHATS_NEW	2012/02/13 10:51:52	1.2281
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Report allocation failure for allocation of PV structure.
   Add clvmd init dependency on dlm service when running with new corosync.
 
 Version 2.02.91 - 12th February 2012
--- LVM2/lib/metadata/metadata.c	2012/02/12 23:01:19	1.480
+++ LVM2/lib/metadata/metadata.c	2012/02/13 10:51:53	1.481
@@ -1557,21 +1557,14 @@
 
 static struct physical_volume *_alloc_pv(struct dm_pool *mem, struct device *dev)
 {
-	struct physical_volume *pv = dm_pool_zalloc(mem, sizeof(*pv));
+	struct physical_volume *pv;
 
-	if (!pv)
-		return_NULL;
+	if (!(pv = dm_pool_zalloc(mem, sizeof(*pv)))) {
+		log_error("Failed to allocate pv structure.");
+		return NULL;
+	}
 
-	pv_set_fid(pv, NULL);
-	pv->pe_size = 0;
-	pv->pe_start = 0;
-	pv->pe_count = 0;
-	pv->pe_alloc_count = 0;
-	pv->pe_align = 0;
-	pv->pe_align_offset = 0;
-	pv->fmt = NULL;
 	pv->dev = dev;
-
 	pv->status = ALLOCATABLE_PV;
 
 	dm_list_init(&pv->tags);
@@ -1621,7 +1614,7 @@
 	unsigned mda_index;
 
 	if (!pv)
-		return NULL;
+		return_NULL;
 
 	if (id)
 		memcpy(&pv->id, id, sizeof(*id));


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2011-11-18 19:28 zkabelac
  0 siblings, 0 replies; 42+ messages in thread
From: zkabelac @ 2011-11-18 19:28 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-18 19:28:01

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Unlock memory for vg_write
	
	For write we do not need to hold memory locked.
	This relaxes many conditions and avoid problems when allocating
	a lot of memory for writting metadata buffers.
	(In case of huge MDA size this would lead to mismatch between
	locked and unlocked memory region size).
	
	Add also internal check we are not writing in critical section.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2189&r2=1.2190
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.472&r2=1.473

--- LVM2/WHATS_NEW	2011/11/18 19:25:20	1.2189
+++ LVM2/WHATS_NEW	2011/11/18 19:28:00	1.2190
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Unlock memory before writing metadata.
   Add query before removing snapshots when inactive snapshot origin is removed.
   Allow changing availability state of snapshots.
   Skip non-virtual snapshots for availability change for lvchange with vg name.
--- LVM2/lib/metadata/metadata.c	2011/11/04 22:49:53	1.472
+++ LVM2/lib/metadata/metadata.c	2011/11/18 19:28:01	1.473
@@ -2573,6 +2573,12 @@
 		return 0;
 	}
 
+	if (critical_section())
+		log_error(INTERNAL_ERROR
+			  "Writing metadata in critical section.");
+
+	/* Unlock memory if possible */
+	memlock_unlock(vg->cmd);
 	vg->seqno++;
 
         dm_list_iterate_items(pv_to_create, &vg->pvs_to_create) {


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-24 10:24:40

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Don't print char type[8] as a plain string
	
	pvck prints 'extra' character from the label since there is no '\0'
	after the struct label entry and just uint64_t follows directly.
	So avoid it by limiting 8 chars to be printed.
	
	https://www.redhat.com/archives/lvm-devel/2011-January/msg00109.html
	
	Signed-off-by: Paul Bolle <pebolle tiscali nl>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2170&r2=1.2171
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.469&r2=1.470

--- LVM2/WHATS_NEW	2011/10/23 16:05:45	1.2170
+++ LVM2/WHATS_NEW	2011/10/24 10:24:39	1.2171
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Don't print char type[8] as a plain string in pvck PV type.
   Use vg memory pool implicitely for vg read.
   Always use vg memory pool for allocated lv segment.
   Remove extra 4kB buffer allocated on stack in print_log().
--- LVM2/lib/metadata/metadata.c	2011/10/11 09:09:00	1.469
+++ LVM2/lib/metadata/metadata.c	2011/10/24 10:24:40	1.470
@@ -3794,7 +3794,7 @@
 		return 0;
 	}
 
-	log_print("Found label on %s, sector %"PRIu64", type=%s",
+	log_print("Found label on %s, sector %"PRIu64", type=%.8s",
 		  pv_name, label->sector, label->type);
 
 	/*


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2011-08-11 16:31 prajnoha
  0 siblings, 0 replies; 42+ messages in thread
From: prajnoha @ 2011-08-11 16:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-08-11 16:31:41

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix possible format instance memory leaks and premature releases in _vg_read.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2063&r2=1.2064
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.462&r2=1.463

--- LVM2/WHATS_NEW	2011/08/11 15:27:46	1.2063
+++ LVM2/WHATS_NEW	2011/08/11 16:31:40	1.2064
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  Fix possible format instance memory leaks and premature releases in _vg_read.
   Suppress locking error messages in monitoring init scripts.
   If pipe in clvmd fails, return busy instead of using uninitialised descriptors.
   Add dmeventd monitoring shared library for RAID.
--- LVM2/lib/metadata/metadata.c	2011/08/10 20:25:30	1.462
+++ LVM2/lib/metadata/metadata.c	2011/08/11 16:31:40	1.463
@@ -2768,6 +2768,14 @@
 		pvl->pv->fid->fmt->ops->destroy_instance(pvl->pv->fid);
 }
 
+static void _destroy_fid(struct format_instance **fid)
+{
+	if (*fid) {
+		(*fid)->fmt->ops->destroy_instance(*fid);
+		*fid = NULL;
+	}
+}
+
 int vg_missing_pv_count(const struct volume_group *vg)
 {
 	int ret = 0;
@@ -2826,7 +2834,7 @@
 				     int warnings, 
 				     int *consistent, unsigned precommitted)
 {
-	struct format_instance *fid;
+	struct format_instance *fid = NULL;
 	struct format_instance_ctx fic;
 	const struct format_type *fmt;
 	struct volume_group *vg, *correct_vg = NULL;
@@ -2900,12 +2908,20 @@
 	}
 
 	/* Store pvids for later so we can check if any are missing */
-	if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
+	if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid))) {
+		_destroy_fid(&fid);
 		return_NULL;
+	}
 
+	/*
+	 * We use the fid globally here so prevent the release_vg
+	 * call to destroy the fid - we may want to reuse it!
+	 */
+	fid->ref_count++;
 	/* Ensure contents of all metadata areas match - else do recovery */
 	inconsistent_mda_count=0;
 	dm_list_iterate_items(mda, &fid->metadata_areas_in_use) {
+
 		if ((use_precommitted &&
 		     !(vg = mda->ops->vg_read_precommit(fid, vgname, mda))) ||
 		    (!use_precommitted &&
@@ -2941,6 +2957,7 @@
 		if (vg != correct_vg)
 			release_vg(vg);
 	}
+	fid->ref_count--;
 
 	/* Ensure every PV in the VG was in the cache */
 	if (correct_vg) {
@@ -2972,8 +2989,10 @@
 				}
 				if (dm_list_size(&info->mdas)) {
 					if (!fid_add_mdas(fid, &info->mdas,
-							  info->dev->pvid, ID_LEN))
+							  info->dev->pvid, ID_LEN)) {
+						release_vg(correct_vg);
 						return_NULL;
+					}
 					 
 					log_debug("Empty mda found for VG %s.", vgname);
 
@@ -3002,11 +3021,14 @@
 				 */
 				lvmcache_update_vg(correct_vg, correct_vg->status & PRECOMMITTED);
 
-				if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
+				if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid))) {
+					release_vg(correct_vg);
 					return_NULL;
+				}
 			}
 		}
 
+		fid->ref_count++;
 		if (dm_list_size(&correct_vg->pvs) !=
 		    dm_list_size(pvids) + vg_missing_pv_count(correct_vg)) {
 			log_debug("Cached VG %s had incorrect PV list",
@@ -3034,12 +3056,20 @@
 			release_vg(correct_vg);
 			correct_vg = NULL;
 		}
+		fid->ref_count--;
 	}
 
 	dm_list_init(&all_pvs);
 
 	/* Failed to find VG where we expected it - full scan and retry */
 	if (!correct_vg) {
+		/*
+		 * Free outstanding format instance that remained unassigned
+		 * from previous step where we tried to get the "correct_vg",
+		 * but we failed to do so (so there's a dangling fid now).
+		 */
+		_destroy_fid(&fid);
+
 		inconsistent = 0;
 
 		/* Independent MDAs aren't supported under low memory */
@@ -3061,6 +3091,11 @@
 			return NULL;
 		}
 
+		/*
+		 * We use the fid globally here so prevent the release_vg
+		 * call to destroy the fid - we may want to reuse it!
+		*/
+		fid->ref_count++;
 		/* Ensure contents of all metadata areas match - else recover */
 		inconsistent_mda_count=0;
 		dm_list_iterate_items(mda, &fid->metadata_areas_in_use) {
@@ -3076,6 +3111,7 @@
 				correct_vg = vg;
 				if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg)) {
 					_free_pv_list(&all_pvs);
+					fid->ref_count--;
 					release_vg(vg);
 					return_NULL;
 				}
@@ -3099,6 +3135,7 @@
 
 				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
 					_free_pv_list(&all_pvs);
+					fid->ref_count--;
 					release_vg(vg);
 					release_vg(correct_vg);
 					return_NULL;
@@ -3115,10 +3152,12 @@
 			if (vg != correct_vg)
 				release_vg(vg);
 		}
+		fid->ref_count--;
 
 		/* Give up looking */
 		if (!correct_vg) {
 			_free_pv_list(&all_pvs);
+			_destroy_fid(&fid);
 			return_NULL;
 		}
 	}


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-08-04 15:18:11

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Remove unused inconsistent_seqno
	
	Last usage was removed in Petr's commit related to VG mda repair fix
	where relaxed check starts to ignore inconsistencies coming from
	PVs that are marked MISSING - thus removing unused variable.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2051&r2=1.2052
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.459&r2=1.460

--- LVM2/WHATS_NEW	2011/08/04 14:30:51	1.2051
+++ LVM2/WHATS_NEW	2011/08/04 15:18:10	1.2052
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  Remove unused inconsistent_seqno variable in _vg_read().
   Remove meaningless const type qualifiers on cast type.
   Fix memory leak in dmsetup _message() memory allocation error path.
   Add test for fcntl error in singlenode client code.
--- LVM2/lib/metadata/metadata.c	2011/06/17 14:39:10	1.459
+++ LVM2/lib/metadata/metadata.c	2011/08/04 15:18:11	1.460
@@ -2835,7 +2835,6 @@
 	int inconsistent = 0;
 	int inconsistent_vgid = 0;
 	int inconsistent_pvs = 0;
-	int inconsistent_seqno = 0;
 	int inconsistent_mdas = 0;
 	int inconsistent_mda_count = 0;
 	unsigned use_precommitted = precommitted;
@@ -2931,10 +2930,9 @@
 				log_very_verbose("Not repairing VG %s metadata seqno (%d != %d) "
 						  "as global/metadata_read_only is set.",
 						  vgname, vg->seqno, correct_vg->seqno);
-			else {
+			else
 				inconsistent = 1;
-				inconsistent_seqno = 1;
-			}
+
 			if (vg->seqno > correct_vg->seqno) {
 				free_vg(correct_vg);
 				correct_vg = vg;
@@ -3100,10 +3098,9 @@
 					log_very_verbose("Not repairing VG %s metadata seqno (%d != %d) "
 							  "as global/metadata_read_only is set.",
 							  vgname, vg->seqno, correct_vg->seqno);
-				else {
+				else
 					inconsistent = 1;
-					inconsistent_seqno = 1;
-				}
+
 				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
 					_free_pv_list(&all_pvs);
 					free_vg(vg);


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2011-03-29 21:57 zkabelac
  0 siblings, 0 replies; 42+ messages in thread
From: zkabelac @ 2011-03-29 21:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-29 21:57:56

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Use id_equal instead of strncmp()
	
	More consistent and easier to read.

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

--- LVM2/WHATS_NEW	2011/03/29 21:34:18	1.1961
+++ LVM2/WHATS_NEW	2011/03/29 21:57:56	1.1962
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Replace several strncmp() calls with id_equal().
   Fix lvmcache_info transfer to orphan_vginfo in _lvmcache_update_vgname().
   Fix -Wold-style-definition gcc warnings.
   Fixes for lvconvert (including --repair) of temporary mirror stacks.
--- LVM2/lib/metadata/metadata.c	2011/03/14 17:00:57	1.450
+++ LVM2/lib/metadata/metadata.c	2011/03/29 21:57:56	1.451
@@ -3043,8 +3043,7 @@
 				continue;
 			}
 
-			if (strncmp((char *)vg->id.uuid,
-			    (char *)correct_vg->id.uuid, ID_LEN)) {
+			if (!id_equal(&vg->id, &correct_vg->id)) {
 				inconsistent = 1;
 				inconsistent_vgid = 1;
 			}
@@ -3292,7 +3291,7 @@
 	    vginfo->vgname && !is_orphan_vg(vginfo->vgname)) {
 		if ((vg = _vg_read(cmd, NULL, vgid, 1,
 				   &consistent, precommitted)) &&
-		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
+		    id_equal(&vg->id, (const struct id *)vgid)) {
 			if (!consistent)
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vg->name);
@@ -3323,7 +3322,7 @@
 		consistent = 0;
 		if ((vg = _vg_read(cmd, vgname, vgid, 1, &consistent,
 				   precommitted)) &&
-		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
+		    id_equal(&vg->id, (const struct id *)vgid)) {
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vgname);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-10 13:12:00

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Use hash tables for validating names
	
	Accelerate validation loop by using lvname, lvid, pvid hash tables.
	Also merge pvl loop into one cycle now - no need to scan the list twice.
	List scan is stopped when dm_hash_insert fails.
	
	The error message with loop_counter1 is no longer provided - however
	the message has been misleading anyway.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1941&r2=1.1942
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.438&r2=1.439

--- LVM2/WHATS_NEW	2011/03/10 12:43:30	1.1941
+++ LVM2/WHATS_NEW	2011/03/10 13:11:59	1.1942
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Use hash tables to speedup string search in validate_vg().
   Refactor allocation of VG structure, add alloc_vg().
   Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name.
   Use empty string instead of /dev// for LV path when there's no VG.
--- LVM2/lib/metadata/metadata.c	2011/03/10 12:43:30	1.438
+++ LVM2/lib/metadata/metadata.c	2011/03/10 13:12:00	1.439
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -2192,15 +2192,17 @@
 
 int vg_validate(struct volume_group *vg)
 {
-	struct pv_list *pvl, *pvl2;
-	struct lv_list *lvl, *lvl2;
+	struct pv_list *pvl;
+	struct lv_list *lvl;
 	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;
 	uint32_t pv_count = 0;
 	uint32_t num_snapshots = 0;
-	uint32_t loop_counter1, loop_counter2;
+	struct dm_hash_table *lvname_hash;
+	struct dm_hash_table *lvid_hash;
+	struct dm_hash_table *pvid_hash;
 
 	if (vg->alloc == ALLOC_CLING_BY_TAGS) {
 		log_error(INTERNAL_ERROR "VG %s allocation policy set to invalid cling_by_tags.",
@@ -2209,50 +2211,53 @@
 	}
 
 	/* FIXME Also check there's no data/metadata overlap */
+	if (!(pvid_hash = dm_hash_create(vg->pv_count))) {
+		log_error("Failed to allocate pvid hash.");
+		return 0;
+	}
+
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		if (++pv_count > vg->pv_count) {
 			log_error(INTERNAL_ERROR "PV list corruption detected in VG %s.", vg->name);
 			/* FIXME Dump list structure? */
 			r = 0;
 		}
+
 		if (pvl->pv->vg != vg) {
 			log_error(INTERNAL_ERROR "VG %s PV list entry points "
-				  "to different VG %s", vg->name,
+				  "to different VG %s.", vg->name,
 				  pvl->pv->vg ? pvl->pv->vg->name : "NULL");
 			r = 0;
 		}
-	}
-
-	loop_counter1 = loop_counter2 = 0;
-	/* FIXME Use temp hash table instead? */
-	dm_list_iterate_items(pvl, &vg->pvs) {
-		if (++loop_counter1 > pv_count)
-			break;
-		dm_list_iterate_items(pvl2, &vg->pvs) {
-			if (++loop_counter2 > pv_count)
-				break;
-			if (pvl == pvl2)
-				break;
-			if (id_equal(&pvl->pv->id,
-				     &pvl2->pv->id)) {
-				if (!id_write_format(&pvl->pv->id, uuid,
-						     sizeof(uuid)))
-					 stack;
-				log_error(INTERNAL_ERROR "Duplicate PV id "
-					  "%s detected for %s in %s.",
-					  uuid, pv_dev_name(pvl->pv),
-					  vg->name);
-				r = 0;
-			}
-		}
 
 		if (strcmp(pvl->pv->vg_name, vg->name)) {
 			log_error(INTERNAL_ERROR "VG name for PV %s is corrupted.",
 				  pv_dev_name(pvl->pv));
 			r = 0;
 		}
+
+		if (dm_hash_lookup_binary(pvid_hash, &pvl->pv->id,
+					  sizeof(pvl->pv->id))) {
+			if (!id_write_format(&pvl->pv->id, uuid,
+					     sizeof(uuid)))
+				stack;
+			log_error(INTERNAL_ERROR "Duplicate PV id "
+				  "%s detected for %s in %s.",
+				  uuid, pv_dev_name(pvl->pv),
+				  vg->name);
+			r = 0;
+		}
+
+		if (!dm_hash_insert_binary(pvid_hash, &pvl->pv->id,
+					   sizeof(pvl->pv->id), pvl->pv)) {
+			log_error("Failed to hash pvid.");
+			r = 0;
+			break;
+		}
 	}
 
+	dm_hash_destroy(pvid_hash);
+
 	if (!check_pv_segments(vg)) {
 		log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
 			  vg->name);
@@ -2320,33 +2325,34 @@
 	if (!r)
 		return r;
 
-	loop_counter1 = loop_counter2 = 0;
-	/* FIXME Use temp hash table instead? */
+	if (!(lvname_hash = dm_hash_create(lv_count))) {
+		log_error("Failed to allocate lv_name hash");
+		return 0;
+	}
+
+	if (!(lvid_hash = dm_hash_create(lv_count))) {
+		log_error("Failed to allocate uuid hash");
+		dm_hash_destroy(lvname_hash);
+		return 0;
+	}
+
 	dm_list_iterate_items(lvl, &vg->lvs) {
-		if (++loop_counter1 > lv_count)
-			break;
-		dm_list_iterate_items(lvl2, &vg->lvs) {
-			if (++loop_counter2 > lv_count)
-				break;
-			if (lvl == lvl2)
-				break;
-			if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
-				log_error(INTERNAL_ERROR "Duplicate LV name "
-					  "%s detected in %s.", lvl->lv->name,
-					  vg->name);
-				r = 0;
-			}
-			if (id_equal(&lvl->lv->lvid.id[1],
-				     &lvl2->lv->lvid.id[1])) {
-				if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
-						     sizeof(uuid)))
-					 stack;
-				log_error(INTERNAL_ERROR "Duplicate LV id "
-					  "%s detected for %s and %s in %s.",
-					  uuid, lvl->lv->name, lvl2->lv->name,
-					  vg->name);
-				r = 0;
-			}
+		if (dm_hash_lookup(lvname_hash, 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],
+					  sizeof(lvl->lv->lvid.id[1]))) {
+			if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
+					     sizeof(uuid)))
+				stack;
+			log_error(INTERNAL_ERROR "Duplicate LV id "
+				  "%s detected for %s in %s.",
+				  uuid, lvl->lv->name, vg->name);
+			r = 0;
 		}
 
 		if (!check_lv_segments(lvl->lv, 1)) {
@@ -2354,8 +2360,24 @@
 				  lvl->lv->name);
 			r = 0;
 		}
+
+		if (!dm_hash_insert(lvname_hash, lvl->lv->name, lvl)) {
+			log_error("Failed to hash lvname.");
+			r = 0;
+			break;
+		}
+
+		if (!dm_hash_insert_binary(lvid_hash, lvl->lv->lvid.id,
+					   sizeof(lvl->lv->lvid.id), lvl->lv)) {
+			log_error("Failed to hash lvid.");
+			r = 0;
+			break;
+		}
 	}
 
+	dm_hash_destroy(lvname_hash);
+	dm_hash_destroy(lvid_hash);
+
 	dm_list_iterate_items(lvl, &vg->lvs) {
 		if (!_lv_postorder(lvl->lv, _lv_validate_references_single, NULL))
 			r = 0;
@@ -2368,14 +2390,14 @@
 			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);
+						  "Segment in %s is not 2-way.",
+						  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);
+					  "Segment in %s has wrong number of areas: %d.",
+					  lvl->lv->name, seg->area_count);
 				r = 0;
 			}
 		}


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-08 10:45:37

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Remove reset of vg->vgmem pointer as it is access of already release memory
	
	This reset of vgmem pointer causes access of already released memory.
	(_vg_make_handle allocates vg from vgmem pool itself - which is a bit tricky)
	
	Interestingly this memory fault was missed by our test suite.

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

--- LVM2/WHATS_NEW	2010/12/06 22:13:10	1.1829
+++ LVM2/WHATS_NEW	2010/12/08 10:45:37	1.1830
@@ -1,5 +1,6 @@
 Version 2.02.79 -
 ===================================
+  Fix write to released memory in vg_relase().  (2.02.78)
 
 Version 2.02.78 - 6th December 2010
 ===================================
--- LVM2/lib/metadata/metadata.c	2010/11/30 11:15:54	1.413
+++ LVM2/lib/metadata/metadata.c	2010/12/08 10:45:37	1.414
@@ -3094,7 +3094,6 @@
 			  vg->name);
 
 	dm_pool_destroy(vg->vgmem);
-	vg->vgmem = NULL;
 }
 
 /* This is only called by lv_from_lvid, which is only called from


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-29 11:08:14

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Reset vg pointer after release
	
	Set vg to NULL after releasing it as the following memlock() test may
	lead to goto for the second call of vg_release() with the already
	released vg pointer.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1811&r2=1.1812
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.410&r2=1.411

--- LVM2/WHATS_NEW	2010/11/29 10:58:33	1.1811
+++ LVM2/WHATS_NEW	2010/11/29 11:08:14	1.1812
@@ -1,5 +1,6 @@
 Version 2.02.78 - 
 ====================================
+  Fix missing reset of vg pointer after vg_release() in _vg_read_by_vgid().
   Fix test for empty system_dir string in _init_backup().
   Certain lvconvert invocations are now required to be done in two steps.
   Fix missing context desctruction in err path of lvm1 fallback in lvm2_main().
--- LVM2/lib/metadata/metadata.c	2010/11/23 01:55:59	1.410
+++ LVM2/lib/metadata/metadata.c	2010/11/29 11:08:14	1.411
@@ -3117,6 +3117,7 @@
 			return vg;
 		}
 		vg_release(vg);
+		vg = NULL; /* reset so memlock goto out is safe */
 	}
 
 	/* Mustn't scan if memory locked: ensure cache gets pre-populated! */


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2010-08-19 23:03 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2010-08-19 23:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-08-19 23:03:35

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Change the pvcreate swap/md logic
	
	pvcreate detects MD and swap signature.
	
	The logic hidden there is not only documented but it is also
	user unfriendly. Who invented this logic should run pvcreate
	on its own critical MD device to see why;-)
	
	This patch
	- creates one function instead of duplication code
	- asks if user want to overwrite signature
	- allows aborting (!)
	(Please note that writing LVM signatute without wiping old
	is wrong, it confuses blkid, MD will not work anyway and
	swap and LUKS is broken too.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1712&r2=1.1713
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.391&r2=1.392

--- LVM2/WHATS_NEW	2010/08/19 22:33:14	1.1712
+++ LVM2/WHATS_NEW	2010/08/19 23:03:34	1.1713
@@ -1,5 +1,6 @@
 Version 2.02.74 - 
 ==================================
+  Simplify MD/swap signature detection in pvcreate and allow aborting.
 
 Version 2.02.73 - 18th August 2010
 ==================================
--- LVM2/lib/metadata/metadata.c	2010/08/12 04:11:49	1.391
+++ LVM2/lib/metadata/metadata.c	2010/08/19 23:03:35	1.392
@@ -1526,6 +1526,40 @@
 	return 1;
 }
 
+static int _wipe_sb(struct device *dev, const char *type, const char *name,
+		    int wipe_len, struct pvcreate_params *pp,
+		    int (*func)(struct device *dev, uint64_t *signature))
+{
+	int wipe;
+	uint64_t superblock;
+
+	wipe = func(dev, &superblock);
+	if (wipe == -1) {
+		log_error("Fatal error while trying to detect %s on %s.",
+			  type, name);
+		return 0;
+	}
+
+	if (wipe == 0)
+		return 1;
+
+	/* Specifying --yes => do not ask. */
+	if (!pp->yes && (pp->force == PROMPT) &&
+	    yes_no_prompt("WARNING: %s detected on %s. Wipe it? [y/n] ",
+			  type, name) != 'y') {
+		log_error("Aborting pvcreate on %s.", name);
+		return 0;
+	}
+
+	log_print("Wiping %s on %s.", type, name);
+	if (!dev_set(dev, superblock, wipe_len, 0)) {
+		log_error("Failed to wipe %s on %s.", type, name);
+		return 0;
+	}
+
+	return 1;
+}
+
 /*
  * See if we may pvcreate on this device.
  * 0 indicates we may not.
@@ -1535,8 +1569,6 @@
 {
 	struct physical_volume *pv;
 	struct device *dev;
-	uint64_t md_superblock, swap_signature;
-	int wipe_md, wipe_swap;
 	struct dm_list mdas;
 
 	dm_list_init(&mdas);
@@ -1602,41 +1634,11 @@
 		return 0;
 	}
 
-	/* Wipe superblock? */
-	if ((wipe_md = dev_is_md(dev, &md_superblock)) == 1 &&
-	    ((!pp->idp && !pp->restorefile) || pp->yes ||
-	     (yes_no_prompt("Software RAID md superblock "
-			    "detected on %s. Wipe it? [y/n] ", name) == 'y'))) {
-		log_print("Wiping software RAID md superblock on %s", name);
-		if (!dev_set(dev, md_superblock, 4, 0)) {
-			log_error("Failed to wipe RAID md superblock on %s",
-				  name);
-			return 0;
-		}
-	}
-
-	if (wipe_md == -1) {
-		log_error("Fatal error while trying to detect software "
-			  "RAID md superblock on %s", name);
+	if (!_wipe_sb(dev, "software RAID md superblock", name, 4, pp, dev_is_md))
 		return 0;
-	}
-
-	if ((wipe_swap = dev_is_swap(dev, &swap_signature)) == 1 &&
-	    ((!pp->idp && !pp->restorefile) || pp->yes ||
-	     (yes_no_prompt("Swap signature detected on %s. Wipe it? [y/n] ",
-			    name) == 'y'))) {
-		log_print("Wiping swap signature on %s", name);
-		if (!dev_set(dev, swap_signature, 10, 0)) {
-			log_error("Failed to wipe swap signature on %s", name);
-			return 0;
-		}
-	}
 
-	if (wipe_swap == -1) {
-		log_error("Fatal error while trying to detect swap "
-			  "signature on %s", name);
+	if (!_wipe_sb(dev, "swap signature", name, 10, pp, dev_is_swap))
 		return 0;
-	}
 
 	if (sigint_caught())
 		return 0;


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2010-06-22 21:10 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2010-06-22 21:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-06-22 21:10:53

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix "allocated" warning typo.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1625&r2=1.1626
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.345&r2=1.346

--- LVM2/WHATS_NEW	2010/06/22 19:18:27	1.1625
+++ LVM2/WHATS_NEW	2010/06/22 21:10:53	1.1626
@@ -1,5 +1,6 @@
 Version 2.02.68 -
 ===============================
+  Fix typo in warning message about missing device with allocated data areas.
   Add device name and offset to output of error messages in raw_read_mda_header().
   Use flexible data[] in cmirrord request to prevent abort in runtime size checks.
   Honor log argument when down-converting stacked mirror.
--- LVM2/lib/metadata/metadata.c	2010/05/24 15:32:20	1.345
+++ LVM2/lib/metadata/metadata.c	2010/06/22 21:10:53	1.346
@@ -2604,7 +2604,7 @@
 				pv->status &= ~MISSING_PV;
 				pvl->pv->status &= ~MISSING_PV;
 			} else
-				log_warn("Device still marked missing because of alocated data "
+				log_warn("Device still marked missing because of allocated data "
 					 "on it, remove volumes and consider vgreduce --removemissing.");
 		}
 }


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2010-05-21 12:45 zkabelac
  0 siblings, 0 replies; 42+ messages in thread
From: zkabelac @ 2010-05-21 12:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-05-21 12:45:19

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Replicator: extend _lv_each_dependency() with dependencies for Replicator devices

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1581&r2=1.1582
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.343&r2=1.344

--- LVM2/WHATS_NEW	2010/05/21 12:43:02	1.1581
+++ LVM2/WHATS_NEW	2010/05/21 12:45:18	1.1582
@@ -1,6 +1,7 @@
 Version 2.02.67 -
 ===============================
-  Add check_replicator_segment() for catching internal replicator errors.
+  Extend _lv_each_dependency() with Replicator dependencies.
+  Add check_replicator_segment() for catching internal Replicator errors.
   Initial lvm2 support for Replicator metadata handling.
   Checking open_count in all parents of presuspend_node.
   Added dm_tree_node_set_presuspend_node() to presuspend child in deactivate.
--- LVM2/lib/metadata/metadata.c	2010/05/19 11:52:37	1.343
+++ LVM2/lib/metadata/metadata.c	2010/05/21 12:45:19	1.344
@@ -2001,6 +2001,8 @@
 	struct lv_segment *lvseg;
 
 	struct logical_volume *deps[] = {
+		(lv->rdevice && lv != lv->rdevice->lv) ? lv->rdevice->lv : 0,
+		(lv->rdevice && lv != lv->rdevice->slog) ? lv->rdevice->slog : 0,
 		lv->snapshot ? lv->snapshot->origin : 0,
 		lv->snapshot ? lv->snapshot->cow : 0 };
 	for (i = 0; i < sizeof(deps) / sizeof(*deps); ++i) {
@@ -2011,6 +2013,8 @@
 	dm_list_iterate_items(lvseg, &lv->segments) {
 		if (lvseg->log_lv && !fn(lvseg->log_lv, data))
 			return_0;
+		if (lvseg->rlog_lv && !fn(lvseg->rlog_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] 42+ messages in thread

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

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

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

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

--- LVM2/WHATS_NEW	2010/04/01 10:34:09	1.1499
+++ LVM2/WHATS_NEW	2010/04/01 11:43:24	1.1500
@@ -1,5 +1,6 @@
 Version 2.02.63 -  
 ================================
+  Improve vg_validate to detect some loops in lists.
   Change most remaining log_error WARNING messages to log_warn.
   Always use blocking lock for VGs and orphan locks.
   Allocate all segments memory from vg private mempool.
--- LVM2/lib/metadata/metadata.c	2010/03/31 17:21:40	1.326
+++ LVM2/lib/metadata/metadata.c	2010/04/01 11:43:26	1.327
@@ -2129,12 +2129,28 @@
 	struct lv_list *lvl, *lvl2;
 	char uuid[64] __attribute((aligned(8)));
 	int r = 1;
-	uint32_t hidden_lv_count = 0;
+	uint32_t hidden_lv_count = 0, lv_count = 0, lv_visible_count = 0;
+	uint32_t pv_count = 0;
+	uint32_t num_snapshots = 0;
+	uint32_t loop_counter1, loop_counter2;
 
 	/* FIXME Also check there's no data/metadata overlap */
+	dm_list_iterate_items(pvl, &vg->pvs) {
+		if (++pv_count > vg->pv_count) {
+			log_error(INTERNAL_ERROR "PV list corruption detected in VG %s.", vg->name);
+			/* FIXME Dump list structure? */
+			r = 0;
+		}
+	}
 
+	loop_counter1 = loop_counter2 = 0;
+	/* FIXME Use temp hash table instead? */
 	dm_list_iterate_items(pvl, &vg->pvs) {
+		if (++loop_counter1 > pv_count)
+			break;
 		dm_list_iterate_items(pvl2, &vg->pvs) {
+			if (++loop_counter2 > pv_count)
+				break;
 			if (pvl == pvl2)
 				break;
 			if (id_equal(&pvl->pv->id,
@@ -2167,6 +2183,14 @@
 	 * Count all non-snapshot invisible LVs
 	 */
 	dm_list_iterate_items(lvl, &vg->lvs) {
+		lv_count++;
+
+		if (lv_is_cow(lvl->lv))
+			num_snapshots++;
+
+		if (lv_is_visible(lvl->lv))
+			lv_visible_count++;
+
 		if (lvl->lv->status & VISIBLE_LV)
 			continue;
 
@@ -2192,17 +2216,22 @@
 	/*
 	 * all volumes = visible LVs + snapshot_cows + invisible LVs
 	 */
-	if (((uint32_t) dm_list_size(&vg->lvs)) !=
-	    vg_visible_lvs(vg) + snapshot_count(vg) + hidden_lv_count) {
+	if (lv_count != lv_visible_count + num_snapshots + hidden_lv_count) {
 		log_error(INTERNAL_ERROR "#internal LVs (%u) != #LVs (%"
 			  PRIu32 ") + #snapshots (%" PRIu32 ") + #internal LVs (%u) in VG %s",
-			  dm_list_size(&vg->lvs), vg_visible_lvs(vg),
-			  snapshot_count(vg), hidden_lv_count, vg->name);
+			  lv_count, lv_visible_count,
+			  num_snapshots, hidden_lv_count, vg->name);
 		r = 0;
 	}
 
+	loop_counter1 = loop_counter2 = 0;
+	/* FIXME Use temp hash table instead? */
 	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (++loop_counter1 > lv_count)
+			break;
 		dm_list_iterate_items(lvl2, &vg->lvs) {
+			if (++loop_counter2 > lv_count)
+				break;
 			if (lvl == lvl2)
 				break;
 			if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
@@ -2223,9 +2252,7 @@
 				r = 0;
 			}
 		}
-	}
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
@@ -2889,6 +2916,15 @@
 	}
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (!check_lv_segments(lvl->lv, 0)) {
+			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
+				  lvl->lv->name);
+			vg_release(vg);
+			return NULL;
+		}
+		/*
+		 * Checks that cross-reference other LVs.
+		 */
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2010-03-02 21:56 snitzer
  0 siblings, 0 replies; 42+ messages in thread
From: snitzer @ 2010-03-02 21:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-03-02 21:56:15

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Handle a misaligned device that reports a -1 alignment_offset.
	
	The kernel's blk_stack_limits() function may flag a device as
	'misaligned'.  If it does the alignment_offset will be -1.
	
	Update set_pe_align_offset() to accommodate this corner case.

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

--- LVM2/WHATS_NEW	2010/03/01 20:00:20	1.1441
+++ LVM2/WHATS_NEW	2010/03/02 21:56:14	1.1442
@@ -1,5 +1,6 @@
 Version 2.02.62 -
 ====================================
+  Handle a misaligned device that reports a -1 alignment_offset.
   Extend core allocation code in preparation for mirrored log areas.
   Rewrite clvmd init script.
   Remove lvs_in_vg_activated_by_uuid_only call.
--- LVM2/lib/metadata/metadata.c	2010/02/24 18:15:57	1.317
+++ LVM2/lib/metadata/metadata.c	2010/03/02 21:56:14	1.318
@@ -123,11 +123,14 @@
 
 	if (find_config_tree_bool(pv->fmt->cmd,
 				  "devices/data_alignment_offset_detection",
-				  DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION))
-		pv->pe_align_offset =
-			MAX(pv->pe_align_offset,
-			    dev_alignment_offset(pv->fmt->cmd->sysfs_dir,
-						 pv->dev));
+				  DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION)) {
+		int align_offset = dev_alignment_offset(pv->fmt->cmd->sysfs_dir,
+							pv->dev);
+		/* must handle a -1 alignment_offset; means dev is misaligned */
+		if (align_offset < 0)
+			align_offset = 0;
+		pv->pe_align_offset = MAX(pv->pe_align_offset, align_offset);
+	}
 
 	log_very_verbose("%s: Setting PE alignment offset to %lu sectors.",
 			 dev_name(pv->dev), pv->pe_align_offset);


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

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

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Call _alloc_pv() inside _pv_read() and clean up error paths.
	
	We should be consistent with pv constructors so call _alloc_pv()
	here as we do from pv_create().

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

--- LVM2/WHATS_NEW	2010/01/21 17:14:18	1.1397
+++ LVM2/WHATS_NEW	2010/01/21 21:09:23	1.1398
@@ -1,5 +1,6 @@
 Version 2.02.59 - 
 ===================================
+  Cleanup memory initialization and freeing in pv_read() and pv_create().
   Clear pointer and counters after their release in _fin_commands().
   Add t-topology-support.sh and t-snapshot-merge.sh tests.
   Fix clvmd to never scan suspended devices.
--- LVM2/lib/metadata/metadata.c	2010/01/21 21:04:44	1.311
+++ LVM2/lib/metadata/metadata.c	2010/01/21 21:09:23	1.312
@@ -3020,29 +3020,30 @@
 	if (label_sector && *label_sector)
 		*label_sector = label->sector;
 
-	if (!(pv = dm_pool_zalloc(pvmem, sizeof(*pv)))) {
+	pv = _alloc_pv(pvmem, dev);
+	if (!pv) {
 		log_error("pv allocation for '%s' failed", pv_name);
 		return NULL;
 	}
 
-	dm_list_init(&pv->tags);
-	dm_list_init(&pv->segments);
-
 	/* FIXME Move more common code up here */
 	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas,
 	      scan_label_only))) {
 		log_error("Failed to read existing physical volume '%s'",
 			  pv_name);
-		return NULL;
+		goto bad;
 	}
 
 	if (!pv->size)
-		return NULL;
+		goto bad;
 
 	if (!alloc_pv_segment_whole_pv(pvmem, pv))
-		return_NULL;
+		goto_bad;
 
 	return pv;
+bad:
+	_free_pv(pvmem, pv);
+	return NULL;
 }
 
 /* May return empty list */


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2010-01-05 16:01 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2010-01-05 16:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-05 16:01:22

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Do not set precommitted flag in cache when precommitted metadata does not exist.
	
	The use_precommitted flag indicates, that we want to use precommitted metadata
	(used in suspend call to preload table with precommitted data).
	
	But if there are no such data, committed metadata are read but the cache
	still contains that precommitted flag.
	
	(The problem is that later possible drop_metadata call will not invalidate
	device in cache.)
	
	The wrong precommitted state is stored in on remote nodes during normal
	suspend/resume cycle _without_ vg_write/commit.
	
	Use the PRECOMMITTED status flag here instead (which is always set if using
	precommited metadata here).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1355&r2=1.1356
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.306&r2=1.307

--- LVM2/WHATS_NEW	2010/01/05 15:58:11	1.1355
+++ LVM2/WHATS_NEW	2010/01/05 16:01:22	1.1356
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Properly handle precommitted flag in cache when commited data only present.
   Resume renamed volumes in reverse order to preserve memlock pairing.
   Drop metadata cache after device was autorepaired and removed from VG.
   Remove missing flag in metadata if PV reappeared and is empty.
--- LVM2/lib/metadata/metadata.c	2009/12/18 12:45:41	1.306
+++ LVM2/lib/metadata/metadata.c	2010/01/05 16:01:22	1.307
@@ -2620,7 +2620,11 @@
 			if (!inconsistent_pvs) {
 				log_debug("Updating cache for PVs without mdas "
 					  "in VG %s.", vgname);
-				lvmcache_update_vg(correct_vg, use_precommitted);
+				/*
+				 * If there is no precommitted metadata, committed metadata
+				 * is read and stored in the cache even if use_precommitted is set
+				 */
+				lvmcache_update_vg(correct_vg, correct_vg->status & PRECOMMITTED);
 
 				if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
 					return_NULL;
@@ -2721,7 +2725,11 @@
 			return_NULL;
 	}
 
-	lvmcache_update_vg(correct_vg, use_precommitted);
+	/*
+	 * If there is no precommitted metadata, committed metadata
+	 * is read and stored in the cache even if use_precommitted is set
+	 */
+	lvmcache_update_vg(correct_vg, correct_vg->status & PRECOMMITTED);
 
 	if (inconsistent) {
 		/* FIXME Test should be if we're *using* precommitted metadata not if we were searching for it */


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2009-12-18 12:45 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2009-12-18 12:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-18 12:45:41

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Drop metadata cache after device was autorepaired and removed from VG.
	
	All long running processes must reload metadata when some
	device becomes orphan after repair.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1353&r2=1.1354
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.305&r2=1.306

--- LVM2/WHATS_NEW	2009/12/18 12:44:20	1.1353
+++ LVM2/WHATS_NEW	2009/12/18 12:45:41	1.1354
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Drop metadata cache after device was autorepaired and removed from VG.
   Remove missing flag in metadata if PV reappeared and is empty.
   Destroy allocated mempool in _vg_read_orphans() error path.
   Fix unlocking vg in some pvresize and toollib error paths.
--- LVM2/lib/metadata/metadata.c	2009/12/18 12:44:20	1.305
+++ LVM2/lib/metadata/metadata.c	2009/12/18 12:45:41	1.306
@@ -2794,6 +2794,9 @@
 				vg_release(correct_vg);
 				return_NULL;
 			}
+
+			/* Refresh metadata after orphan write */
+			drop_cached_metadata(correct_vg);
       next_pv:
 			;
 		}


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2009-12-18 12:44 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2009-12-18 12:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-18 12:44:20

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Remove missing flag if PV reappeared and is empty.
	
	When PV device reappears with old metadata, it is
	always updated to new version byt atutomatic metadata
	repair.
	
	Remove missing flag if device is empty.
	
	If device contains allocated extents, issue warning that
	user must remove volumes and re-add this PV before
	manipulating with this volume.
	
	This partially solves bug 547842 when one PV (log) is failed,
	dmeventd removes that device and later this device reappears and
	is wrongly added into VG marked missing.

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

--- LVM2/WHATS_NEW	2009/12/11 13:14:44	1.1352
+++ LVM2/WHATS_NEW	2009/12/18 12:44:20	1.1353
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Remove missing flag in metadata if PV reappeared and is empty.
   Destroy allocated mempool in _vg_read_orphans() error path.
   Fix unlocking vg in some pvresize and toollib error paths.
   Explicitly call suspend for temporary mirror layer.
--- LVM2/lib/metadata/metadata.c	2009/12/16 19:26:20	1.304
+++ LVM2/lib/metadata/metadata.c	2009/12/18 12:44:20	1.305
@@ -2457,6 +2457,25 @@
 	return ret;
 }
 
+static void check_reappeared_pv(struct volume_group *correct_vg,
+				struct physical_volume *pv)
+{
+	struct pv_list *pvl;
+
+	dm_list_iterate_items(pvl, &correct_vg->pvs)
+		if (pv->dev == pvl->pv->dev && pvl->pv->status & MISSING_PV) {
+			log_warn("Missing device %s reappeared, updating "
+				 "metadata for VG %s to version %u.",
+				 pv_dev_name(pvl->pv),  pv_vg_name(pvl->pv), 
+				 correct_vg->seqno);
+			if (pvl->pv->pe_alloc_count == 0) {
+				pv->status &= ~MISSING_PV;
+				pvl->pv->status &= ~MISSING_PV;
+			} else
+				log_warn("Device still marked missing because of alocated data "
+					 "on it, remove volumes and consider vgreduce --removemissing.");
+		}
+}
 /* Caller sets consistent to 1 if it's safe for vg_read_internal to correct
  * inconsistent metadata on disk (i.e. the VG write lock is held).
  * This guarantees only consistent metadata is returned.
@@ -2737,6 +2756,13 @@
 		log_warn("WARNING: Inconsistent metadata found for VG %s - updating "
 			 "to use version %u", vgname, correct_vg->seqno);
 
+		/*
+		 * If PV is marked missing but we found it,
+		 * update metadata and remove MISSING flag
+		 */
+		dm_list_iterate_items(pvl, &all_pvs)
+			check_reappeared_pv(correct_vg, pvl->pv);
+
 		cmd->handles_missing_pvs = 1;
 		if (!vg_write(correct_vg)) {
 			log_error("Automatic metadata correction failed");


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2009-12-11 13:14:45

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Destroy allocated mempool in _vg_read_orphans() error path.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1351&r2=1.1352
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.301&r2=1.302

--- LVM2/WHATS_NEW	2009/12/11 13:11:56	1.1351
+++ LVM2/WHATS_NEW	2009/12/11 13:14:44	1.1352
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Destroy allocated mempool in _vg_read_orphans() error path.
   Fix unlocking vg in some pvresize and toollib error paths.
   Explicitly call suspend for temporary mirror layer.
   Allow use precommited metadata when a PV is missing.
--- LVM2/lib/metadata/metadata.c	2009/12/09 19:29:04	1.301
+++ LVM2/lib/metadata/metadata.c	2009/12/11 13:14:44	1.302
@@ -2380,7 +2380,7 @@
 
 	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg)))) {
 		log_error("vg allocation failed");
-		return NULL;
+		goto bad;
 	}
 	dm_list_init(&vg->pvs);
 	dm_list_init(&vg->lvs);


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2009-12-09 19:29 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2009-12-09 19:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 19:29:04

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Allow manipulation with precommited metadata even when a PV is missing.
	
	The new recovery code first tries to repair LV and then removes failed PV
	from VG. It means that during operation there can be VG with PV missing,
	and vg_read code handles it like not consistent VG.
	
	We already allows returning "inconsistent" commited metadata,
	for mirror repair we need this for precommited too.
	(The suspend call prepares precommited metadata to inactive table on
	other cluster nodes.)
	
	"Inconsistent" here means - correct metadata, just with some metadata areas
	not found (obviously on missing or failed PVs).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1348&r2=1.1349
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.300&r2=1.301

--- LVM2/WHATS_NEW	2009/12/09 19:01:27	1.1348
+++ LVM2/WHATS_NEW	2009/12/09 19:29:04	1.1349
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Allow use precommited metadata when a PV is missing.
   Add memlock information to do_lock_lv debug output.
   Never use distributed lock for LV in non-clustered VG.
   Allow implicit lock conversion in pre/post callbacks on local node.
--- LVM2/lib/metadata/metadata.c	2009/12/03 19:18:34	1.300
+++ LVM2/lib/metadata/metadata.c	2009/12/09 19:29:04	1.301
@@ -2481,6 +2481,7 @@
 	int inconsistent = 0;
 	int inconsistent_vgid = 0;
 	int inconsistent_pvs = 0;
+	int inconsistent_seqno = 0;
 	unsigned use_precommitted = precommitted;
 	unsigned saved_handles_missing_pvs = cmd->handles_missing_pvs;
 	struct dm_list *pvids;
@@ -2556,6 +2557,7 @@
 		/* FIXME Also ensure contents same - checksum compare? */
 		if (correct_vg->seqno != vg->seqno) {
 			inconsistent = 1;
+			inconsistent_seqno = 1;
 			if (vg->seqno > correct_vg->seqno) {
 				vg_release(correct_vg);
 				correct_vg = vg;
@@ -2679,6 +2681,7 @@
 			/* FIXME Also ensure contents same - checksums same? */
 			if (correct_vg->seqno != vg->seqno) {
 				inconsistent = 1;
+				inconsistent_seqno = 1;
 				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
 					vg_release(vg);
 					vg_release(correct_vg);
@@ -2706,6 +2709,16 @@
 		if (use_precommitted) {
 			log_error("Inconsistent pre-commit metadata copies "
 				  "for volume group %s", vgname);
+			/* FIXME: during repair, there is inconsistent flag set because some metadata areas
+			 * are missing (on missing PVs). Code should create list of missing PVs, compare it
+			 * with PV marked missing in metadata and if equals, use it as consistent vg.
+			 * For now, return precommited metadata if remainng seq match here to allow
+			 * preloading table in suspend call.
+			 */
+			if (!inconsistent_seqno) {
+				*consistent = 0;
+				return correct_vg;
+			}
 			vg_release(correct_vg);
 			return NULL;
 		}


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2009-08-20  7:03 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2009-08-20  7:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-08-20 07:03:02

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix uuid warning in pvcreate to use terminated (and dash formatted) UUID string.
	
	# pvcreate -u udwxr7-BoKY-EeKM-r033-xK6o-4og7-F13sGi /dev/sdc
	uuid udwxr7BoKYEeKMr033xK6o4og7F13sGi|��� already in use on "/dev/sdb1"
	is now
	# pvcreate -u udwxr7-BoKY-EeKM-r033-xK6o-4og7-F13sGi /dev/sdc
	uuid udwxr7-BoKY-EeKM-r033-xK6o-4og7-F13sGi already in use on "/dev/sdb1"

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

--- LVM2/WHATS_NEW	2009/08/19 15:34:33	1.1242
+++ LVM2/WHATS_NEW	2009/08/20 07:03:02	1.1243
@@ -1,5 +1,6 @@
 Version 2.02.52 -
 =================================
+  Fix pvcreate string termination in duplicate uuid warning message.
   Fix pvcreate on a partition (2.02.51).
   Fix vgcfgrestore error paths when locking fails (2.02.49).
   Added configure --enable-clogd to conditionally build the cluster log daemon.
--- LVM2/lib/metadata/metadata.c	2009/08/10 17:15:01	1.278
+++ LVM2/lib/metadata/metadata.c	2009/08/20 07:03:02	1.279
@@ -1264,6 +1264,7 @@
 	struct device *dev;
 	struct dm_list mdas;
 	struct pvcreate_params default_pp;
+	char buffer[64] __attribute((aligned(8)));
 
 	fill_default_pvcreate_params(&default_pp);
 	if (!pp)
@@ -1272,8 +1273,11 @@
 	if (pp->idp) {
 		if ((dev = device_from_pvid(cmd, pp->idp)) &&
 		    (dev != dev_cache_get(pv_name, cmd->filter))) {
-			log_error("uuid %s already in use on \"%s\"",
-				  pp->idp->uuid, dev_name(dev));
+			if (!id_write_format((const struct id*)&pp->idp->uuid,
+			    buffer, sizeof(buffer)))
+				return_NULL;
+			log_error("uuid %s already in use on \"%s\"", buffer,
+				  dev_name(dev));
 			return NULL;
 		}
 	}


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-16 03:25:26

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Remove extraneous messages for extent_size and alloc_policy upon vgcreate.
	
	When converting to the new liblvm functions, the vgcreate code path
	changed to create a new vg, then set values.  As a result of this
	change, and the fact that we give a user a message if they try to
	set the same value of a VG attribute (extent_size, alloc_policy, etc),
	you'll see these 2 extraneous "is already" messages with vgcreate:
	tools/lvm vgcreate vg2 /dev/loop2
	Physical extent size of VG vg2 is already 4.00 MB
	Volume group allocation policy is already normal
	Volume group "vg2" successfully created
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

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

--- LVM2/WHATS_NEW	2009/07/16 00:52:06	1.1192
+++ LVM2/WHATS_NEW	2009/07/16 03:25:26	1.1193
@@ -1,5 +1,6 @@
 Version 2.02.50 - 
 ================================
+  Remove unnecessary messages after vgcreate/vgsplit refactor (2.02.49).
   Add log_errno to set a specific errno and replace log_error in due course.
   Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
   Change create_toolcontext to still return an object if it fails part-way.
--- LVM2/lib/metadata/metadata.c	2009/07/15 20:02:47	1.256
+++ LVM2/lib/metadata/metadata.c	2009/07/16 03:25:26	1.257
@@ -742,7 +742,7 @@
 	}
 
 	if (new_size == vg->extent_size) {
-		log_error("Physical extent size of VG %s is already %s",
+		log_verbose("Physical extent size of VG %s is already %s",
 			  vg->name, display_size(vg->cmd, (uint64_t) new_size));
 		return 1;
 	}
@@ -933,7 +933,7 @@
 	}
 
 	if (alloc == vg->alloc) {
-		log_print("Volume group allocation policy is already %s",
+		log_verbose("Volume group allocation policy is already %s",
 			  get_alloc_string(vg->alloc));
 		return 1;
 	}


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

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

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix counting of virtual origin LVs in vg_validate. (mbroz)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1125&r2=1.1126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.221&r2=1.222

--- LVM2/WHATS_NEW	2009/05/27 13:05:53	1.1125
+++ LVM2/WHATS_NEW	2009/05/27 13:19:34	1.1126
@@ -1,5 +1,6 @@
 Version 2.02.48 - 
 ===============================
+  Fix counting of virtual origin LVs in vg_validate.
   Attempt to load dm-zero module if zero target needed but not present.
 
 Version 2.02.47 - 22nd May 2009
--- LVM2/lib/metadata/metadata.c	2009/05/21 03:04:53	1.221
+++ LVM2/lib/metadata/metadata.c	2009/05/27 13:19:34	1.222
@@ -1449,7 +1449,7 @@
 	struct lv_list *lvl, *lvl2;
 	char uuid[64] __attribute((aligned(8)));
 	int r = 1;
-	uint32_t lv_count;
+	uint32_t hidden_lv_count = 0;
 
 	/* FIXME Also check there's no data/metadata overlap */
 
@@ -1486,17 +1486,20 @@
 	/*
 	 * Count all non-snapshot invisible LVs
 	 */
-	lv_count = 0;
 	dm_list_iterate_items(lvl, &vg->lvs) {
 		if (lvl->lv->status & VISIBLE_LV)
 			continue;
 
 		/* snapshots */
-		if (lv_is_cow(lvl->lv) || lv_is_origin(lvl->lv))
+		if (lv_is_cow(lvl->lv))
+			continue;
+
+		/* virtual origins are always hidden */
+		if (lv_is_origin(lvl->lv) && !lv_is_virtual_origin(lvl->lv))
 			continue;
 
 		/* count other non-snapshot invisible volumes */
-		lv_count++;
+		hidden_lv_count++;
 
 		/*
 		 *  FIXME: add check for unreferenced invisible LVs
@@ -1510,11 +1513,11 @@
 	 * all volumes = visible LVs + snapshot_cows + invisible LVs
 	 */
 	if (((uint32_t) dm_list_size(&vg->lvs)) !=
-	    vg_visible_lvs(vg) + snapshot_count(vg) + lv_count) {
+	    vg_visible_lvs(vg) + snapshot_count(vg) + hidden_lv_count) {
 		log_error("Internal error: #internal LVs (%u) != #LVs (%"
-			  PRIu32 ") + #snapshots (%" PRIu32 ") + #invisible LVs %u in VG %s",
+			  PRIu32 ") + #snapshots (%" PRIu32 ") + #internal LVs %u in VG %s",
 			  dm_list_size(&vg->lvs), vg_visible_lvs(vg),
-			  snapshot_count(vg), lv_count, vg->name);
+			  snapshot_count(vg), hidden_lv_count, vg->name);
 		r = 0;
 	}
 


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2009-05-12 19:09 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2009-05-12 19:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-05-12 19:09:21

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix first_seg() call for empty segment list.
	
	The seg variable is temporary variable for list iterator,
	code cannot expect that after iteration it remains NULL
	(it contains non-NULL pointer here id list is empty).
	
	Patch fixes first_seg function so it now correctly returns NULL
	for empty segment list.

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

--- LVM2/WHATS_NEW	2009/05/11 10:28:45	1.1099
+++ LVM2/WHATS_NEW	2009/05/12 19:09:21	1.1100
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Fix first_seg() call for empty segment list.
   Add make install_lvm2 as complement to device-mapper install.
   Reject missing PVs from allocation in toollib.
   Fix PV datalignment for values starting prior to MDA area. (2.02.45)
--- LVM2/lib/metadata/metadata.c	2009/04/28 17:46:47	1.213
+++ LVM2/lib/metadata/metadata.c	2009/05/12 19:09:21	1.214
@@ -1108,12 +1108,12 @@
 
 struct lv_segment *first_seg(const struct logical_volume *lv)
 {
-	struct lv_segment *seg = NULL;
+	struct lv_segment *seg;
 
 	dm_list_iterate_items(seg, &lv->segments)
-		break;
+		return seg;
 
-	return seg;
+	return NULL;
 }
 
 /* Find segment at a given physical extent in a PV */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-22 09:31:32

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Alloc PV internal structure from VG mempool if possible.

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

--- LVM2/WHATS_NEW	2009/04/21 14:31:57	1.1091
+++ LVM2/WHATS_NEW	2009/04/22 09:31:30	1.1092
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Alloc PV internal structure from VG mempool if possible.
   Fix metadata backup to run after vg_commit always.
   Tidy clvmd volume lock cache functions.
   Fix pvs report for orphan PVs when segment attributes are requested.
--- LVM2/lib/metadata/metadata.c	2009/04/10 10:01:08	1.211
+++ LVM2/lib/metadata/metadata.c	2009/04/22 09:31:31	1.212
@@ -38,6 +38,7 @@
 	(((const struct physical_volume *)(handle))->field)
 
 static struct physical_volume *_pv_read(struct cmd_context *cmd,
+					struct dm_pool *pvmem,
 					const char *pv_name,
 					struct dm_list *mdas,
 					uint64_t *label_sector,
@@ -1070,7 +1071,7 @@
 {
 	struct physical_volume *pv;
 
-	if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1, 0))) {
+	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
 		log_error("Physical volume %s not found", pv_name);
 		return NULL;
 	}
@@ -1079,7 +1080,7 @@
 		/* If a PV has no MDAs - need to search all VGs for it */
 		if (!scan_vgs_for_pvs(cmd))
 			return_NULL;
-		if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1, 0))) {
+		if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
 			log_error("Physical volume %s not found", pv_name);
 			return NULL;
 		}
@@ -1684,7 +1685,7 @@
 	}
 
 	dm_list_iterate_items(info, &vginfo->infos) {
-		if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1, 0))) {
+		if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), NULL, NULL, 1, 0))) {
 			continue;
 		}
 		if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
@@ -2216,11 +2217,12 @@
 				struct dm_list *mdas, uint64_t *label_sector,
 				int warnings, int scan_label_only)
 {
-	return _pv_read(cmd, pv_name, mdas, label_sector, warnings, scan_label_only);
+	return _pv_read(cmd, cmd->mem, pv_name, 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 dm_list *mdas,
 					uint64_t *label_sector,
@@ -2245,7 +2247,7 @@
 	if (label_sector && *label_sector)
 		*label_sector = label->sector;
 
-	if (!(pv = dm_pool_zalloc(cmd->mem, sizeof(*pv)))) {
+	if (!(pv = dm_pool_zalloc(pvmem, sizeof(*pv)))) {
 		log_error("pv allocation for '%s' failed", pv_name);
 		return NULL;
 	}
@@ -2263,8 +2265,8 @@
 
 	if (!pv->size)
 		return NULL;
-	
-	if (!alloc_pv_segment_whole_pv(cmd->mem, pv))
+
+	if (!alloc_pv_segment_whole_pv(pvmem, pv))
 		return_NULL;
 
 	return pv;
@@ -2918,7 +2920,7 @@
 pv_t *pv_by_path(struct cmd_context *cmd, const char *pv_name)
 {
 	struct dm_list mdas;
-	
+
 	dm_list_init(&mdas);
-	return _pv_read(cmd, pv_name, &mdas, NULL, 1, 0);
+	return _pv_read(cmd, cmd->mem, pv_name, &mdas, NULL, 1, 0);
 }


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-10 09:56:00

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Properly copy the whole pv structure for later use.
	
	The all_pvs list, used in vg_read, should make its own private
	copy of pv structures, otherwise (when vg will use its own pool)
	it will point to released memory pool.
	The same applies for get_pvs() call.
	
	Patch adds pv_list copy helper and adds explicit memory pool
	parameter into _copy_pv.
	
	(Please note that all these helper functions cannot guarantee that
	vg related fields are valid - proper vg read & lock must be used
	if it is requested.)

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

--- LVM2/WHATS_NEW	2009/04/10 09:54:36	1.1083
+++ LVM2/WHATS_NEW	2009/04/10 09:56:00	1.1084
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Use copy of PV structure when manipulating with global PV lists.
   Always return exit error status when locking of volume group fails.
   Fix mirror log convert validation question.
   Avoid referencing files from DESTDIR during build process.
--- LVM2/lib/metadata/metadata.c	2009/04/02 15:01:11	1.208
+++ LVM2/lib/metadata/metadata.c	2009/04/10 09:56:00	1.209
@@ -198,11 +198,10 @@
 	return 1;
 }
 
-static int _copy_pv(struct physical_volume *pv_to,
+static int _copy_pv(struct dm_pool *pvmem,
+		    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 (!(pv_to->vg_name = dm_pool_strdup(pvmem, pv_from->vg_name)))
@@ -217,6 +216,25 @@
 	return 1;
 }
 
+static struct pv_list *_copy_pvl(struct dm_pool *pvmem, struct pv_list *pvl_from)
+{
+	struct pv_list *pvl_to = NULL;
+
+	if (!(pvl_to = dm_pool_zalloc(pvmem, sizeof(*pvl_to))))
+		return_NULL;
+
+	if (!(pvl_to->pv = dm_pool_alloc(pvmem, sizeof(*pvl_to->pv))))
+		goto_bad;
+
+	if(!_copy_pv(pvmem, pvl_to->pv, pvl_from->pv))
+		goto_bad;
+
+	return pvl_to;
+bad:
+	dm_pool_free(pvmem, pvl_to);
+	return NULL;
+}
+
 int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
 			 const char *vgid, const char *pvid,
 			 struct physical_volume *pv)
@@ -237,7 +255,7 @@
 
 	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(fmt->cmd->mem, pv, pvl->pv)) {
 				log_error("internal PV duplication failed");
 				return_0;
 			}
@@ -1669,7 +1687,7 @@
 	return vg;
 }
 
-static int _update_pv_list(struct dm_list *all_pvs, struct volume_group *vg)
+static int _update_pv_list(struct dm_pool *pvmem, struct dm_list *all_pvs, struct volume_group *vg)
 {
 	struct pv_list *pvl, *pvl2;
 
@@ -1678,13 +1696,15 @@
 			if (pvl->pv->dev == pvl2->pv->dev)
 				goto next_pv;
 		}
-		/* PV is not on list so add it.  Note that we don't copy it. */
-       		if (!(pvl2 = dm_pool_zalloc(vg->cmd->mem, sizeof(*pvl2)))) {
+
+		/*
+		 * PV is not on list so add it.
+		 */
+		if (!(pvl2 = _copy_pvl(pvmem, pvl))) {
 			log_error("pv_list allocation for '%s' failed",
 				  pv_dev_name(pvl->pv));
 			return 0;
 		}
-		pvl2->pv = pvl->pv;
 		dm_list_add(all_pvs, &pvl2->list);
   next_pv:
 		;
@@ -1899,7 +1919,7 @@
 			}
 			if (!correct_vg) {
 				correct_vg = vg;
-				if (!_update_pv_list(&all_pvs, correct_vg))
+				if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg))
 					return_NULL;
 				continue;
 			}
@@ -1913,7 +1933,7 @@
 			/* FIXME Also ensure contents same - checksums same? */
 			if (correct_vg->seqno != vg->seqno) {
 				inconsistent = 1;
-				if (!_update_pv_list(&all_pvs, vg))
+				if (!_update_pv_list(cmd->mem, &all_pvs, vg))
 					return_NULL;
 				if (vg->seqno > correct_vg->seqno)
 					correct_vg = vg;
@@ -2203,7 +2223,7 @@
 	struct str_list *strl;
 	struct dm_list * uninitialized_var(results);
 	const char *vgname, *vgid;
-	struct dm_list *pvh, *tmp;
+	struct pv_list *pvl, *pvl_copy;
 	struct dm_list *vgids;
 	struct volume_group *vg;
 	int consistent = 0;
@@ -2249,8 +2269,13 @@
 
 		/* Move PVs onto results list */
 		if (pvslist)
-			dm_list_iterate_safe(pvh, tmp, &vg->pvs)
-				dm_list_add(results, pvh);
+			dm_list_iterate_items(pvl, &vg->pvs) {
+				if (!(pvl_copy = _copy_pvl(cmd->mem, pvl))) {
+					log_error("PV list allocation failed");
+					return 0;
+				}
+				dm_list_add(results, &pvl_copy->list);
+			}
 	}
 	init_pvmove(old_pvmove);
 


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

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

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Replace internal vg_check_status() implementation.  (mornfall)

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

--- LVM2/WHATS_NEW	2009/01/26 19:01:32	1.1029
+++ LVM2/WHATS_NEW	2009/01/26 22:42:59	1.1030
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Replace internal vg_check_status() implementation.
   Rename vg_read() to vg_read_internal().
 
 Version 2.02.44 - 26th January 2009
--- LVM2/lib/metadata/metadata.c	2009/01/26 22:22:07	1.199
+++ LVM2/lib/metadata/metadata.c	2009/01/26 22:43:00	1.200
@@ -2377,7 +2377,14 @@
 	return 1;
 }
 
-static uint32_t _vg_check_status(const struct volume_group *vg, uint32_t status)
+/*
+ * Performs a set of checks against a VG according to bits set in status
+ * and returns FAILED_* bits for those that aren't acceptable.
+ *
+ * FIXME Remove the unnecessary duplicate definitions and return bits directly.
+ */
+static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
+				    uint32_t status)
 {
 	uint32_t failure = 0;
 
@@ -2414,38 +2421,10 @@
  * vg_check_status - check volume group status flags and log error
  * @vg - volume group to check status flags
  * @status - specific status flags to check (e.g. EXPORTED_VG)
- *
- * Returns:
- * 0 - fail
- * 1 - success
  */
 int vg_check_status(const struct volume_group *vg, uint32_t status)
 {
-	if ((status & CLUSTERED) &&
-	    (vg_is_clustered(vg)) && !locking_is_clustered() &&
-	    !lockingfailed()) {
-		log_error("Skipping clustered volume group %s", vg->name);
-		return 0;
-	}
-
-	if ((status & EXPORTED_VG) &&
-	    (vg->status & EXPORTED_VG)) {
-		log_error("Volume group %s is exported", vg->name);
-		return 0;
-	}
-
-	if ((status & LVM_WRITE) &&
-	    !(vg->status & LVM_WRITE)) {
-		log_error("Volume group %s is read-only", vg->name);
-		return 0;
-	}
-	if ((status & RESIZEABLE_VG) &&
-	    !(vg->status & RESIZEABLE_VG)) {
-		log_error("Volume group %s is not resizeable.", vg->name);
-		return 0;
-	}
-
-	return 1;
+	return !_vg_bad_status_bits(vg, status);
 }
 
 /*
@@ -2616,7 +2595,7 @@
 		}
 	
 
-	failure |= _vg_check_status(vg, status_flags & ~CLUSTERED);
+	failure |= _vg_bad_status_bits(vg, status_flags & ~CLUSTERED);
 	if (failure)
 		goto_bad;
 


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2008-09-25 15:59 mbroz
  0 siblings, 0 replies; 42+ messages in thread
From: mbroz @ 2008-09-25 15:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2008-09-25 15:59:11

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix handling of PVs which reappeared with old metadata version.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.966&r2=1.967
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.192&r2=1.193

--- LVM2/WHATS_NEW	2008/09/25 15:52:28	1.966
+++ LVM2/WHATS_NEW	2008/09/25 15:59:10	1.967
@@ -1,5 +1,6 @@
 Version 2.02.41 -
 =====================================
+  Fix handling of PVs which reappeared with old metadata version.
   Fix mirror DSO to call vgreduce with proper parameters.
   Fix validation of --minor and --major in lvcreate to require -My always.
   Fix release: clvmd build, vgreduce consolidate & tests, /dev/ioerror warning.
--- LVM2/lib/metadata/metadata.c	2008/09/25 15:57:02	1.192
+++ LVM2/lib/metadata/metadata.c	2008/09/25 15:59:10	1.193
@@ -1871,11 +1871,10 @@
 			/* FIXME Also ensure contents same - checksums same? */
 			if (correct_vg->seqno != vg->seqno) {
 				inconsistent = 1;
-				if (vg->seqno > correct_vg->seqno) {
-					if (!_update_pv_list(&all_pvs, vg))
-						return_NULL;
+				if (!_update_pv_list(&all_pvs, vg))
+					return_NULL;
+				if (vg->seqno > correct_vg->seqno)
 					correct_vg = vg;
-				}
 			}
 		}
 
@@ -2270,6 +2269,7 @@
 
 	pv->vg_name = cmd->fmt->orphan_vg_name;
 	pv->status = ALLOCATABLE_PV;
+	pv->pe_alloc_count = 0;
 
 	if (!dev_get_size(pv->dev, &pv->size)) {
 		log_error("%s: Couldn't get size.", pv_dev_name(pv));


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2008-06-03 17:56 agk
  0 siblings, 0 replies; 42+ messages in thread
From: agk @ 2008-06-03 17:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-06-03 17:56:54

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Drop metadata cache if update fails in vg_revert or vg_commit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.879&r2=1.880
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.175&r2=1.176

--- LVM2/WHATS_NEW	2008/06/03 17:51:03	1.879
+++ LVM2/WHATS_NEW	2008/06/03 17:56:54	1.880
@@ -9,6 +9,7 @@
 
 Version 2.02.37 - 
 =================================
+  Drop metadata cache if update fails in vg_revert or vg_commit.
   Avoid spurious duplicate VG messages referring to VGs that are gone.
   Drop dev_name_confirmed error message to debug level.
   Fix setpriority error message to signed int.
--- LVM2/lib/metadata/metadata.c	2008/05/08 18:06:58	1.175
+++ LVM2/lib/metadata/metadata.c	2008/06/03 17:56:54	1.176
@@ -1363,7 +1363,8 @@
 		}
 	}
 
-	if (!drop_cached_metadata(vg))
+	/* If update failed, remove any cached precommitted metadata. */
+	if (!cache_updated && !drop_cached_metadata(vg))
 		log_error("Attempt to drop cached metadata failed "
 			  "after commit for VG %s.", vg->name);
 
@@ -1383,6 +1384,10 @@
 		}
 	}
 
+	if (!drop_cached_metadata(vg))
+		log_error("Attempt to drop cached metadata failed "
+			  "after reverted update for VG %s.", vg->name);
+
 	return 1;
 }
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-05-08 18:06:59

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Drop metadata cache before writing precommitted metadata instead of after.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.867&r2=1.868
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.174&r2=1.175

--- LVM2/WHATS_NEW	2008/04/30 14:34:02	1.867
+++ LVM2/WHATS_NEW	2008/05/08 18:06:58	1.868
@@ -1,9 +1,13 @@
-Version 2.02.37 - 
+Version 2.02.38 - 
 =================================
-  Don't touch /dev in vgrename if activation is disabled.
   Check lv_count in vg_validate.
   Add --prefixes to reporting tools for field name prefix output format.
 
+Version 2.02.37 - 
+=================================
+  Drop metadata cache before writing precommitted metadata instead of after.
+  Don't touch /dev in vgrename if activation is disabled.
+
 Version 2.02.36 - 29th April 2008
 =================================
   Fix fsadm.sh to work with older blockdev, blkid & readlink binaries.
--- LVM2/lib/metadata/metadata.c	2008/04/29 16:11:27	1.174
+++ LVM2/lib/metadata/metadata.c	2008/05/08 18:06:58	1.175
@@ -1278,6 +1278,11 @@
 		return 0;
 	}
 
+	if (!drop_cached_metadata(vg)) {
+		log_error("Unable to drop cached metadata for VG %s.", vg->name);
+		return 0;
+	}
+
 	vg->seqno++;
 
 	/* Write to each copy of the metadata area */
@@ -1343,11 +1348,6 @@
 		return cache_updated;
 	}
 
-	if (!drop_cached_metadata(vg)) {
-		log_error("Unable to drop cached metadata for VG %s.", vg->name);
-		return 0;
-	}
-
 	/* Commit to each copy of the metadata area */
 	list_iterate_items(mda, &vg->fid->metadata_areas) {
 		failed = 0;


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2008-04-07 22:12 agk
  0 siblings, 0 replies; 42+ messages in thread
From: agk @ 2008-04-07 22:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-04-07 22:12:37

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	create fids for internal orphan VGs

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.828&r2=1.829
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.165&r2=1.166

--- LVM2/WHATS_NEW	2008/04/07 19:17:29	1.828
+++ LVM2/WHATS_NEW	2008/04/07 22:12:35	1.829
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Create a fid for internal orphan VGs.
   Update lvmcache VG lock state for all locking types now.
   Fix output if overriding command_names on cmdline.
   Add detection of clustered mirror log capability.
--- LVM2/lib/metadata/metadata.c	2008/04/04 15:41:20	1.165
+++ LVM2/lib/metadata/metadata.c	2008/04/07 22:12:37	1.166
@@ -1382,6 +1382,15 @@
 		return NULL;
 	}
 
+	/* create format instance with appropriate metadata area */
+	if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt,
+							  orphan_vgname, NULL,
+							  NULL))) {
+		log_error("Failed to create format instance");
+		dm_pool_free(cmd->mem, vg);
+		return NULL;
+	}
+
 	list_iterate_items(info, &vginfo->infos) {
 		if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1))) {
 			continue;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-04-04 15:41:20

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Add check to vg_commit() to ensure lock is held before writing new VG metadata.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.824&r2=1.825
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165

--- LVM2/WHATS_NEW	2008/04/04 11:59:29	1.824
+++ LVM2/WHATS_NEW	2008/04/04 15:41:20	1.825
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Add check to vg_commit() ensuring VG lock held before writing new VG metadata.
   Add validation of LV name to pvmove -n.
   Make clvmd refresh the context correctly when lvm.conf is updated.
   Add some basic internal VG lock validation.
--- LVM2/lib/metadata/metadata.c	2008/04/01 22:40:12	1.164
+++ LVM2/lib/metadata/metadata.c	2008/04/04 15:41:20	1.165
@@ -1316,6 +1316,12 @@
 	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;
+	}
+
 	/* Commit to each copy of the metadata area */
 	list_iterate_items(mda, &vg->fid->metadata_areas) {
 		failed = 0;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-10-12 18:37:19

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Add _alloc_pv() and _free_pv() from _pv_create() code and fix error paths.
	
	Modified original patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>

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

--- LVM2/WHATS_NEW	2007/10/12 14:29:31	1.720
+++ LVM2/WHATS_NEW	2007/10/12 18:37:19	1.721
@@ -1,8 +1,9 @@
 Version 2.02.29 -
 ==================================
+  Add _alloc_pv() and _free_pv() from _pv_create() code and fix error paths.
   Add pv_dev_name() to access PV device name.
   Add const attributes to pv accessor functions.
-  Refactor vg_add_snapshot and lv_create_empty.
+  Refactor vg_add_snapshot() and lv_create_empty().
   Handle new sysfs subsystem/block/devices directory structure.
   Tests are run with LVM_SYSTEM_DIR pointing to private root and /dev dirs.
   Fix a bug in lvm_dump.sh checks for lvm/dmsetup binaries.
--- LVM2/lib/metadata/metadata.c	2007/10/12 14:29:32	1.138
+++ LVM2/lib/metadata/metadata.c	2007/10/12 18:37:19	1.139
@@ -708,6 +708,45 @@
 			  pvmetadatasize, mdas);
 }
 
+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);
+}
+
+static struct physical_volume *_alloc_pv(struct dm_pool *mem)
+{
+	struct physical_volume *pv = dm_pool_zalloc(mem, sizeof(*pv));
+
+	if (!pv) {
+		stack;
+		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;
+	pv->pe_alloc_count = 0;
+	pv->fmt = NULL;
+
+	pv->status = ALLOCATABLE_PV;
+
+	list_init(&pv->tags);
+	list_init(&pv->segments);
+
+	return pv;
+}
+
 /* Sizes in sectors */
 static struct physical_volume *_pv_create(const struct format_type *fmt,
 				  struct device *dev,
@@ -719,28 +758,21 @@
 				  uint64_t pvmetadatasize, struct list *mdas)
 {
 	struct dm_pool *mem = fmt->cmd->mem;
-	struct physical_volume *pv = dm_pool_zalloc(mem, sizeof(*pv));
+	struct physical_volume *pv = _alloc_pv(mem);
 
-	if (!pv) {
-		stack;
+	if (!pv)
 		return NULL;
-	}
 
 	if (id)
 		memcpy(&pv->id, id, sizeof(*id));
 	else if (!id_create(&pv->id)) {
 		log_error("Failed to create random uuid for %s.",
 			  dev_name(dev));
-		return NULL;
+		goto bad;
 	}
 
 	pv->dev = dev;
 
-	if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN)))
-		goto_bad;
-
-	pv->status = ALLOCATABLE_PV;
-
 	if (!dev_get_size(pv->dev, &pv->size)) {
 		log_error("%s: Couldn't get size.", pv_dev_name(pv));
 		goto bad;
@@ -761,15 +793,8 @@
 		goto bad;
 	}
 
-	pv->pe_size = 0;
-	pv->pe_start = 0;
-	pv->pe_count = 0;
-	pv->pe_alloc_count = 0;
 	pv->fmt = fmt;
 
-	list_init(&pv->tags);
-	list_init(&pv->segments);
-
 	if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count,
 				existing_extent_size,
 				pvmetadatacopies, pvmetadatasize, mdas,
@@ -781,7 +806,7 @@
 	return pv;
 
       bad:
-	dm_pool_free(mem, pv);
+	_free_pv(mem, pv);
 	return NULL;
 }
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-07-02 21:48:31

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Convert _add_pv_to_vg to usable LVM library function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.645&r2=1.646
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123

--- LVM2/WHATS_NEW	2007/07/02 20:18:38	1.645
+++ LVM2/WHATS_NEW	2007/07/02 21:48:30	1.646
@@ -1,5 +1,6 @@
 Version 2.02.27 - 
 ================================
+  Convert _add_pv_to_vg to usable LVM library function.
   Add kernel and device-mapper targets versions report to lvmdump.
   Don't use index and rindex functions marked by SUSv3 as legacy.
   Fix vgsplit if splitting all PVs from VG.
--- LVM2/lib/metadata/metadata.c	2007/06/28 17:33:44	1.122
+++ LVM2/lib/metadata/metadata.c	2007/07/02 21:48:30	1.123
@@ -66,11 +66,11 @@
 	return MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
 }
 
-static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
-			 const char *pv_name)
+static int _add_pv_to_vg(struct volume_group *vg, const char *pv_name)
 {
 	struct pv_list *pvl;
 	struct physical_volume *pv;
+	struct format_instance *fid = vg->fid;
 	struct dm_pool *mem = fid->fmt->cmd->mem;
 	struct list mdas;
 
@@ -251,7 +251,7 @@
 
 	/* attach each pv */
 	for (i = 0; i < pv_count; i++)
-		if (!_add_pv_to_vg(vg->fid, vg, pv_names[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;


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2006-09-21 20:25 agk
  0 siblings, 0 replies; 42+ messages in thread
From: agk @ 2006-09-21 20:25 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-09-21 20:25:54

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Fix two potential NULL pointer derefs in error cases in vg_read().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.443&r2=1.444
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98

--- LVM2/WHATS_NEW	2006/09/20 17:36:47	1.443
+++ LVM2/WHATS_NEW	2006/09/21 20:25:54	1.444
@@ -1,5 +1,6 @@
 Version 2.02.11 - 
 =====================================
+  Fix two potential NULL pointer derefs in error cases in vg_read().
   Separate --enable-cluster from locking lib options in lvmconf.sh.
   Add a missing comma in lvcreate man page.
 
--- LVM2/lib/metadata/metadata.c	2006/08/17 19:53:36	1.97
+++ LVM2/lib/metadata/metadata.c	2006/09/21 20:25:54	1.98
@@ -1044,7 +1044,7 @@
 	if (correct_vg) {
 		if (list_size(&correct_vg->pvs) != list_size(pvids)) {
 			log_debug("Cached VG %s had incorrect PV list",
-				  vg->name);
+				  vgname);
 
 			if (memlock())
 				inconsistent = 1;
@@ -1053,7 +1053,7 @@
 		} else list_iterate_items(pvl, &correct_vg->pvs) {
 			if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
 				log_debug("Cached VG %s had incorrect PV list",
-					  vg->name);
+					  vgname);
 				correct_vg = NULL;
 				break;
 			}


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2006-08-09 19:33 agk
  0 siblings, 0 replies; 42+ messages in thread
From: agk @ 2006-08-09 19:33 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-08-09 19:33:25

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Add checks for duplicate LV name, lvid and PV id before writing metadata.
	Report all sanity check failures, not just the first.

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

--- LVM2/WHATS_NEW	2006/08/08 21:20:00	1.415
+++ LVM2/WHATS_NEW	2006/08/09 19:33:25	1.416
@@ -1,5 +1,7 @@
 Version 2.02.08 - 
 ================================
+  Add checks for duplicate LV name, lvid and PV id before writing metadata.
+  Report all sanity check failures, not just the first.
   Fix missing lockfs on first snapshot creation.
   Add unreliable --trustcache option to reporting commands.
   Fix locking for mimage removal.
--- LVM2/lib/metadata/metadata.c	2006/07/04 19:36:49	1.94
+++ LVM2/lib/metadata/metadata.c	2006/08/09 19:33:25	1.95
@@ -722,23 +722,68 @@
 
 int vg_validate(struct volume_group *vg)
 {
-	struct lv_list *lvl;
+	struct pv_list *pvl, *pvl2;
+	struct lv_list *lvl, *lvl2;
+	char uuid[64];
+	int r = 1;
+
+	list_iterate_items(pvl, &vg->pvs) {
+		list_iterate_items(pvl2, &vg->pvs) {
+			if (pvl == pvl2)
+				break;
+			if (id_equal(&pvl->pv->id,
+				     &pvl2->pv->id)) {
+				if (!id_write_format(&pvl->pv->id, uuid,
+						     sizeof(uuid)))
+					 stack;
+				log_error("Internal error: Duplicate PV id "
+					  "%s detected for %s in %s.",
+					  uuid, dev_name(pvl->pv->dev),
+					  vg->name);
+				r = 0;
+			}
+		}
+	}
 
 	if (!check_pv_segments(vg)) {
 		log_error("Internal error: PV segments corrupted in %s.",
 			  vg->name);
-		return 0;
+		r = 0;
+	}
+
+	list_iterate_items(lvl, &vg->lvs) {
+		list_iterate_items(lvl2, &vg->lvs) {
+			if (lvl == lvl2)
+				break;
+			if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
+				log_error("Internal error: Duplicate LV name "
+					  "%s detected in %s.", lvl->lv->name,
+					  vg->name);
+				r = 0;
+			}
+			if (id_equal(&lvl->lv->lvid.id[1],
+				     &lvl2->lv->lvid.id[1])) {
+				if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
+						     sizeof(uuid)))
+					 stack;
+				log_error("Internal error: Duplicate LV id "
+					  "%s detected for %s and %s in %s.",
+					  uuid, lvl->lv->name, lvl2->lv->name,
+					  vg->name);
+				r = 0;
+			}
+		}
 	}
 
 	list_iterate_items(lvl, &vg->lvs) {
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error("Internal error: LV segments corrupted in %s.",
 				  lvl->lv->name);
-			return 0;
+			r = 0;
 		}
 	}
 
-	return 1;
+	return r;
 }
 
 /*


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c
@ 2006-07-04 19:36 agk
  0 siblings, 0 replies; 42+ messages in thread
From: agk @ 2006-07-04 19:36 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-07-04 19:36:49

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Add some forgotten memlock checks to _vg_read to protect against full scans.

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

--- LVM2/WHATS_NEW	2006/07/04 18:57:26	1.405
+++ LVM2/WHATS_NEW	2006/07/04 19:36:48	1.406
@@ -1,5 +1,6 @@
 Version 2.02.07 - 
 =================================
+  Add some forgotten memlock checks to _vg_read to protect against full scans.
   Add mutex to dmeventd_mirror to avoid concurrent execution.
   Fix vgreduce --removemissing to return success if VG is already consistent.
   Fix return code if VG specified on command line is not found.
--- LVM2/lib/metadata/metadata.c	2006/05/11 17:58:58	1.93
+++ LVM2/lib/metadata/metadata.c	2006/07/04 19:36:49	1.94
@@ -993,7 +993,11 @@
 		if (list_size(&correct_vg->pvs) != list_size(pvids)) {
 			log_debug("Cached VG %s had incorrect PV list",
 				  vg->name);
-			correct_vg = NULL;
+
+			if (memlock())
+				inconsistent = 1;
+			else
+				correct_vg = NULL;
 		} else list_iterate_items(pvl, &correct_vg->pvs) {
 			if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
 				log_debug("Cached VG %s had incorrect PV list",
@@ -1008,6 +1012,10 @@
 	if (!correct_vg) {
 		inconsistent = 0;
 
+		if (memlock()) {
+			stack;
+			return NULL;
+		}
 		lvmcache_label_scan(cmd, 2);
 		if (!(fmt = fmt_from_vgname(vgname, vgid))) {
 			stack;
@@ -1149,7 +1157,8 @@
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vginfo->vgname);
-				return NULL;
+				if (!partial_mode())
+					return NULL;
 			}
 			return vg;
 		}


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

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

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 15:06 LVM2 ./WHATS_NEW lib/metadata/metadata.c prajnoha
  -- strict thread matches above, loose matches on Subject: below --
2012-03-12 14:18 zkabelac
2012-02-23  0:11 agk
2012-02-13 11:01 zkabelac
2012-02-13 10:58 zkabelac
2012-02-13 10:51 zkabelac
2011-11-18 19:28 zkabelac
2011-10-24 10:24 zkabelac
2011-08-11 16:31 prajnoha
2011-08-04 15:18 zkabelac
2011-03-29 21:57 zkabelac
2011-03-10 13:12 zkabelac
2010-12-08 10:45 zkabelac
2010-11-29 11:08 zkabelac
2010-08-19 23:03 mbroz
2010-06-22 21:10 mbroz
2010-05-21 12:45 zkabelac
2010-04-01 11:43 agk
2010-03-02 21:56 snitzer
2010-01-21 21:09 wysochanski
2010-01-05 16:01 mbroz
2009-12-18 12:45 mbroz
2009-12-18 12:44 mbroz
2009-12-11 13:14 zkabelac
2009-12-09 19:29 mbroz
2009-08-20  7:03 mbroz
2009-07-16  3:25 wysochanski
2009-05-27 13:19 agk
2009-05-12 19:09 mbroz
2009-04-22  9:31 mbroz
2009-04-10  9:56 mbroz
2009-01-26 22:43 agk
2008-09-25 15:59 mbroz
2008-06-03 17:56 agk
2008-05-08 18:06 agk
2008-04-07 22:12 agk
2008-04-04 15:41 wysochanski
2007-10-12 18:37 wysochanski
2007-07-02 21:48 wysochanski
2006-09-21 20:25 agk
2006-08-09 19:33 agk
2006-07-04 19:36 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).