public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2010-10-26  9:13 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2010-10-26  9:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix NULL pointer dereference for too large MDA error path
	
	Replace dereference of NULL vg with passed vgname to the function
	_vg_read_raw_area() in the error path for too large MDA.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1779&r2=1.1780
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.147&r2=1.148

--- LVM2/WHATS_NEW	2010/10/26 08:59:05	1.1779
+++ LVM2/WHATS_NEW	2010/10/26 09:13:13	1.1780
@@ -1,5 +1,6 @@
 Version 2.02.76
 ===================================
+  Fix NULL pointer dereference for too large MDA error path in _vg_read_raw_area().
   Use static for internal _align_chunk() and _new_chunk() from pool-fast.c.
   Fix vgchange to process -a, --refresh, --monitor and --poll like lvchange.
   Add lvm2app functions to query any pv, vg, or lv property / report field.
--- LVM2/lib/format_text/format-text.c	2010/10/05 17:34:06	1.147
+++ LVM2/lib/format_text/format-text.c	2010/10/26 09:13:13	1.148
@@ -507,7 +507,7 @@
 
 	if (wrap > rlocn->offset) {
 		log_error("VG %s metadata too large for circular buffer",
-			  vg->name);
+			  vgname);
 		goto out;
 	}
 


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

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

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

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Add check for mda_copy failure

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2287&r2=1.2288
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.192&r2=1.193

--- LVM2/WHATS_NEW	2012/02/13 11:07:55	1.2287
+++ LVM2/WHATS_NEW	2012/02/13 11:09:25	1.2288
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Add check for mda_copy failure in _text_pv_setup().
   Add check for _mirrored_init_target failure.
   Add free_orphan_vg.
   Skip pv/vg_set_fid processing if the fid is same.
--- LVM2/lib/format_text/format-text.c	2012/02/13 11:04:00	1.192
+++ LVM2/lib/format_text/format-text.c	2012/02/13 11:09:25	1.193
@@ -1608,7 +1608,8 @@
 
 			/* Be sure it's not already in VG's format instance! */
 			if (!fid_get_mda_indexed(vg->fid, pvid, ID_LEN, mda_index)) {
-				pv_mda_copy = mda_copy(vg->fid->mem, pv_mda);
+				if (!(pv_mda_copy = mda_copy(vg->fid->mem, pv_mda)))
+					return_0;
 				fid_add_mda(vg->fid, pv_mda_copy, pvid, ID_LEN, mda_index);
 			}
 		}


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2011-08-29 13:37 prajnoha
  0 siblings, 0 replies; 17+ messages in thread
From: prajnoha @ 2011-08-29 13:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-08-29 13:37:37

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Directly allocate buffer memory in a pvck scan instead of using a mempool.
	
	There's a very high memory usage when calling _pv_analyse_mda_raw (e.g. while
	executing pvck) that can end up with "out of memory".
	
	_pv_analyse_mda_raw scans for metadata in the MDA, iteratively increasing the
	size to scan with SECTOR_SIZE until we find a probable config section or we're
	at the edge of the metadata area. However, when using a memory pool, we're also
	iteratively chasing for bigger and bigger mempool chunk which can't be found
	and so we're always allocating a new one, consuming more and more memory...
	
	This patch just changes the mempool to direct memory allocation in this
	problematic part of the code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2084&r2=1.2085
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.183&r2=1.184

--- LVM2/WHATS_NEW	2011/08/24 13:41:46	1.2084
+++ LVM2/WHATS_NEW	2011/08/29 13:37:36	1.2085
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Directly allocate buffer memory in a pvck scan instead of using a mempool.
   Add configure --with-thin for (unimplemented) segtypes "thin" and "thin_pool".
   Fix raid shared lib segtype registration (2.02.87).
 
--- LVM2/lib/format_text/format-text.c	2011/08/10 20:25:30	1.183
+++ LVM2/lib/format_text/format-text.c	2011/08/29 13:37:37	1.184
@@ -226,7 +226,7 @@
 		 * "maybe_config_section" returning true when there's no valid
 		 * metadata in a sector (sectors with all nulls).
 		 */
-		if (!(buf = dm_pool_alloc(fmt->cmd->mem, size + size2)))
+		if (!(buf = dm_malloc(size + size2)))
 			goto_out;
 
 		if (!dev_read_circular(area->dev, offset, size,
@@ -261,14 +261,14 @@
 				size += SECTOR_SIZE;
 			}
 		}
-		dm_pool_free(fmt->cmd->mem, buf);
+		dm_free(buf);
 		buf = NULL;
 	}
 
 	r = 1;
  out:
 	if (buf)
-		dm_pool_free(fmt->cmd->mem, buf);
+		dm_free(buf);
 	if (!dev_close(area->dev))
 		stack;
 	return r;


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2011-02-03  1:41 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2011-02-03  1:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-02-03 01:41:03

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix wipe size when seting up mda.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1899&r2=1.1900
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.153&r2=1.154

--- LVM2/WHATS_NEW	2011/02/03 01:24:46	1.1899
+++ LVM2/WHATS_NEW	2011/02/03 01:41:03	1.1900
@@ -1,5 +1,6 @@
 Version 2.02.83 - 
 ===================================
+  Fix wipe size when setting up mda.
   Remove unneeded checks for open_count in lv_info().
   Synchronize with udev before checking open_count in lv_info().
   Allow CLVMD_CMD_SYNC_NAMES to be propagated around the cluster if requested.
--- LVM2/lib/format_text/format-text.c	2010/12/20 13:32:49	1.153
+++ LVM2/lib/format_text/format-text.c	2011/02/03 01:41:03	1.154
@@ -1347,8 +1347,8 @@
 			return 0;
 
 		if (!dev_set((struct device *) pv->dev, start1,
-			     (size_t) (mda_size1 >
-				       wipe_size ? : mda_size1), 0)) {
+			     (size_t) ((mda_size1 > wipe_size) ?
+				       wipe_size : mda_size1), 0)) {
 			log_error("Failed to wipe new metadata area");
 			return 0;
 		}
@@ -1392,8 +1392,8 @@
 		if (!add_mda(fmt, fmt->cmd->mem, mdas, pv->dev, start2,
 			     mda_size2, metadataignore)) return 0;
 		if (!dev_set(pv->dev, start2,
-			     (size_t) (mda_size1 >
-				       wipe_size ? : mda_size1), 0)) {
+			     (size_t) ((mda_size2 > wipe_size) ?
+				       wipe_size : mda_size2), 0)) {
 			log_error("Failed to wipe new metadata area");
 			return 0;
 		}


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2010-09-30 14:12 prajnoha
  0 siblings, 0 replies; 17+ messages in thread
From: prajnoha @ 2010-09-30 14:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-09-30 14:12:14

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix memory leak of vg_read while using live copies of metadata in directories.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1741&r2=1.1742
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.145&r2=1.146

--- LVM2/WHATS_NEW	2010/09/30 11:44:54	1.1741
+++ LVM2/WHATS_NEW	2010/09/30 14:12:14	1.1742
@@ -1,5 +1,6 @@
 Version 2.02.75 - 
 =====================================
+  Fix memory leak of vg_read while using live copies of metadata in directories.
   Fix memory leak of config_tree in reinitialization code path.
   Swap pool destruction order in dmeventd_lvm2_exit() to fix leak report.
   Read whole /proc/self/maps file before working with maps entries.
--- LVM2/lib/format_text/format-text.c	2010/09/27 19:09:35	1.145
+++ LVM2/lib/format_text/format-text.c	2010/09/30 14:12:14	1.146
@@ -1083,9 +1083,11 @@
 				fid = _text_create_text_instance(fmt, NULL, NULL,
 							    NULL);
 				if ((vg = _vg_read_file_name(fid, vgname,
-							     path)))
+							     path))) {
 					/* FIXME Store creation host in vg */
 					lvmcache_update_vg(vg, 0);
+					dm_pool_destroy(vg->vgmem);
+				}
 			}
 
 		if (closedir(d))


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2010-06-01 12:08 prajnoha
  0 siblings, 0 replies; 17+ messages in thread
From: prajnoha @ 2010-06-01 12:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-06-01 12:08:51

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix incorrect memory pool deallocation while using vg_read for files.
	
	We create a separate pool "lvm2 vg_read" for vg_read and we don't use
	cmd->mem anymore.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1600&r2=1.1601
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122

--- LVM2/WHATS_NEW	2010/05/28 03:50:15	1.1600
+++ LVM2/WHATS_NEW	2010/06/01 12:08:50	1.1601
@@ -1,5 +1,6 @@
 Version 2.02.67 -
 ===============================
+  Fix incorrect memory pool deallocation while using vg_read for files.
   Add --type parameter description to the lvcreate man page.
   Replace strncmp kernel version number checks with proper ones.
   Avoid selecting names under /dev/block if there is an alternative.
--- LVM2/lib/format_text/format-text.c	2010/04/14 13:09:16	1.121
+++ LVM2/lib/format_text/format-text.c	2010/06/01 12:08:50	1.122
@@ -814,7 +814,7 @@
 	 * check that it contains the correct volume group.
 	 */
 	if (vgname && strcmp(vgname, vg->name)) {
-		dm_pool_free(fid->fmt->cmd->mem, vg);
+		dm_pool_destroy(vg->vgmem);
 		log_error("'%s' does not contain volume group '%s'.",
 			  read_path, vgname);
 		return NULL;


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-07-30 21:15 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2009-07-30 21:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-07-30 21:15:18

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Disable the "new pe_start policy"
	
	Documented which use-cases force the reinstatement of the nuanced
	handling of pe_start.  As soon as orphan PVs are eliminated much of this
	will no longer be a concern ('preserve_pe_start' can be reenabled in
	.pv_setup).
	
	Added defensive 'if (pv->pe_align)' check in _text_pv_write()'s pe_start
	loop.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1217&r2=1.1218
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113

--- LVM2/WHATS_NEW	2009/07/30 18:40:22	1.1217
+++ LVM2/WHATS_NEW	2009/07/30 21:15:17	1.1218
@@ -1,9 +1,7 @@
 Version 2.02.51 - 
 ================================
   Add --dataalignmentoffset to pvcreate to shift start of aligned data area.
-  Preserve pe_start in .pv_write if pe_start was supplied.
   Fix _mda_setup() to not check first mda's size before pe_align rounding.
-  Formalize pe_start policy as split between .pv_setup and .pv_write.
   Document -I option of clvmd in the man page.
   Fix configure script to handle multiple clvmd selections.
   Fix lvm2app.pc installation filename.
--- LVM2/lib/format_text/format-text.c	2009/07/30 18:40:22	1.112
+++ LVM2/lib/format_text/format-text.c	2009/07/30 21:15:17	1.113
@@ -1337,6 +1337,7 @@
 	char buf[MDA_HEADER_SIZE] __attribute((aligned(8)));
 	struct mda_header *mdah = (struct mda_header *) buf;
 	uint64_t adjustment;
+	struct data_area_list *da;
 
 	/* FIXME Test mode don't update cache? */
 
@@ -1373,24 +1374,42 @@
 		dm_list_init(&info->mdas);
 	}
 
-	if (info->das.n)
+	/*
+	 * If no pe_start supplied but PV already exists,
+	 * get existing value; use-cases include:
+	 * - pvcreate on PV without prior pvremove
+	 * - vgremove on VG with PV(s) that have pe_start=0 (hacked cfg)
+	 */
+	if (info->das.n) {
+		if (!pv->pe_start)
+			dm_list_iterate_items(da, &info->das)
+				pv->pe_start = da->disk_locn.offset >> SECTOR_SHIFT;
 		del_das(&info->das);
-	else
+	} else
 		dm_list_init(&info->das);
 
+#if 0
+	/*
+	 * FIXME: ideally a pre-existing pe_start seen in .pv_write
+	 * would always be preserved BUT 'pvcreate on PV without prior pvremove'
+	 * could easily cause the pe_start to overlap with the first mda!
+	 */
 	if (pv->pe_start) {
 		log_very_verbose("%s: preserving pe_start=%lu",
 				 pv_dev_name(pv), pv->pe_start);
 		goto preserve_pe_start;
 	}
+#endif
 
 	/*
 	 * If pe_start is still unset, set it to first aligned
 	 * sector after any metadata areas that begin before pe_start.
 	 */
-	pv->pe_start = pv->pe_align;
-	if (pv->pe_align_offset)
-		pv->pe_start += pv->pe_align_offset;
+	if (!pv->pe_start) {
+		pv->pe_start = pv->pe_align;
+		if (pv->pe_align_offset)
+			pv->pe_start += pv->pe_align_offset;
+	}
 	dm_list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if (pv->dev == mdac->area.dev &&
@@ -1402,11 +1421,14 @@
 			pv->pe_start = (mdac->area.start + mdac->area.size)
 			    >> SECTOR_SHIFT;
 			/* Adjust pe_start to: (N * pe_align) + pe_align_offset */
-			adjustment =
+			if (pv->pe_align) {
+				adjustment =
 				(pv->pe_start - pv->pe_align_offset) % pv->pe_align;
-			if (adjustment)
-				pv->pe_start += pv->pe_align - adjustment;
-			log_very_verbose("%s: setting pe_start=%lu (orig_pe_start=%lu, "
+				if (adjustment)
+					pv->pe_start += pv->pe_align - adjustment;
+
+				log_very_verbose("%s: setting pe_start=%lu "
+					 "(orig_pe_start=%lu, "
 					 "pe_align=%lu, pe_align_offset=%lu, "
 					 "adjustment=%" PRIu64 ")",
 					 pv_dev_name(pv), pv->pe_start,
@@ -1414,6 +1436,7 @@
 					  pv->pe_start -= pv->pe_align - adjustment :
 					  pv->pe_start),
 					 pv->pe_align, pv->pe_align_offset, adjustment);
+			}
 		}
 	}
 	if (pv->pe_start >= pv->size) {
@@ -1422,7 +1445,7 @@
 		return 0;
 	}
 
- preserve_pe_start:
+	/* FIXME: preserve_pe_start: */
 	if (!add_da
 	    (NULL, &info->das, pv->pe_start << SECTOR_SHIFT, UINT64_C(0)))
 		return_0;
@@ -1635,7 +1658,7 @@
 
 /* pvmetadatasize in sectors */
 /*
- * pe_start policy:
+ * pe_start goal: FIXME -- reality of .pv_write complexity undermines this goal
  * - In cases where a pre-existing pe_start is provided (pvcreate --restorefile
  *   and vgconvert): pe_start must not be changed (so pv->pe_start = pe_start).
  * - In cases where pe_start is 0: leave pv->pe_start as 0 and defer the
@@ -1758,6 +1781,18 @@
 			return 0;
 		}
 
+		/*
+		 * This initialization has a side-effect of allowing
+		 * orphaned PVs to be created with the proper alignment.
+		 * Setting pv->pe_start here circumvents .pv_write's
+		 * "pvcreate on PV without prior pvremove" retreival of
+		 * the PV's previous pe_start.
+		 * - Without this you get actual != expected pe_start
+		 *   failures in the testsuite.
+		 */
+		if (!pe_start && pv->pe_start < pv->pe_align)
+			pv->pe_start = pv->pe_align;
+
 		if (extent_count)
 			pe_end = pe_start + extent_count * extent_size - 1;
 		if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-07-30 18:40 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2009-07-30 18:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-07-30 18:40:22

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Revert 'preserve_pe_start' related code in _text_pv_setup
	
	If pv_setup was given a non-zero pe_start it would short-circuit
	establishing a default pv->pe_align.  pv->pe_align=0 would result
	in a divide by zero in _mda_setup().  'vgconvert -M2 $vgname' hit this.
	
	.pv_write still properly preserves pe_start if it was supplied.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1216&r2=1.1217
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112

--- LVM2/WHATS_NEW	2009/07/30 17:45:28	1.1216
+++ LVM2/WHATS_NEW	2009/07/30 18:40:22	1.1217
@@ -1,7 +1,7 @@
 Version 2.02.51 - 
 ================================
   Add --dataalignmentoffset to pvcreate to shift start of aligned data area.
-  Preserve pe_start in .pv_setup and .pv_write if pe_start was supplied.
+  Preserve pe_start in .pv_write if pe_start was supplied.
   Fix _mda_setup() to not check first mda's size before pe_align rounding.
   Formalize pe_start policy as split between .pv_setup and .pv_write.
   Document -I option of clvmd in the man page.
--- LVM2/lib/format_text/format-text.c	2009/07/30 17:45:29	1.111
+++ LVM2/lib/format_text/format-text.c	2009/07/30 18:40:22	1.112
@@ -1735,10 +1735,8 @@
 		/* FIXME Default from config file? vgextend cmdline flag? */
 		pv->status |= ALLOCATABLE_PV;
 	} else {
-		if (pe_start) {
+		if (pe_start)
 			pv->pe_start = pe_start;
-			goto preserve_pe_start;
-		}
 
 		if (!data_alignment)
 			data_alignment = find_config_tree_int(pv->fmt->cmd,
@@ -1760,7 +1758,6 @@
 			return 0;
 		}
 
-	preserve_pe_start:
 		if (extent_count)
 			pe_end = pe_start + extent_count * extent_size - 1;
 		if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-07-30 17:42 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2009-07-30 17:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-07-30 17:42:34

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Preserve pe_start in .pv_setup and .pv_write if pe_start was supplied.
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1214&r2=1.1215
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110

--- LVM2/WHATS_NEW	2009/07/30 17:19:31	1.1214
+++ LVM2/WHATS_NEW	2009/07/30 17:42:33	1.1215
@@ -1,5 +1,6 @@
 Version 2.02.51 - 
 ================================
+  Preserve pe_start in .pv_setup and .pv_write if pe_start was supplied.
   Fix _mda_setup() to not check first mda's size before pe_align rounding.
   Formalize pe_start policy as split between .pv_setup and .pv_write.
   Document -I option of clvmd in the man page.
--- LVM2/lib/format_text/format-text.c	2009/07/30 17:41:01	1.109
+++ LVM2/lib/format_text/format-text.c	2009/07/30 17:42:33	1.110
@@ -1368,12 +1368,17 @@
 	else
 		dm_list_init(&info->das);
 
+	if (pv->pe_start) {
+		log_very_verbose("%s: preserving pe_start=%lu",
+				 pv_dev_name(pv), pv->pe_start);
+		goto preserve_pe_start;
+	}
+
 	/*
 	 * If pe_start is still unset, set it to first aligned
 	 * sector after any metadata areas that begin before pe_start.
 	 */
-	if (!pv->pe_start)
-		pv->pe_start = pv->pe_align;
+	pv->pe_start = pv->pe_align;
 	dm_list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if (pv->dev == mdac->area.dev &&
@@ -1389,6 +1394,8 @@
 				pv->pe_start += pv->pe_align - adjustment;
 		}
 	}
+
+ preserve_pe_start:
 	if (!add_da
 	    (NULL, &info->das, pv->pe_start << SECTOR_SHIFT, UINT64_C(0)))
 		return_0;
@@ -1700,8 +1707,10 @@
 		/* FIXME Default from config file? vgextend cmdline flag? */
 		pv->status |= ALLOCATABLE_PV;
 	} else {
-		if (pe_start)
+		if (pe_start) {
 			pv->pe_start = pe_start;
+			goto preserve_pe_start;
+		}
 
 		if (!data_alignment)
 			data_alignment = find_config_tree_int(pv->fmt->cmd,
@@ -1714,6 +1723,7 @@
 				 "%lu sectors (requested %lu sectors)",
 				 pv_dev_name(pv), pv->pe_align, data_alignment);
 
+	preserve_pe_start:
 		if (extent_count)
 			pe_end = pe_start + extent_count * extent_size - 1;
 		if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-07-30 17:19 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2009-07-30 17:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-07-30 17:19:31

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix _mda_setup() to not check first mda's size before pe_align rounding.
	
	Without this fix rounding the end of the first mda to a pe_align
	boundary could silently exceed the disk_size.
	
	Final 'if (start1 + mda_size1 > disk_size)' block serves as a safety
	net.
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1213&r2=1.1214
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108

--- LVM2/WHATS_NEW	2009/07/30 17:18:03	1.1213
+++ LVM2/WHATS_NEW	2009/07/30 17:19:31	1.1214
@@ -1,5 +1,6 @@
 Version 2.02.51 - 
 ================================
+  Fix _mda_setup() to not check first mda's size before pe_align rounding.
   Formalize pe_start policy as split between .pv_setup and .pv_write.
   Document -I option of clvmd in the man page.
   Fix configure script to handle multiple clvmd selections.
--- LVM2/lib/format_text/format-text.c	2009/07/30 17:18:08	1.107
+++ LVM2/lib/format_text/format-text.c	2009/07/30 17:19:31	1.108
@@ -1214,6 +1214,15 @@
 			start1 += (pagesize - mda_adjustment);
 	}
 
+	/* Round up to pe_align boundary */
+	mda_adjustment = (mda_size1 + start1) % alignment;
+	if (mda_adjustment) {
+		mda_size1 += (alignment - mda_adjustment);
+		/* Revert if it's now too large */
+		if (start1 + mda_size1 > disk_size)
+			mda_size1 -= (alignment - mda_adjustment);
+	}
+
 	/* Ensure it's not going to be bigger than the disk! */
 	if (start1 + mda_size1 > disk_size) {
 		log_warn("WARNING: metadata area fills disk leaving no "
@@ -1221,15 +1230,19 @@
 		/* Leave some free space for rounding */
 		/* Avoid empty data area as could cause tools problems */
 		mda_size1 = disk_size - start1 - alignment * 2;
+		if (start1 + mda_size1 > disk_size) {
+			log_error("Insufficient space for first mda on %s",
+				  pv_dev_name(pv));
+			return 0;
+		}
+		/* Round up to pe_align boundary */
+		mda_adjustment = (mda_size1 + start1) % alignment;
+		if (mda_adjustment)
+			mda_size1 += (alignment - mda_adjustment);
 		/* Only have 1 mda in this case */
 		pvmetadatacopies = 1;
 	}
 
-	/* Round up to pe_align() boundary */
-	mda_adjustment = (mda_size1 + start1) % alignment;
-	if (mda_adjustment)
-		mda_size1 += (alignment - mda_adjustment);
-
 	/* If we already have PEs, avoid overlap */
 	if (pe_start || pe_end) {
 		if (pe_start <= start1)


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-07-30 17:18 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2009-07-30 17:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-07-30 17:18:08

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Formalize pe_start policy as split between .pv_setup and .pv_write.
	
	Document existing pe_start policy.
	Fix issue in _text_pv_setup() where existing pe_start case could have
	the pv->pe_start set to pv->pe_align even though pe_start shouldn't ever
	change.
	
	vgconvert and pvcreate have a facility to preserve the existing start
	of the on-disk data extents, known as pe_start.
	They indicate this by passing the existing value to the pvsetup function
	which must preserve it.
	
	This patch avoids one particular case where the value could get
	changed incorrectly now that the alignment settings are configurable.
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1212&r2=1.1213
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107

--- LVM2/WHATS_NEW	2009/07/30 13:32:38	1.1212
+++ LVM2/WHATS_NEW	2009/07/30 17:18:03	1.1213
@@ -1,5 +1,6 @@
 Version 2.02.51 - 
 ================================
+  Formalize pe_start policy as split between .pv_setup and .pv_write.
   Document -I option of clvmd in the man page.
   Fix configure script to handle multiple clvmd selections.
   Fix lvm2app.pc installation filename.
--- LVM2/lib/format_text/format-text.c	2009/07/15 20:02:47	1.106
+++ LVM2/lib/format_text/format-text.c	2009/07/30 17:18:08	1.107
@@ -1595,6 +1595,13 @@
 };
 
 /* pvmetadatasize in sectors */
+/*
+ * pe_start policy:
+ * - In cases where a pre-existing pe_start is provided (pvcreate --restorefile
+ *   and vgconvert): pe_start must not be changed (so pv->pe_start = pe_start).
+ * - In cases where pe_start is 0: leave pv->pe_start as 0 and defer the
+ *   setting of pv->pe_start to .pv_write
+ */
 static int _text_pv_setup(const struct format_type *fmt,
 		     uint64_t pe_start, uint32_t extent_count,
 		     uint32_t extent_size, unsigned long data_alignment,
@@ -1702,9 +1709,6 @@
 				 "%lu sectors (requested %lu sectors)",
 				 pv_dev_name(pv), pv->pe_align, data_alignment);
 
-		if (pv->pe_start < pv->pe_align)
-			pv->pe_start = pv->pe_align;
-
 		if (extent_count)
 			pe_end = pe_start + extent_count * extent_size - 1;
 		if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-03-23 21:13 taka
  0 siblings, 0 replies; 17+ messages in thread
From: taka @ 2009-03-23 21:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	taka@sourceware.org	2009-03-23 21:13:38

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix error message when adding metadata directory to internal list fails.
	
	Author: Takahiro Yasui <tyasui@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1067&r2=1.1068
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104

--- LVM2/WHATS_NEW	2009/03/17 13:59:56	1.1067
+++ LVM2/WHATS_NEW	2009/03/23 21:13:37	1.1068
@@ -7,6 +7,7 @@
   Rename liblvm.a to liblvm-internal.a and build new application library.
   Flush memory pool and fix locking in clvmd refresh and backup command.
   Fix unlocks in clvmd-corosync. Broken in 2.02.45.
+  Fix error message when adding metadata directory to internal list fails.
 
 Version 2.02.45 - 3rd March 2009
 ================================
--- LVM2/lib/format_text/format-text.c	2009/03/03 16:35:34	1.103
+++ LVM2/lib/format_text/format-text.c	2009/03/23 21:13:37	1.104
@@ -1996,8 +1996,8 @@
 			}
 
 			if (!_add_dir(cv->v.str, &mda_lists->dirs)) {
-				log_error("Failed to add %s to internal device "
-					  "cache", cv->v.str);
+				log_error("Failed to add %s to text format "
+					  "metadata directory list ", cv->v.str);
 				goto err;
 			}
 		}


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2009-03-03 16:35 mbroz
  0 siblings, 0 replies; 17+ messages in thread
From: mbroz @ 2009-03-03 16:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-03-03 16:35:35

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	vgname_from_mda now tries to parse for vgname even
	if rlocn not defined (there is no metadata area).
	
	In most cases it fails in validate_name(),
	unfortunately there are situatuions, when
	validate_name is ok and later code fails with
	checksum error.
	
	Reproducer:
	
	# dd if=/dev/zero of=/dev/loop0
	
	# pvcreate --metadatasize 637k /dev/loop0
	Physical volume "/dev/loop0" successfully created
	
	# pvs /dev/loop0
	/dev/loop0: Checksum error
	PV         VG   Fmt  Attr PSize PFree
	/dev/loop0      lvm2 --   1.00M 1.00M
	
	Signed-off-by: Milan Broz <mbroz@redhat.com>
	
	-

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1059&r2=1.1060
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103

--- LVM2/WHATS_NEW	2009/03/03 13:03:03	1.1059
+++ LVM2/WHATS_NEW	2009/03/03 16:35:32	1.1060
@@ -1,5 +1,6 @@
 Version 2.02.45 - 3rd March 2009
 ================================
+  Avoid scanning empty metadata areas for VG names.
   Attempt proper clean up in child before executing new binary in exec_cmd().
   Do not scan devices if reporting only attributes from PV label.
   Use pkgconfig to obtain corosync library details during configuration.
--- LVM2/lib/format_text/format-text.c	2009/02/25 23:29:06	1.102
+++ LVM2/lib/format_text/format-text.c	2009/03/03 16:35:34	1.103
@@ -1061,6 +1061,12 @@
 	/* FIXME Cope with returning a list */
 	rlocn = mdah->raw_locns;
 
+	/*
+	 * If no valid offset, do not try to search for vgname
+	 */
+	if (!rlocn->offset)
+		goto out;
+
 	/* Do quick check for a vgname */
 	if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
 		      NAME_LEN, buf))


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2008-10-17  0:55 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2008-10-17  0:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-10-17 00:55:46

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Avoid overwriting in-use on-disk text metadata by forgetting MDA_HEADER_SIZE. (Edward Allcutt)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.974&r2=1.975
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97

--- LVM2/WHATS_NEW	2008/10/13 12:06:30	1.974
+++ LVM2/WHATS_NEW	2008/10/17 00:55:46	1.975
@@ -1,5 +1,6 @@
 Version 2.02.41 -
 =====================================
+  Avoid overwriting in-use on-disk text metadata by forgetting MDA_HEADER_SIZE.
   Fix snapshot monitoring library to not cancel monitoring invalid snapshot.
   Generate man pages from templates and include version.
   Add usrlibdir and usrsbindir to configure.
--- LVM2/lib/format_text/format-text.c	2008/09/30 20:37:52	1.96
+++ LVM2/lib/format_text/format-text.c	2008/10/17 00:55:46	1.97
@@ -513,7 +513,7 @@
 	struct mda_header *mdah;
 	struct pv_list *pvl;
 	int r = 0;
-	uint32_t new_wrap = 0, old_wrap = 0;
+       uint64_t new_wrap = 0, old_wrap = 0, new_end;
 	int found = 0;
 	int noprecommit = 0;
 
@@ -552,10 +552,11 @@
 	if (rlocn && (rlocn->offset + rlocn->size > mdah->size))
 		old_wrap = (rlocn->offset + rlocn->size) - mdah->size;
 
+	new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE :
+			    mdac->rlocn.offset + mdac->rlocn.size;
+
 	if ((new_wrap && old_wrap) ||
-	    (rlocn && ((new_wrap > rlocn->offset) ||
-		       (old_wrap && (mdac->rlocn.offset + mdac->rlocn.size >
-				     rlocn->offset)))) ||
+	    (rlocn && (new_wrap || old_wrap) && (new_end > rlocn->offset)) ||
 	    (mdac->rlocn.size >= mdah->size)) {
 		log_error("VG %s metadata too large for circular buffer",
 			  vg->name);
@@ -573,7 +574,7 @@
 		goto_out;
 
 	if (new_wrap) {
-		log_debug("Writing metadata to %s at %" PRIu64 " len %" PRIu32,
+               log_debug("Writing metadata to %s at %" PRIu64 " len %" PRIu64,
 			  dev_name(mdac->area.dev), mdac->area.start +
 			  MDA_HEADER_SIZE, new_wrap);
 
@@ -592,7 +593,7 @@
 		mdac->rlocn.checksum = calc_crc(mdac->rlocn.checksum,
 						fidtc->raw_metadata_buf +
 						mdac->rlocn.size -
-						new_wrap, new_wrap);
+						new_wrap, (uint32_t) new_wrap);
 
 	r = 1;
 
@@ -601,10 +602,10 @@
 		if (!dev_close(mdac->area.dev))
 			stack;
 
-                if (fidtc->raw_metadata_buf) {
-                        dm_free(fidtc->raw_metadata_buf);
-                        fidtc->raw_metadata_buf = NULL;
-                }
+		if (fidtc->raw_metadata_buf) {
+			dm_free(fidtc->raw_metadata_buf);
+			fidtc->raw_metadata_buf = NULL;
+		}
 	}
 
 	return r;


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2008-09-30 20:37 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2008-09-30 20:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-09-30 20:37:53

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Free text metadata buffer after a failure writing it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.968&r2=1.969
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96

--- LVM2/WHATS_NEW	2008/09/29 09:59:10	1.968
+++ LVM2/WHATS_NEW	2008/09/30 20:37:52	1.969
@@ -1,5 +1,6 @@
 Version 2.02.41 -
 =====================================
+  Free text metadata buffer after a failure writing it.
   Fix misleading error message when there is no allocatable extents in VG.
   Fix handling of PVs which reappeared with old metadata version.
   Fix mirror DSO to call vgreduce with proper parameters.
--- LVM2/lib/format_text/format-text.c	2008/09/19 04:27:26	1.95
+++ LVM2/lib/format_text/format-text.c	2008/09/30 20:37:52	1.96
@@ -597,8 +597,15 @@
 	r = 1;
 
       out:
-	if (!r && !dev_close(mdac->area.dev))
-		stack;
+	if (!r) {
+		if (!dev_close(mdac->area.dev))
+			stack;
+
+                if (fidtc->raw_metadata_buf) {
+                        dm_free(fidtc->raw_metadata_buf);
+                        fidtc->raw_metadata_buf = NULL;
+                }
+	}
 
 	return r;
 }


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2008-08-16  9:46 mbroz
  0 siblings, 0 replies; 17+ messages in thread
From: mbroz @ 2008-08-16  9:46 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2008-08-16 09:46:55

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Fix allocation bug in text metadata format write error path.
	
	Function _text_pv_write doesn't use memory pool but static buffer,
	call dm_pool_free in error path in _raw_write_mda_header is wrong.
	
	Move pool free only to path where is the memory pool used.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.946&r2=1.947
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94

--- LVM2/WHATS_NEW	2008/08/13 12:44:23	1.946
+++ LVM2/WHATS_NEW	2008/08/16 09:46:55	1.947
@@ -1,5 +1,6 @@
 Version 2.02.40 - 
 ================================
+  Fix allocation bug in text metadata format write error path.
   Fix vgcfgbackup to properly check filename if template is used.
   configure aborts if lcov or genhtml are missing with --enable-profiling
   vgremove tries to remove lv snapshot first.
--- LVM2/lib/format_text/format-text.c	2008/07/31 13:07:01	1.93
+++ LVM2/lib/format_text/format-text.c	2008/08/16 09:46:55	1.94
@@ -346,10 +346,8 @@
 					     MDA_HEADER_SIZE -
 					     sizeof(mdah->checksum_xl)));
 
-	if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
-		dm_pool_free(fmt->cmd->mem, mdah);
+	if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah))
 		return_0;
-	}
 
 	return 1;
 }
@@ -670,6 +668,7 @@
 
 	if (!_raw_write_mda_header(fid->fmt, mdac->area.dev, mdac->area.start,
 				   mdah)) {
+		dm_pool_free(fid->fmt->cmd->mem, mdah);
 		log_error("Failed to write metadata area header");
 		goto out;
 	}
@@ -752,6 +751,7 @@
 
 	if (!_raw_write_mda_header(fid->fmt, mdac->area.dev, mdac->area.start,
 				   mdah)) {
+		dm_pool_free(fid->fmt->cmd->mem, mdah);
 		log_error("Failed to write metadata area header");
 		goto out;
 	}


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c
@ 2008-07-31 10:50 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2008-07-31 10:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-07-31 10:50:19

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 

Log message:
	Refactor _text_pv_read and always return mda list if requested.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.936&r2=1.937
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92

--- LVM2/WHATS_NEW	2008/07/24 15:39:47	1.936
+++ LVM2/WHATS_NEW	2008/07/31 10:50:12	1.937
@@ -1,5 +1,6 @@
 Version 2.02.40 - 
 ================================
+  Refactor _text_pv_read and always return mda list if requested.
   Fix configure to work w/o readline unless --enable-readline used. (2.02.39)
   Remove is_lvm_partition template which has not yet been coded.
   Refactor pvcreate to separate parameter parsing from validation logic.
--- LVM2/lib/format_text/format-text.c	2008/07/16 21:32:38	1.91
+++ LVM2/lib/format_text/format-text.c	2008/07/31 10:50:18	1.92
@@ -1396,43 +1396,33 @@
 	return 1;
 }
 
-static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
-		    struct physical_volume *pv, struct list *mdas)
+static int _get_pv_if_in_vg(struct lvmcache_info *info,
+			    struct physical_volume *pv)
 {
-	struct label *label;
-	struct device *dev;
-	struct lvmcache_info *info;
-	struct metadata_area *mda, *mda_new;
-	struct mda_context *mdac, *mdac_new;
-	struct data_area_list *da;
+	if (info->vginfo && info->vginfo->vgname &&
+	    !is_orphan_vg(info->vginfo->vgname) &&
+	    get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname,
+				 info->vginfo->vgid, info->dev->pvid, pv))
+		return 1;
 
-	if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
-		return_0;
+	return 0;
+}
 
-	/* FIXME Optimise out repeated reading when cache lock held */
-	if (!(label_read(dev, &label, UINT64_C(0))))
-		return_0;
-	info = (struct lvmcache_info *) label->info;
+static int _populate_pv_fields(struct lvmcache_info *info,
+			       struct physical_volume *pv)
+{
+	struct data_area_list *da;
 
 	/* Have we already cached vgname? */
-	if (info->vginfo && info->vginfo->vgname &&
-	    !is_orphan_vg(info->vginfo->vgname) &&
-	    get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname,
-				 info->vginfo->vgid, info->dev->pvid, pv)) {
+	if (_get_pv_if_in_vg(info, pv))
 		return 1;
-	}
 
 	/* Perform full scan (just the first time) and try again */
 	if (!memlock() && !full_scan_done()) {
-		lvmcache_label_scan(fmt->cmd, 2);
+		lvmcache_label_scan(info->fmt->cmd, 2);
 
-		if (info->vginfo && info->vginfo->vgname &&
-		    !is_orphan_vg(info->vginfo->vgname) &&
-		    get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname,
-					 info->vginfo->vgid,
-					 info->dev->pvid, pv)) {
+		if (_get_pv_if_in_vg(info, pv))
 			return 1;
-		}
 	}
 
 	/* Orphan */
@@ -1445,13 +1435,35 @@
 	/* Currently only support exactly one data area */
 	if (list_size(&info->das) != 1) {
 		log_error("Must be exactly one data area (found %d) on PV %s",
-			  list_size(&info->das), dev_name(dev));
+			  list_size(&info->das), dev_name(info->dev));
 		return 0;
 	}
 
 	list_iterate_items(da, &info->das)
 		pv->pe_start = da->disk_locn.offset >> SECTOR_SHIFT;
 
+	return 1;
+}
+
+static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
+		    struct physical_volume *pv, struct list *mdas)
+{
+	struct label *label;
+	struct device *dev;
+	struct lvmcache_info *info;
+	struct metadata_area *mda, *mda_new;
+	struct mda_context *mdac, *mdac_new;
+
+	if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter)))
+		return_0;
+
+	if (!(label_read(dev, &label, UINT64_C(0))))
+		return_0;
+	info = (struct lvmcache_info *) label->info;
+
+	if (!_populate_pv_fields(info, pv))
+		return 0;
+
 	if (!mdas)
 		return 1;
 


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

end of thread, other threads:[~2012-02-13 11:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26  9:13 LVM2 ./WHATS_NEW lib/format_text/format-text.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-02-13 11:09 zkabelac
2011-08-29 13:37 prajnoha
2011-02-03  1:41 zkabelac
2010-09-30 14:12 prajnoha
2010-06-01 12:08 prajnoha
2009-07-30 21:15 snitzer
2009-07-30 18:40 snitzer
2009-07-30 17:42 snitzer
2009-07-30 17:19 snitzer
2009-07-30 17:18 snitzer
2009-03-23 21:13 taka
2009-03-03 16:35 mbroz
2008-10-17  0:55 agk
2008-09-30 20:37 agk
2008-08-16  9:46 mbroz
2008-07-31 10:50 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).