public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2005-01-20 18:11 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2005-01-20 18:11 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-01-20 18:11:53

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c snapshot_manip.c 
	lib/uuid       : uuid.c 
	tools          : pvchange.c vgchange.c 

Log message:
	Always fail if random id generation fails.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.159&r2=1.160
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/snapshot_manip.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/uuid/uuid.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-05-09 12:31:00

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	test/shell     : pvcreate-operation.sh 

Log message:
	Fix division by zero if PV with zero PE count is used during vgcfgrestore.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2399&r2=1.2400
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.200&r2=1.201
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/shell/pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3

--- LVM2/WHATS_NEW	2012/05/09 12:17:06	1.2399
+++ LVM2/WHATS_NEW	2012/05/09 12:30:56	1.2400
@@ -1,5 +1,6 @@
 Version 2.02.96 - 
 ================================
+  Fix division by zero if PV with zero PE count is used during vgcfgrestore.
   Add initial support for thin pool lvconvert.
   Fix lvrename for thin volumes (regression in for_each_sub_lv() 2.02.89).
   Fix up-convert when mirror activation is controled by volume_list and tags.
--- LVM2/lib/format_text/format-text.c	2012/04/10 12:26:27	1.200
+++ LVM2/lib/format_text/format-text.c	2012/05/09 12:30:59	1.201
@@ -1713,7 +1713,7 @@
 			   pv->pe_start + size_reduction;
 
 	/* Recalculate number of extents that will fit */
-	if (!pv->pe_count) {
+	if (!pv->pe_count && vg->extent_size) {
 		pe_count = (pv->size - pv->pe_start - size_reduction) /
 			   vg->extent_size;
 		if (pe_count > UINT32_MAX) {
--- LVM2/test/shell/pvcreate-operation.sh	2012/03/16 13:00:06	1.2
+++ LVM2/test/shell/pvcreate-operation.sh	2012/05/09 12:30:59	1.3
@@ -111,6 +111,14 @@
 vgcfgbackup -f $backupfile
 not pvcreate --uuid $uuid2 --restorefile $backupfile "$dev2"
 
+# vgcfgrestore of a VG containing a PV with zero PEs (bz #820116)
+# (use case: one PV in a VG used solely to keep metadata)
+size_mb=$(($(blockdev --getsz $dev1) / 2048))
+pvcreate --metadatasize $size_mb $dev1
+vgcreate $vg1 $dev1
+vgcfgbackup -f $backupfile
+vgcfgrestore -f $backupfile $vg1
+
 # pvcreate wipes swap signature when forced
 dd if=/dev/zero of="$dev1" bs=1024 count=64
 mkswap "$dev1"


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2011-04-21 13:13 zkabelac
  0 siblings, 0 replies; 16+ messages in thread
From: zkabelac @ 2011-04-21 13:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-04-21 13:13:41

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c 
Added files:
	test           : t-pv-duplicate.sh 

Log message:
	Fix use of released vgname and vgid
	
	Avoid using of already released memory when duplicated MDA is found.
	
	As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy
	of the vgname and vgid on the stack as vginfo may dissapear and code was
	then accessing garbage in memory.
	
	i.e.  pvs  /dev/loop0
	(when /dev/loop0 and /dev/loop1 has same MDA content)
	
	Invalid read of size 1
	at 0x523C986: dm_hash_lookup (hash.c:325)
	by 0x440C8C: vginfo_from_vgname (lvmcache.c:399)
	by 0x4605C0: _create_vg_text_instance (format-text.c:1882)
	by 0x46140D: _text_create_text_instance (format-text.c:2243)
	by 0x47EB49: _vg_read (metadata.c:2887)
	by 0x47FBD8: vg_read_internal (metadata.c:3231)
	by 0x477594: get_pv_from_vg_by_id (metadata.c:344)
	by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400)
	by 0x45F0B9: _populate_pv_fields (format-text.c:1414)
	by 0x45F40F: _text_pv_read (format-text.c:1493)
	by 0x480431: _pv_read (metadata.c:3500)
	by 0x4802B2: pv_read (metadata.c:3462)
	Address 0x652ab80 is 0 bytes inside a block of size 4 free'd
	at 0x4C2756E: free (vg_replace_malloc.c:366)
	by 0x442277: _free_vginfo (lvmcache.c:963)
	by 0x44235E: _drop_vginfo (lvmcache.c:992)
	by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165)
	by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358)
	by 0x443C07: lvmcache_add (lvmcache.c:1492)
	by 0x46588C: _text_read (text_label.c:271)
	by 0x466A65: label_read (label.c:289)
	by 0x4413FC: lvmcache_label_scan (lvmcache.c:635)
	by 0x4605AD: _create_vg_text_instance (format-text.c:1881)
	by 0x46140D: _text_create_text_instance (format-text.c:2243)
	by 0x47EB49: _vg_read (metadata.c:2887)
	
	Add testing script

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1972&r2=1.1973
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.178&r2=1.179
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.454&r2=1.455
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pv-duplicate.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1

--- LVM2/WHATS_NEW	2011/04/13 18:26:39	1.1972
+++ LVM2/WHATS_NEW	2011/04/21 13:13:40	1.1973
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fix use of released memory when duplicate PV is found.
   Add "devices/issue_discards" to lvm.conf.
   Issue discards on lvremove, lvreduce, etc if enabled and supported.
   Fix incorrect tests for dm_snprintf() failure.
--- LVM2/lib/format_text/format-text.c	2011/03/11 15:10:17	1.178
+++ LVM2/lib/format_text/format-text.c	2011/04/21 13:13:40	1.179
@@ -1395,11 +1395,23 @@
 static int _get_pv_if_in_vg(struct lvmcache_info *info,
 			    struct physical_volume *pv)
 {
+	char vgname[NAME_LEN + 1];
+	char vgid[ID_LEN + 1];
+
 	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;
+	    !is_orphan_vg(info->vginfo->vgname)) {
+		/*
+		 * get_pv_from_vg_by_id() may call
+		 * lvmcache_label_scan() and drop cached
+		 * vginfo so make a local copy of string.
+		 */
+		strcpy(vgname, info->vginfo->vgname);
+		memcpy(vgid, info->vginfo->vgid, sizeof(vgid));
+
+		if (get_pv_from_vg_by_id(info->fmt, vgname, vgid,
+					 info->dev->pvid, pv))
+			return 1;
+	}
 
 	return 0;
 }
--- LVM2/lib/metadata/metadata.c	2011/04/08 14:40:20	1.454
+++ LVM2/lib/metadata/metadata.c	2011/04/21 13:13:40	1.455
@@ -2771,6 +2771,9 @@
  * If precommitted is set, use precommitted metadata if present.
  *
  * Either of vgname or vgid may be NULL.
+ *
+ * Note: vginfo structs must not be held or used as parameters
+ *       across the call to this function.
  */
 static struct volume_group *_vg_read(struct cmd_context *cmd,
 				     const char *vgname,
/cvs/lvm2/LVM2/test/t-pv-duplicate.sh,v  -->  standard output
revision 1.1
--- LVM2/test/t-pv-duplicate.sh
+++ -	2011-04-21 13:13:42.016714000 +0000
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+# 'Exercise duplicate metadata diagnostics'
+
+. lib/test
+
+aux prepare_devs 3
+
+vgcreate -c n --metadatasize 128k $vg1 $dev1
+
+# copy mda
+dd if=$dev1 of=$dev2 bs=256K count=1
+dd if=$dev1 of=$dev3 bs=256K count=1
+
+pvs $dev1
+vgs $vg1


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-02-28 13:19:03

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	tools          : pvchange.c pvresize.c vgconvert.c vgreduce.c 

Log message:
	Allow non-orphan PVs with two metadata areas to be resized.
	
	We allow writing non-orphan PVs only for resize now. The "orphan PV" assert
	in pv_write fn uses the "allow_non_orphan" parameter to control this assert.
	However, we should find a more elaborate solution so we can remove this
	restriction altogether (pv_write together with vg_write is not atomic, we
	need to find a safe mechanism so there's an easy revert possible in case of
	an error).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1928&r2=1.1929
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.169&r2=1.170
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.183&r2=1.184
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.436&r2=1.437
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.239&r2=1.240
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108

--- LVM2/WHATS_NEW	2011/02/27 01:16:52	1.1928
+++ LVM2/WHATS_NEW	2011/02/28 13:19:02	1.1929
@@ -5,8 +5,8 @@
   Improve normal allocation algorithm to include clinging to existing areas.
   Add allocation/maximise_cling & mirror_logs_require_separate_pvs to lvm.conf.
   Fix metadata balance code to work with recent changes in metadata handling.
-  Add old_uuid field to physical_volume and fix pvchange -u for recent changes.
-  Allow pvresize on a PV with two metadata areas (for PVs not in a VG).
+  Add old_id field to physical_volume and fix pvchange -u for recent changes.
+  Allow pvresize on a PV with two metadata areas.
   Change pvcreate to use new metadata handling interface.
   Restructure existing pv_setup and pv_write fn, add pv_initialise fn.
   Add internal interface to support adding and removing metadata areas.
--- LVM2/lib/format_text/format-text.c	2011/02/25 14:08:55	1.169
+++ LVM2/lib/format_text/format-text.c	2011/02/28 13:19:02	1.170
@@ -1273,7 +1273,8 @@
 
 	/* Add a new cache entry with PV info or update existing one. */
 	if (!(info = lvmcache_add(fmt->labeller, (const char *) &pv->id,
-			pv->dev, FMT_TEXT_ORPHAN_VG_NAME, NULL, 0)))
+		      pv->dev, pv->vg ? pv->vg->name : FMT_TEXT_ORPHAN_VG_NAME,
+		      NULL, 0)))
 		return_0;
 
 	label = info->label;
@@ -2161,17 +2162,6 @@
 	/* If there's an mda at the end, move it to a new position. */
 	if ((mda = fid_get_mda_indexed(fid, pvid, ID_LEN, 1)) &&
 	    (mdac = mda->metadata_locn)) {
-		/*
-		 * FIXME: Remove this restriction - we need to
-		 *        allow writing PV labels on non-orphan VGs
-		 *        for this to work correctly.
-		 */
-		if (vg) {
-			log_error("Resizing a PV with two metadata areas "
-				  "that is part of a VG is not supported.");
-			return 0;
-		}
-
 		/* FIXME: Maybe MDA0 size would be better? */
 		mda_size = mdac->area.size >> SECTOR_SHIFT;
 		mda_ignored = mda_is_ignored(mda);
--- LVM2/lib/metadata/metadata-exported.h	2011/02/25 14:02:54	1.183
+++ LVM2/lib/metadata/metadata-exported.h	2011/02/28 13:19:02	1.184
@@ -384,7 +384,7 @@
 struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal);
 int scan_vgs_for_pvs(struct cmd_context *cmd, int warnings);
 
-int pv_write(struct cmd_context *cmd, struct physical_volume *pv);
+int pv_write(struct cmd_context *cmd, struct physical_volume *pv, int allow_non_orphan);
 int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
 	    const char *pv_name);
 int move_pvs_used_by_lv(struct volume_group *vg_from,
--- LVM2/lib/metadata/metadata.c	2011/02/25 14:08:55	1.436
+++ LVM2/lib/metadata/metadata.c	2011/02/28 13:19:02	1.437
@@ -586,7 +586,7 @@
 		}
 
 		/* FIXME Write to same sector label was read from */
-		if (!pv_write(vg->cmd, pv)) {
+		if (!pv_write(vg->cmd, pv, 0)) {
 			log_error("Failed to remove physical volume \"%s\""
 				  " from volume group \"%s\"",
 				  pv_dev_name(pv), vg->name);
@@ -1511,7 +1511,7 @@
 	log_very_verbose("Writing physical volume data to disk \"%s\"",
 			 pv_name);
 
-	if (!(pv_write(cmd, pv))) {
+	if (!(pv_write(cmd, pv, 0))) {
 		log_error("Failed to write physical volume \"%s\"", pv_name);
 		goto error;
 	}
@@ -3536,7 +3536,7 @@
 }
 
 int pv_write(struct cmd_context *cmd __attribute__((unused)),
-	     struct physical_volume *pv)
+	     struct physical_volume *pv, int allow_non_orphan)
 {
 	if (!pv->fmt->ops->pv_write) {
 		log_error("Format does not support writing physical volumes");
@@ -3549,7 +3549,8 @@
 	 *        to provide some revert mechanism since PV label together
 	 *        with VG metadata write is not atomic.
 	 */
-	if (!is_orphan_vg(pv->vg_name) || pv->pe_alloc_count) {
+	if (!allow_non_orphan &&
+	    (!is_orphan_vg(pv->vg_name) || pv->pe_alloc_count)) {
 		log_error("Assertion failed: can't _pv_write non-orphan PV "
 			  "(in VG %s)", pv->vg_name);
 		return 0;
@@ -3574,7 +3575,7 @@
 		return 0;
 	}
 
-	if (!pv_write(cmd, pv)) {
+	if (!pv_write(cmd, pv, 0)) {
 		log_error("Failed to clear metadata from physical "
 			  "volume \"%s\" after removal from \"%s\"",
 			  pv_dev_name(pv), old_vg_name);
--- LVM2/lib/metadata/metadata.h	2011/02/21 12:27:26	1.239
+++ LVM2/lib/metadata/metadata.h	2011/02/28 13:19:02	1.240
@@ -192,6 +192,7 @@
 void mda_set_ignored(struct metadata_area *mda, unsigned ignored);
 unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2);
 void vg_set_fid(struct volume_group *vg, struct format_instance *fid);
+/* FIXME: Add generic interface for mda counts based on given key. */
 int fid_add_mda(struct format_instance *fid, struct metadata_area *mda,
 		const char *key, size_t key_len, const unsigned sub_key);
 int fid_add_mdas(struct format_instance *fid, struct dm_list *mdas,
--- LVM2/tools/pvchange.c	2011/02/21 12:31:28	1.90
+++ LVM2/tools/pvchange.c	2011/02/28 13:19:03	1.91
@@ -140,7 +140,7 @@
 
 			pv->vg_name = pv->fmt->orphan_vg_name;
 			pv->pe_alloc_count = 0;
-			if (!(pv_write(cmd, pv))) {
+			if (!(pv_write(cmd, pv, 0))) {
 				log_error("pv_write with new uuid failed "
 					  "for %s.", pv_name);
 				return 0;
@@ -162,7 +162,7 @@
 			return 0;
 		}
 		backup(vg);
-	} else if (!(pv_write(cmd, pv))) {
+	} else if (!(pv_write(cmd, pv, 0))) {
 		log_error("Failed to store physical volume \"%s\"",
 			  pv_name);
 		return 0;
--- LVM2/tools/pvresize.c	2011/02/21 12:27:26	1.41
+++ LVM2/tools/pvresize.c	2011/02/28 13:19:03	1.42
@@ -15,6 +15,7 @@
  */
 
 #include "tools.h"
+#include "metadata.h"
 
 struct pvresize_params {
 	uint64_t new_size;
@@ -96,6 +97,16 @@
 		goto_out;
 
 	log_verbose("Updating physical volume \"%s\"", pv_name);
+
+	/* Write PV label only if this an orphan PV or it has 2nd mda. */
+	if ((is_orphan_vg(vg_name) ||
+	    fid_get_mda_indexed(vg->fid, (const char *) &pv->id, ID_LEN, 1)) &&
+	    !pv_write(cmd, pv, 1)) {
+		log_error("Failed to store physical volume \"%s\"",
+			  pv_name);
+		goto out;
+	}
+
 	if (!is_orphan_vg(vg_name)) {
 		if (!vg_write(vg) || !vg_commit(vg)) {
 			log_error("Failed to store physical volume \"%s\" in "
@@ -103,10 +114,6 @@
 			goto out;
 		}
 		backup(vg);
-	} else if (!(pv_write(cmd, pv))) {
-		log_error("Failed to store physical volume \"%s\"",
-			  pv_name);
-		goto out;
 	}
 
 	log_print("Physical volume \"%s\" changed", pv_name);
--- LVM2/tools/vgconvert.c	2011/02/25 14:02:54	1.49
+++ LVM2/tools/vgconvert.c	2011/02/28 13:19:03	1.50
@@ -151,7 +151,7 @@
 
 		log_very_verbose("Writing physical volume data to disk \"%s\"",
 				 pv_dev_name(pv));
-		if (!(pv_write(cmd, pv))) {
+		if (!(pv_write(cmd, pv, 0))) {
 			log_error("Failed to write physical volume \"%s\"",
 				  pv_dev_name(pv));
 			log_error("Use pvcreate and vgcfgrestore to repair "
--- LVM2/tools/vgreduce.c	2011/02/21 12:26:28	1.107
+++ LVM2/tools/vgreduce.c	2011/02/28 13:19:03	1.108
@@ -438,7 +438,7 @@
 		goto bad;
 	}
 
-	if (!pv_write(cmd, pv)) {
+	if (!pv_write(cmd, pv, 0)) {
 		log_error("Failed to clear metadata from physical "
 			  "volume \"%s\" "
 			  "after removal from \"%s\"", name, vg->name);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-02-25 14:08:55

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

Log message:
	Allow only orphan PVs to be resized even with two metadata areas.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1925&r2=1.1926
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.168&r2=1.169
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.435&r2=1.436

--- LVM2/WHATS_NEW	2011/02/25 14:02:53	1.1925
+++ LVM2/WHATS_NEW	2011/02/25 14:08:54	1.1926
@@ -2,7 +2,7 @@
 ===================================
   Fix metadata balance code to work with recent changes in metadata handling.
   Add old_uuid field to physical_volume and fix pvchange -u for recent changes.
-  Allow pvresize on a PV with two metadata areas.
+  Allow pvresize on a PV with two metadata areas (for PVs not in a VG).
   Change pvcreate to use new metadata handling interface.
   Restructure existing pv_setup and pv_write fn, add pv_initialise fn.
   Add internal interface to support adding and removing metadata areas.
--- LVM2/lib/format_text/format-text.c	2011/02/25 13:59:47	1.168
+++ LVM2/lib/format_text/format-text.c	2011/02/25 14:08:55	1.169
@@ -2161,6 +2161,17 @@
 	/* If there's an mda at the end, move it to a new position. */
 	if ((mda = fid_get_mda_indexed(fid, pvid, ID_LEN, 1)) &&
 	    (mdac = mda->metadata_locn)) {
+		/*
+		 * FIXME: Remove this restriction - we need to
+		 *        allow writing PV labels on non-orphan VGs
+		 *        for this to work correctly.
+		 */
+		if (vg) {
+			log_error("Resizing a PV with two metadata areas "
+				  "that is part of a VG is not supported.");
+			return 0;
+		}
+
 		/* FIXME: Maybe MDA0 size would be better? */
 		mda_size = mdac->area.size >> SECTOR_SHIFT;
 		mda_ignored = mda_is_ignored(mda);
--- LVM2/lib/metadata/metadata.c	2011/02/25 14:02:54	1.435
+++ LVM2/lib/metadata/metadata.c	2011/02/25 14:08:55	1.436
@@ -3543,6 +3543,12 @@
 		return 0;
 	}
 
+	/*
+	 * FIXME: Try to remove this restriction. This requires checking
+	 *        that the PV and the VG are in a consistent state. We need
+	 *        to provide some revert mechanism since PV label together
+	 *        with VG metadata write is not atomic.
+	 */
 	if (!is_orphan_vg(pv->vg_name) || pv->pe_alloc_count) {
 		log_error("Assertion failed: can't _pv_write non-orphan PV "
 			  "(in VG %s)", pv->vg_name);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-05-07 12:11:51

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	test           : t-pvcreate-usage.sh 

Log message:
	Fix PV datalign when for values starting prior to MDA area.
	
	The dataalign value must always be aligned according
	to MDA area.
	The currect code checks if calculated value collides with
	MDA area but not if the value is so small that it is
	located before MDA starts.
	
	Unfortunatelly there can be also MDA in the end of the device.
	
	The patch adds simple check to avoid this miscalculation.
	Patch expects that first MDA always starts on <= pagesize boundary
	(this is true for all allowed label sector parameters).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1096&r2=1.1097
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-usage.sh.diff?cvsroot=lvm2&r1=1.8&r2=1.9

--- LVM2/WHATS_NEW	2009/04/25 01:17:59	1.1096
+++ LVM2/WHATS_NEW	2009/05/07 12:11:50	1.1097
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Fix PV datalignment for values starting prior to MDA area. (2.02.45)
   Add sparse devices: lvcreate -s --virtualoriginsize (hidden zero origin).
   Add lvs origin_size field.
   Fix linux configure --enable-debug to exclude -O2.
--- LVM2/lib/format_text/format-text.c	2009/03/23 21:13:37	1.104
+++ LVM2/lib/format_text/format-text.c	2009/05/07 12:11:51	1.105
@@ -1372,7 +1372,9 @@
 	dm_list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if (pv->dev == mdac->area.dev &&
-		    (mdac->area.start <= (pv->pe_start << SECTOR_SHIFT)) &&
+		    ((mdac->area.start <= (pv->pe_start << SECTOR_SHIFT)) ||
+		    (mdac->area.start <= lvm_getpagesize() &&
+		     pv->pe_start < (lvm_getpagesize() >> SECTOR_SHIFT))) &&
 		    (mdac->area.start + mdac->area.size >
 		     (pv->pe_start << SECTOR_SHIFT))) {
 			pv->pe_start = (mdac->area.start + mdac->area.size)
--- LVM2/test/t-pvcreate-usage.sh	2009/02/25 23:31:06	1.8
+++ LVM2/test/t-pvcreate-usage.sh	2009/05/07 12:11:51	1.9
@@ -94,6 +94,12 @@
 pvcreate --metadatasize 100k --dataalignment 100k $dev1
 check_pv_field_ $dev1 pe_start 200.00K
 
+pvcreate --metadatasize 128k --dataalignment 3.5k $dev1
+check_pv_field_ $dev1 pe_start 133.00K
+
+pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1
+check_pv_field_ $dev1 pe_start 133.00K
+
 #COMM 'pv with LVM1 compatible data alignment can be convereted'
 #compatible == LVM1_PE_ALIGN == 64k
 pvcreate --dataalignment 256k $dev1


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-11-05 17:17:56

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c format-text.h layout.h 
	                 text_label.c 
	lib/metadata   : metadata.c metadata.h 
	lib/report     : columns.h report.c 

Log message:
	Add pv_mda_free and vg_mda_free fields to reports for raw text format.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.728&r2=1.729
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/layout.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.173&r2=1.174
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64

--- LVM2/WHATS_NEW	2007/11/05 01:47:47	1.728
+++ LVM2/WHATS_NEW	2007/11/05 17:17:55	1.729
@@ -1,5 +1,7 @@
 Version 2.02.29 -
 ==================================
+  Fix human-readable output of odd numbers of sectors.
+  Add pv_mda_free and vg_mda_free fields to reports for raw text format.
   Add LVM2 version to 'Generated by' comment in metadata.
   Show 'not usable' space when PV is too large for device in pvdisplay.
   Ignore and fix up any excessive device size found in metadata.
--- LVM2/lib/format_text/format-text.c	2007/11/02 13:06:41	1.84
+++ LVM2/lib/format_text/format-text.c	2007/11/05 17:17:55	1.85
@@ -83,6 +83,13 @@
 	return 1;
 }
 
+static uint64_t _mda_free_sectors_raw(struct metadata_area *mda)
+{
+	struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
+
+	return mdac->free_sectors;
+}
+
 /*
  * Check if metadata area belongs to vg
  */
@@ -1043,7 +1050,8 @@
 
 const char *vgname_from_mda(const struct format_type *fmt,
 			    struct device_area *dev_area, struct id *vgid,
-			    uint32_t *vgstatus, char **creation_host)
+			    uint32_t *vgstatus, char **creation_host,
+			    uint64_t *mda_free_sectors)
 {
 	struct raw_locn *rlocn;
 	struct mda_header *mdah;
@@ -1052,6 +1060,10 @@
 	unsigned int len = 0;
 	char buf[NAME_LEN + 1] __attribute((aligned(8)));
 	char uuid[64] __attribute((aligned(8)));
+	uint64_t buffer_size, current_usage;
+
+	if (mda_free_sectors)
+		*mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
 
 	if (!dev_open(dev_area->dev)) {
 		stack;
@@ -1114,9 +1126,21 @@
 	}
 
 	log_debug("%s: Found metadata at %" PRIu64 " size %" PRIu64
-		  " for %s (%s)", 
+		  " (in area at %" PRIu64 " size %" PRIu64
+		  ") for %s (%s)", 
 		  dev_name(dev_area->dev), dev_area->start + rlocn->offset,
-		  rlocn->size, vgname, uuid);
+		  rlocn->size, dev_area->start, dev_area->size, vgname, uuid);
+
+	if (mda_free_sectors) {
+		current_usage = (rlocn->size + SECTOR_SIZE - UINT64_C(1)) -
+				 (rlocn->size + SECTOR_SIZE - UINT64_C(1)) % SECTOR_SIZE;
+		buffer_size = mdah->size - MDA_HEADER_SIZE;
+
+		if (current_usage * 2 >= buffer_size)
+			*mda_free_sectors = UINT64_C(0);
+		else
+			*mda_free_sectors = ((buffer_size - 2 * current_usage) / 2) >> SECTOR_SHIFT;
+	}
 
       out:
 	if (!dev_close(dev_area->dev))
@@ -1143,7 +1167,7 @@
 	list_iterate_items(rl, raw_list) {
 		/* FIXME We're reading mdah twice here... */
 		if ((vgname = vgname_from_mda(fmt, &rl->dev_area, &vgid, &vgstatus,
-					      NULL))) {
+					      NULL, NULL))) {
 			if ((vg = _vg_read_raw_area(&fid, vgname,
 						    &rl->dev_area, 0)))
 				lvmcache_update_vg(vg);
@@ -1557,6 +1581,7 @@
 	.vg_precommit = _vg_precommit_raw,
 	.vg_commit = _vg_commit_raw,
 	.vg_revert = _vg_revert_raw,
+	.mda_free_sectors = _mda_free_sectors_raw,
 	.mda_in_vg = _mda_in_vg_raw,
 	.pv_analyze_mda = _pv_analyze_mda_raw,
 };
--- LVM2/lib/format_text/format-text.h	2007/08/20 20:55:26	1.22
+++ LVM2/lib/format_text/format-text.h	2007/11/05 17:17:55	1.23
@@ -57,6 +57,7 @@
 
 const char *vgname_from_mda(const struct format_type *fmt,
 			    struct device_area *dev_area, struct id *vgid,
-			    uint32_t *vgstatus, char **creation_host);
+			    uint32_t *vgstatus, char **creation_host,
+			    uint64_t *mda_free_sectors);
 
 #endif
--- LVM2/lib/format_text/layout.h	2007/08/20 20:55:26	1.7
+++ LVM2/lib/format_text/layout.h	2007/11/05 17:17:55	1.8
@@ -75,6 +75,7 @@
 
 struct mda_context {
 	struct device_area area;
+	uint64_t free_sectors;
 	struct raw_locn rlocn;	/* Store inbetween write and commit */
 };
 
--- LVM2/lib/format_text/text_label.c	2007/08/20 20:55:26	1.18
+++ LVM2/lib/format_text/text_label.c	2007/11/05 17:17:55	1.19
@@ -162,6 +162,7 @@
 	mdac->area.dev = dev;
 	mdac->area.start = start;
 	mdac->area.size = size;
+	mdac->free_sectors = UINT64_C(0);
 	memset(&mdac->rlocn, 0, sizeof(mdac->rlocn));
 
 	list_add(mdas, &mdal->list);
@@ -239,7 +240,8 @@
 	list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if ((vgname = vgname_from_mda(info->fmt, &mdac->area, 
-					      &vgid, &vgstatus, &creation_host)) &&
+					      &vgid, &vgstatus, &creation_host,
+					      &mdac->free_sectors)) &&
 		    !lvmcache_update_vgname_and_id(info, vgname,
 						   (char *) &vgid, vgstatus,
 						   creation_host))
--- LVM2/lib/metadata/metadata.c	2007/11/02 20:40:04	1.142
+++ LVM2/lib/metadata/metadata.c	2007/11/05 17:17:55	1.143
@@ -1820,7 +1820,7 @@
  */
 int is_orphan_vg(const char *vg_name)
 {
-	return (vg_name[0] ? 0 : 1);
+	return (!strcmp(vg_name, ORPHAN) ? 1 : 0);
 }
 
 /**
--- LVM2/lib/metadata/metadata.h	2007/11/02 13:06:41	1.173
+++ LVM2/lib/metadata/metadata.h	2007/11/05 17:17:55	1.174
@@ -113,6 +113,12 @@
 			  struct volume_group * vg, struct metadata_area * mda);
 	int (*vg_remove) (struct format_instance * fi, struct volume_group * vg,
 			  struct metadata_area * mda);
+
+	/*
+	 * Returns number of free sectors in given metadata area.
+	 */
+	uint64_t (*mda_free_sectors) (struct metadata_area *mda);
+
 	/*
 	 * Check if metadata area belongs to vg
 	 */
--- LVM2/lib/report/columns.h	2007/09/11 13:49:51	1.23
+++ LVM2/lib/report/columns.h	2007/11/05 17:17:55	1.24
@@ -48,6 +48,7 @@
 FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.")
 FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.")
 FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, "pv_mda_count", "Number of metadata areas on this device.")
+FIELD(PVS, pv, NUM, "#PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.")
 
 FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.")
 FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.")
@@ -67,6 +68,7 @@
 FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata.  Incremented whenever it changes.")
 FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.")
 FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas in use by this VG.")
+FIELD(VGS, vg, NUM, "#VMdaFree", cmd, 9, vgmdafree, "vg_mda_free", "Free metadata area space for this VG in current units.")
 
 FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype", "Type of LV segment")
 FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes", "Number of stripes or mirror legs.")
--- LVM2/lib/report/report.c	2007/09/11 13:49:52	1.63
+++ LVM2/lib/report/report.c	2007/11/05 17:17:55	1.64
@@ -745,6 +745,53 @@
 	return _uint32_disp(rh, mem, field, &count, private);
 }
 
+static int _pvmdafree_disp(struct dm_report *rh, struct dm_pool *mem,
+			   struct dm_report_field *field,
+			   const void *data, void *private)
+{
+	struct lvmcache_info *info; 
+	uint64_t freespace = UINT64_MAX, mda_free;
+	const char *pvid = (const char *)(&((struct id *) data)->uuid);
+	struct metadata_area *mda;
+
+	info = info_from_pvid(pvid);
+
+	list_iterate_items(mda, &info->mdas) {
+		if (!mda->ops->mda_free_sectors)
+			continue;
+		mda_free = mda->ops->mda_free_sectors(mda);
+		if (mda_free < freespace)
+			freespace = mda_free;
+	}
+
+	if (freespace == UINT64_MAX)
+		freespace = UINT64_C(0);
+
+	return _size64_disp(rh, mem, field, &freespace, private);
+}
+
+static int _vgmdafree_disp(struct dm_report *rh, struct dm_pool *mem,
+			   struct dm_report_field *field,
+			   const void *data, void *private)
+{
+	const struct volume_group *vg = (const struct volume_group *) data;
+	uint64_t freespace = UINT64_MAX, mda_free;
+	struct metadata_area *mda;
+
+	list_iterate_items(mda, &vg->fid->metadata_areas) {
+		if (!mda->ops->mda_free_sectors)
+			continue;
+		mda_free = mda->ops->mda_free_sectors(mda);
+		if (mda_free < freespace)
+			freespace = mda_free;
+	}
+
+	if (freespace == UINT64_MAX)
+		freespace = UINT64_C(0);
+
+	return _size64_disp(rh, mem, field, &freespace, private);
+}
+
 static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem,
 			    struct dm_report_field *field,
 			    const void *data, void *private)


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2007-04-25 21:10 wysochanski
  0 siblings, 0 replies; 16+ messages in thread
From: wysochanski @ 2007-04-25 21:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-04-25 22:10:55

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

Log message:
	Update pvck to include text metadata area and record detection.
	
	--

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.604&r2=1.605
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.155&r2=1.156

--- LVM2/WHATS_NEW	2007/04/25 20:38:39	1.604
+++ LVM2/WHATS_NEW	2007/04/25 21:10:55	1.605
@@ -1,5 +1,6 @@
 Version 2.02.25 -
 =================================
+  Update pvck to include text metadata area and record detection
   Add support functions for analysis of config sections
   Update pvck to read labels on disk, with --labelsector parameter
   Add count_chars and count_chars_len functions
--- LVM2/lib/format_text/format-text.c	2007/04/23 18:21:01	1.74
+++ LVM2/lib/format_text/format-text.c	2007/04/25 21:10:55	1.75
@@ -39,6 +39,9 @@
 #define FMT_TEXT_NAME "lvm2"
 #define FMT_TEXT_ALIAS "text"
 
+static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
+					       struct device_area *dev_area);
+
 static struct format_instance *_text_create_text_instance(const struct format_type
 						     *fmt, const char *vgname,
 						     const char *vgid,
@@ -96,6 +99,148 @@
 	return 0;
 }
 
+/*
+ * For circular region between region_start and region_start + region_size,
+ * back up one SECTOR_SIZE from 'region_ptr' and return the value.
+ * This allows reverse traversal through text metadata area to find old
+ * metadata.
+ *
+ * Parameters:
+ *   region_start: start of the region (bytes)
+ *   region_size: size of the region (bytes)
+ *   region_ptr: pointer within the region (bytes)
+ *   NOTE: region_start <= region_ptr <= region_start + region_size
+ */
+static uint64_t _get_prev_sector_circular(uint64_t region_start,
+					  uint64_t region_size,
+					  uint64_t region_ptr)
+{
+	if (region_ptr >= region_start + SECTOR_SIZE)
+		return region_ptr - SECTOR_SIZE;
+	else
+		return (region_start + region_size - SECTOR_SIZE);
+}
+
+/*
+ * Analyze a metadata area for old metadata records in the circular buffer.
+ * This function just looks through and makes a first pass at the data in
+ * the sectors for particular things.
+ * FIXME: do something with each metadata area (try to extract vg, write
+ * raw data to file, etc)
+ */
+static int _pv_analyze_mda_raw (const struct format_type * fmt,
+				struct metadata_area *mda)
+{
+	struct mda_header *mdah;
+	struct raw_locn *rlocn;
+	uint64_t area_start;
+	uint64_t area_size;
+	uint64_t prev_sector;
+	uint64_t latest_mrec_offset;
+	int i;
+	uint64_t offset;
+	uint64_t offset2;
+	uint64_t size;
+	uint64_t size2;
+	char *buf=NULL;
+	struct device_area *area;
+	struct mda_context *mdac;
+	int r=0;
+
+	mdac = (struct mda_context *) mda->metadata_locn;
+
+	log_print("Found text metadata area, offset=%"PRIu64", size=%"PRIu64,
+		  mdac->area.start,
+		  mdac->area.size);
+	area = &mdac->area;
+
+	if (!dev_open(area->dev))
+		return_0;
+
+	if (!(mdah = _raw_read_mda_header(fmt, area)))
+		goto_out;
+
+	rlocn = mdah->raw_locns;
+
+	/*
+	 * The device area includes the metadata header as well as the
+	 * records, so remove the metadata header from the start and size
+	 */
+	area_start = area->start + MDA_HEADER_SIZE;
+	area_size = area->size - MDA_HEADER_SIZE;
+	latest_mrec_offset = rlocn->offset + area->start;
+
+	/*
+	 * Start searching at rlocn (point of live metadata) and go
+	 * backwards.
+	 */
+	prev_sector = _get_prev_sector_circular(area_start, area_size,
+					       latest_mrec_offset);
+	offset = prev_sector;
+	size = SECTOR_SIZE;
+	offset2 = size2 = 0;
+	i = 0;
+	while (prev_sector != latest_mrec_offset) {
+		prev_sector = _get_prev_sector_circular(area_start, area_size,
+							prev_sector);
+		/*
+		 * FIXME: for some reason, the whole metadata region from
+		 * area->start to area->start+area->size is not used.
+		 * Only ~32KB seems to contain valid metadata records
+		 * (LVM2 format - format_text).  As a result, I end up with
+		 * "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)))
+			goto_out;
+
+		if (!dev_read_circular(area->dev, offset, size,
+				       offset2, size2, buf))
+			goto_out;
+
+		/*
+		 * FIXME: We could add more sophisticated metadata detection
+		 */
+		if (maybe_config_section(buf, size+size2)) {
+			/* FIXME: Validate region, pull out timestamp?, etc */
+			/* FIXME: Do something with this region */
+			log_verbose ("Found LVM2 metadata record at "
+				     "offset=%"PRIu64", size=%"PRIu64", "
+				     "offset2=%"PRIu64" size2=%"PRIu64,
+				     offset, size, offset2, size2);
+			offset = prev_sector;
+			size = SECTOR_SIZE;
+			offset2 = size2 = 0;
+		} else {
+			/*
+			 * Not a complete metadata record, assume we have
+			 * metadata and just increase the size and offset.
+			 * Start the second region if the previous sector is
+			 * wrapping around towards the end of the disk.
+			 */
+			if (prev_sector > offset) {
+				offset2 = prev_sector;
+				size2 += SECTOR_SIZE;
+			} else {
+				offset = prev_sector;
+				size += SECTOR_SIZE;
+			}
+		}
+		dm_pool_free(fmt->cmd->mem, buf);
+		buf = NULL;
+	}
+
+	r = 1;
+ out:
+	if (buf)
+		dm_pool_free(fmt->cmd->mem, buf);
+	if (!dev_close(area->dev))
+		stack;
+	return r;
+}
+
+
+
 static int _text_lv_setup(struct format_instance *fid __attribute((unused)),
 			  struct logical_volume *lv)
 {
@@ -1413,6 +1558,7 @@
 	.vg_commit = _vg_commit_raw,
 	.vg_revert = _vg_revert_raw,
 	.mda_in_vg = _mda_in_vg_raw,
+	.pv_analyze_mda = _pv_analyze_mda_raw,
 };
 
 /* pvmetadatasize in sectors */
--- LVM2/lib/metadata/metadata.c	2007/04/25 20:03:15	1.106
+++ LVM2/lib/metadata/metadata.c	2007/04/25 21:10:55	1.107
@@ -1565,6 +1565,8 @@
 {
 	struct label *label;
 	struct device *dev;
+	struct metadata_area *mda;
+	struct lvmcache_info *info;
 
 	dev = dev_cache_get(pv_name, cmd->filter);
 	if (!dev) {
@@ -1585,5 +1587,12 @@
 	log_print("Found label on %s, sector %"PRIu64", type=%s",
 		  pv_name, label->sector, label->type);
 
+	/*
+	 * Next, loop through metadata areas
+	 */
+	info = label->info;
+	list_iterate_items(mda, &info->mdas)
+		mda->ops->pv_analyze_mda(info->fmt, mda);
+
 	return 1;
 }
--- LVM2/lib/metadata/metadata.h	2007/04/25 20:03:15	1.155
+++ LVM2/lib/metadata/metadata.h	2007/04/25 21:10:55	1.156
@@ -183,6 +183,12 @@
 	 */
 	int (*mda_in_vg) (struct format_instance * fi,
 			    struct volume_group * vg, struct metadata_area *mda);
+	/*
+	 * Analyze a metadata area on a PV.
+	 */
+	int (*pv_analyze_mda) (const struct format_type * fmt,
+			       struct metadata_area *mda);
+
 };
 
 struct metadata_area {


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2007-03-23 12:43:17

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c metadata.h 
	tools          : vgsplit.c 

Log message:
	Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
	Split metadata areas in vgsplit properly.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.590&r2=1.591
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.153&r2=1.154
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24

--- LVM2/WHATS_NEW	2007/03/19 21:16:49	1.590
+++ LVM2/WHATS_NEW	2007/03/23 12:43:17	1.591
@@ -1,5 +1,7 @@
 Version 2.02.25 -
 =================================
+  Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
+  Split metadata areas in vgsplit properly.
 
 Version 2.02.24 - 19th March 2007
 =================================
--- LVM2/lib/format_text/format-text.c	2007/01/25 14:37:48	1.72
+++ LVM2/lib/format_text/format-text.c	2007/03/23 12:43:17	1.73
@@ -80,6 +80,22 @@
 	return 1;
 }
 
+/*
+ * Check if metadata area belongs to vg
+ */
+static int _mda_in_vg_raw(struct format_instance *fid __attribute((unused)),
+			     struct volume_group *vg, struct metadata_area *mda)
+{
+	struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
+	struct pv_list *pvl;
+
+	list_iterate_items(pvl, &vg->pvs)
+		if (pvl->pv->dev == mdac->area.dev)
+			return 1;
+
+	return 0;
+}
+
 static int _text_lv_setup(struct format_instance *fid __attribute((unused)),
 			  struct logical_volume *lv)
 {
@@ -1395,7 +1411,8 @@
 	.vg_remove = _vg_remove_raw,
 	.vg_precommit = _vg_precommit_raw,
 	.vg_commit = _vg_commit_raw,
-	.vg_revert = _vg_revert_raw
+	.vg_revert = _vg_revert_raw,
+	.mda_in_vg = _mda_in_vg_raw,
 };
 
 /* pvmetadatasize in sectors */
--- LVM2/lib/metadata/metadata.c	2007/02/07 13:29:52	1.103
+++ LVM2/lib/metadata/metadata.c	2007/03/23 12:43:17	1.104
@@ -505,6 +505,34 @@
 	return 1;
 }
 
+int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
+		  struct volume_group *vg_to)
+{
+	struct metadata_area *mda, *mda2;
+	struct list *mdas_from, *mdas_to;
+	int common_mda = 0;
+
+	mdas_from = &vg_from->fid->metadata_areas;
+	mdas_to = &vg_to->fid->metadata_areas;
+
+	list_iterate_items_safe(mda, mda2, mdas_from) {
+		if (!mda->ops->mda_in_vg) {
+			common_mda = 1;
+			continue;
+		}
+
+		if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda)) {
+			list_del(&mda->list);
+			list_add(mdas_to, &mda->list);
+		}
+	}
+
+	if (list_empty(mdas_from) || list_empty(mdas_to))
+		return common_mda;
+
+	return 1;
+}
+
 /* Sizes in sectors */
 struct physical_volume *pv_create(const struct format_type *fmt,
 				  struct device *dev,
@@ -759,6 +787,12 @@
 				r = 0;
 			}
 		}
+
+		if (strcmp(pvl->pv->vg_name, vg->name)) {
+			log_error("Internal error: VG name for PV %s is corrupted",
+				  dev_name(pvl->pv->dev));
+			r = 0;
+		}
 	}
 
 	if (!check_pv_segments(vg)) {
--- LVM2/lib/metadata/metadata.h	2007/02/07 13:29:52	1.153
+++ LVM2/lib/metadata/metadata.h	2007/03/23 12:43:17	1.154
@@ -178,6 +178,11 @@
 			  struct volume_group * vg, struct metadata_area * mda);
 	int (*vg_remove) (struct format_instance * fi, struct volume_group * vg,
 			  struct metadata_area * mda);
+	/*
+	 * Check if metadata area belongs to vg
+	 */
+	int (*mda_in_vg) (struct format_instance * fi,
+			    struct volume_group * vg, struct metadata_area *mda);
 };
 
 struct metadata_area {
@@ -450,6 +455,8 @@
 	      int pv_count, char **pv_names);
 int vg_change_pesize(struct cmd_context *cmd, struct volume_group *vg,
 		     uint32_t new_extent_size);
+int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
+		  struct volume_group *vg_to);
 
 /* Manipulate LVs */
 struct logical_volume *lv_create_empty(struct format_instance *fi,
--- LVM2/tools/vgsplit.c	2007/03/09 21:25:33	1.23
+++ LVM2/tools/vgsplit.c	2007/03/23 12:43:17	1.24
@@ -299,6 +299,10 @@
 		goto error;
 	}
 
+	/* Set metadata format of original VG */
+	/* FIXME: need some common logic */
+	cmd->fmt = vg_from->fid->fmt;
+
 	/* Create new VG structure */
 	if (!(vg_to = vg_create(cmd, vg_name_to, vg_from->extent_size,
 				vg_from->max_pv, vg_from->max_lv,
@@ -330,11 +334,15 @@
 	if (!(_move_mirrors(vg_from, vg_to)))
 		goto error;
 
-	/* FIXME Split mdas properly somehow too! */
-	/* Currently we cheat by sharing the format instance and relying on 
-	 * vg_write to ignore mdas outside the VG!  Done this way, with text 
-	 * format, vg_from disappears for a short time. */
-	vg_to->fid = vg_from->fid;
+	/* Split metadata areas and check if both vgs have at least one area */
+	if (!(vg_split_mdas(cmd, vg_from, vg_to))) {
+		log_error("Cannot split: Nowhere to store metadata for new Volume Group");
+		goto error;
+	}
+
+	/* Set proper name for all PVs in new VG */
+	if (!vg_rename(cmd, vg_to, vg_name_to))
+		goto error;
 
 	/* store it on disks */
 	log_verbose("Writing out updated volume groups");


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2007-01-09 21:12 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2007-01-09 21:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-01-09 21:12:41

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	man            : lvextend.8 
	tools          : vgsplit.c 

Log message:
	Free memory in _raw_read_mda_header() error paths.
	Fix ambiguous vgsplit error message for split LV.
	Fix lvextend man page typo.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.528&r2=1.529
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvextend.8.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21

--- LVM2/WHATS_NEW	2007/01/09 20:31:08	1.528
+++ LVM2/WHATS_NEW	2007/01/09 21:12:40	1.529
@@ -1,5 +1,8 @@
 Version 2.02.18 -
 ====================================
+  Free memory in _raw_read_mda_header() error paths.
+  Fix ambiguous vgsplit error message for split LV.
+  Fix lvextend man page typo.
   Add configure --with-dmdir to compile against a device-mapper source tree.
   Use no flush suspending for mirrors.
   Add dmeventd_mirror register_mutex, tidy initialisation & add memlock.
--- LVM2/lib/format_text/format-text.c	2006/11/30 23:11:41	1.70
+++ LVM2/lib/format_text/format-text.c	2007/01/09 21:12:41	1.71
@@ -132,37 +132,40 @@
 
 	if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, mdah)) {
 		stack;
-		dm_pool_free(fmt->cmd->mem, mdah);
-		return NULL;
+		goto error;
 	}
 
 	if (mdah->checksum_xl != xlate32(calc_crc(INITIAL_CRC, mdah->magic,
 						  MDA_HEADER_SIZE -
 						  sizeof(mdah->checksum_xl)))) {
 		log_error("Incorrect metadata area header checksum");
-		return NULL;
+		goto error;
 	}
 
 	_xlate_mdah(mdah);
 
 	if (strncmp((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) {
 		log_error("Wrong magic number in metadata area header");
-		return NULL;
+		goto error;
 	}
 
 	if (mdah->version != FMTT_VERSION) {
 		log_error("Incompatible metadata area header version: %d",
 			  mdah->version);
-		return NULL;
+		goto error;
 	}
 
 	if (mdah->start != dev_area->start) {
 		log_error("Incorrect start sector in metadata area header: %"
 			  PRIu64, mdah->start);
-		return NULL;
+		goto error;
 	}
 
 	return mdah;
+
+error:
+	dm_pool_free(fmt->cmd->mem, mdah);
+	return NULL;
 }
 
 static int _raw_write_mda_header(const struct format_type *fmt,
--- LVM2/man/lvextend.8	2006/11/10 18:24:11	1.8
+++ LVM2/man/lvextend.8	2007/01/09 21:12:41	1.9
@@ -31,7 +31,7 @@
 free space in the Volume Group with the suffix %FREE.
 .TP
 .I \-L, \-\-size [+]LogicalVolumeSize[kKmMgGtTpPeE]
-Extend or set the logical volume size in units in units of megabytes.
+Extend or set the logical volume size in units of megabytes.
 A size suffix of M for megabytes,
 G for gigabytes, T for terabytes, P for petabytes 
 or E for exabytes is optional.
--- LVM2/tools/vgsplit.c	2006/10/13 13:22:44	1.20
+++ LVM2/tools/vgsplit.c	2007/01/09 21:12:41	1.21
@@ -84,9 +84,9 @@
 				pv = seg_pv(seg, s);
 				if (vg_with) {
 					if (!pv_is_in_vg(vg_with, pv)) {
-						log_error("Logical Volume %s "
-							  "split between "
-							  "Volume Groups",
+						log_error("Can't split Logical "
+							  "Volume %s between "
+							  "two Volume Groups",
 							  lv->name);
 						return 0;
 					}


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2006-10-05 22:02 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2006-10-05 22:02 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-10-05 22:02:52

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

Log message:
	Fix format_text mda_setup pv->size and pv_setup pe_count calculations.
	
	(This area of the code needs a lot more work.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.454&r2=1.455
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/WHATS_NEW	2006/10/05 21:24:46	1.454
+++ LVM2/WHATS_NEW	2006/10/05 22:02:52	1.455
@@ -1,5 +1,6 @@
 Version 2.02.11 - 
 =====================================
+  Fix format_text mda_setup pv->size and pv_setup pe_count calculations.
   Fix _for_each_pv() for mirror with core log.
   Add lvm_dump.sh script to create a tarball of debugging info from a system.
   Capture error messages in clvmd and pass them back to the user.
--- LVM2/lib/format_text/format-text.c	2006/08/21 12:54:52	1.66
+++ LVM2/lib/format_text/format-text.c	2006/10/05 22:02:52	1.67
@@ -1007,11 +1007,8 @@
 	uint64_t wipe_size = 8 << SECTOR_SHIFT;
 	size_t pagesize = lvm_getpagesize();
 
-	if (!pvmetadatacopies) {
-		/* Space available for PEs */
-		pv->size -= pe_align();
+	if (!pvmetadatacopies)
 		return 1;
-	}
 
 	alignment = pe_align() << SECTOR_SHIFT;
 	disk_size = pv->size << SECTOR_SHIFT;
@@ -1027,9 +1024,6 @@
 	/* Requested metadatasize */
 	mda_size1 = pvmetadatasize << SECTOR_SHIFT;
 
-	/* Space available for PEs (before any mdas created) */
-	pv->size -= LABEL_SCAN_SECTORS;
-
 	/* Place mda straight after label area at start of disk */
 	start1 = LABEL_SCAN_SIZE;
 
@@ -1037,11 +1031,8 @@
 	if ((!pe_start && !pe_end) ||
 	    ((pe_start > start1) && (pe_start - start1 >= MDA_SIZE_MIN))) {
 		mda_adjustment = start1 % pagesize;
-		if (mda_adjustment) {
+		if (mda_adjustment)
 			start1 += (pagesize - mda_adjustment);
-			pv->size -= ((pagesize - mda_adjustment) >>
-				     SECTOR_SHIFT);
-		}
 	}
 
 	/* Ensure it's not going to be bigger than the disk! */
@@ -1071,7 +1062,8 @@
 	/* FIXME If creating new mdas, wipe them! */
 	if (mda_size1) {
 		if (!add_mda(fmt, fmt->cmd->mem, mdas, pv->dev, start1,
-			     mda_size1)) return 0;
+			     mda_size1))
+			return 0;
 
 		if (!dev_set((struct device *) pv->dev, start1,
 			     (size_t) (mda_size1 >
@@ -1080,7 +1072,6 @@
 			return 0;
 		}
 
-		pv->size -= mda_size1 >> SECTOR_SHIFT;
 		if (pvmetadatacopies == 1)
 			return 1;
 	} else
@@ -1125,7 +1116,6 @@
 			log_error("Failed to wipe new metadata area");
 			return 0;
 		}
-		pv->size -= mda_size2 >> SECTOR_SHIFT;
 	} else
 		return 0;
 
@@ -1416,8 +1406,8 @@
 	struct lvmcache_info *info;
 	int found;
 	uint64_t pe_end = 0;
-
-	/* FIXME if vg, adjust start/end of pe area to avoid mdas! */
+	unsigned mda_count = 0;
+	uint64_t mda_size2 = 0;
 
 	/* FIXME Cope with pvchange */
 	/* FIXME Merge code with _text_create_text_instance */
@@ -1428,11 +1418,16 @@
 		if ((info = info_from_pvid(pv->dev->pvid))) {
 			pvmdas = &info->mdas;
 			list_iterate_items(mda, pvmdas) {
+				mda_count++;
 				mdac =
 				    (struct mda_context *) mda->metadata_locn;
 
 				/* FIXME Check it isn't already in use */
 
+				/* Reduce usable device size */
+				if (mda_count > 1)
+					mda_size2 = mdac->area.size >> SECTOR_SHIFT;
+
 				/* Ensure it isn't already on list */
 				found = 0;
 				list_iterate_items(mda2, mdas) {
@@ -1470,6 +1465,9 @@
 			}
 		}
 
+		/* Recalculate number of extents that will fit */
+		pv->pe_count = (pv->size - pv->pe_start - mda_size2) / vg->extent_size;
+
 		/* Unlike LVM1, we don't store this outside a VG */
 		/* FIXME Default from config file? vgextend cmdline flag? */
 		pv->status |= ALLOCATABLE_PV;
--- LVM2/lib/metadata/metadata.c	2006/09/21 20:25:54	1.98
+++ LVM2/lib/metadata/metadata.c	2006/10/05 22:02:52	1.99
@@ -734,6 +734,8 @@
 	char uuid[64];
 	int r = 1;
 
+	/* FIXME Also check there's no data/metadata overlap */
+
 	list_iterate_items(pvl, &vg->pvs) {
 		list_iterate_items(pvl2, &vg->pvs) {
 			if (pvl == pvl2)


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2006-08-17 19:53 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2006-08-17 19:53 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-08-17 19:53:36

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

Log message:
	Fix PE_ALIGN for pagesize over 32KB.

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

--- LVM2/WHATS_NEW	2006/08/17 19:30:59	1.422
+++ LVM2/WHATS_NEW	2006/08/17 19:53:35	1.423
@@ -1,5 +1,6 @@
 Version 2.02.09 - 
 ==================================
+  Fix PE_ALIGN for pagesize over 32KB.
   Separate out LVM1_PE_ALIGN and pe_align().
   Add lvm_getpagesize wrapper.
   Add --maxphysicalvolumes to vgchange.
--- LVM2/lib/format_text/format-text.c	2006/08/17 19:30:59	1.64
+++ LVM2/lib/format_text/format-text.c	2006/08/17 19:53:35	1.65
@@ -1193,7 +1193,7 @@
 	list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if (pv->dev == mdac->area.dev &&
-		    (mdac->area.start < (pv->pe_start << SECTOR_SHIFT)) &&
+		    (mdac->area.start <= (pv->pe_start << SECTOR_SHIFT)) &&
 		    (mdac->area.start + mdac->area.size >
 		     (pv->pe_start << SECTOR_SHIFT))) {
 			pv->pe_start = (mdac->area.start + mdac->area.size)
--- LVM2/lib/metadata/metadata.c	2006/08/17 19:30:59	1.96
+++ LVM2/lib/metadata/metadata.c	2006/08/17 19:53:36	1.97
@@ -24,9 +24,11 @@
 #include "pv_alloc.h"
 #include "activate.h"
 
+#include <sys/param.h>
+
 unsigned long pe_align(void)
 {
-	return (65536UL >> SECTOR_SHIFT);
+	return MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
 }
 
 static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2006-08-17 19:31 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2006-08-17 19:31 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-08-17 19:30:59

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

Log message:
	wrap PE_ALIGN

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.421&r2=1.422
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.147&r2=1.148

--- LVM2/WHATS_NEW	2006/08/17 19:15:27	1.421
+++ LVM2/WHATS_NEW	2006/08/17 19:30:59	1.422
@@ -1,6 +1,6 @@
 Version 2.02.09 - 
 ==================================
-  Separate out LVM1_PE_ALIGN.
+  Separate out LVM1_PE_ALIGN and pe_align().
   Add lvm_getpagesize wrapper.
   Add --maxphysicalvolumes to vgchange.
 
--- LVM2/lib/format_text/format-text.c	2006/08/17 18:23:43	1.63
+++ LVM2/lib/format_text/format-text.c	2006/08/17 19:30:59	1.64
@@ -994,7 +994,7 @@
 }
 
 /* For orphan, creates new mdas according to policy.
-   Always have an mda between end-of-label and PE_ALIGN boundary */
+   Always have an mda between end-of-label and pe_align() boundary */
 static int _mda_setup(const struct format_type *fmt,
 		      uint64_t pe_start, uint64_t pe_end,
 		      int pvmetadatacopies,
@@ -1009,11 +1009,11 @@
 
 	if (!pvmetadatacopies) {
 		/* Space available for PEs */
-		pv->size -= PE_ALIGN;
+		pv->size -= pe_align();
 		return 1;
 	}
 
-	alignment = PE_ALIGN << SECTOR_SHIFT;
+	alignment = pe_align() << SECTOR_SHIFT;
 	disk_size = pv->size << SECTOR_SHIFT;
 	pe_start <<= SECTOR_SHIFT;
 	pe_end <<= SECTOR_SHIFT;
@@ -1055,7 +1055,7 @@
 		pvmetadatacopies = 1;
 	}
 
-	/* Round up to PE_ALIGN boundary */
+	/* Round up to pe_align() boundary */
 	mda_adjustment = (mda_size1 + start1) % alignment;
 	if (mda_adjustment)
 		mda_size1 += (alignment - mda_adjustment);
@@ -1189,7 +1189,7 @@
 
 	/* Set pe_start to first aligned sector after any metadata 
 	 * areas that begin before pe_start */
-	pv->pe_start = PE_ALIGN;
+	pv->pe_start = pe_align();
 	list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if (pv->dev == mdac->area.dev &&
@@ -1198,9 +1198,9 @@
 		     (pv->pe_start << SECTOR_SHIFT))) {
 			pv->pe_start = (mdac->area.start + mdac->area.size)
 			    >> SECTOR_SHIFT;
-			adjustment = pv->pe_start % PE_ALIGN;
+			adjustment = pv->pe_start % pe_align();
 			if (adjustment)
-				pv->pe_start += (PE_ALIGN - adjustment);
+				pv->pe_start += (pe_align() - adjustment);
 		}
 	}
 	if (!add_da
--- LVM2/lib/metadata/metadata.c	2006/08/09 19:33:25	1.95
+++ LVM2/lib/metadata/metadata.c	2006/08/17 19:30:59	1.96
@@ -24,6 +24,11 @@
 #include "pv_alloc.h"
 #include "activate.h"
 
+unsigned long pe_align(void)
+{
+	return (65536UL >> SECTOR_SHIFT);
+}
+
 static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
 			 const char *pv_name)
 {
@@ -78,8 +83,8 @@
 
 	/* FIXME Do proper rounding-up alignment? */
 	/* Reserved space for label; this holds 0 for PVs created by LVM1 */
-	if (pv->pe_start < PE_ALIGN)
-		pv->pe_start = PE_ALIGN;
+	if (pv->pe_start < pe_align())
+		pv->pe_start = pe_align();
 
 	/*
 	 * The next two fields should be corrected
--- LVM2/lib/metadata/metadata.h	2006/08/17 18:23:43	1.147
+++ LVM2/lib/metadata/metadata.h	2006/08/17 19:30:59	1.148
@@ -33,7 +33,6 @@
 #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
 #define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
-#define PE_ALIGN (65536UL >> SECTOR_SHIFT)	/* PE alignment */
 #define MAX_RESTRICTED_LVS 255	/* Used by FMT_RESTRICTED_LVIDS */
 
 /* Various flags */
@@ -403,6 +402,7 @@
 /*
  * Utility functions
  */
+unsigned long pe_align(void);
 int vg_validate(struct volume_group *vg);
 int vg_write(struct volume_group *vg);
 int vg_commit(struct volume_group *vg);


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2006-04-29 22:08 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2006-04-29 22:08 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-29 22:08:43

Modified files:
	.              : WHATS_NEW 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.h 
	man            : lvcreate.8 
	tools          : lvcreate.c lvresize.c 

Log message:
	Improve stripe size validation.
	Increase maximum stripe size limit to physical extent size for lvm2 metadata.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.374&r2=1.375
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2005-09-01 18:37 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2005-09-01 18:37 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-09-01 18:37:22

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

Log message:
	Suppress fsync() error message on filesystems that don't support it.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.289&r2=1.290
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13


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

* LVM2 ./WHATS_NEW lib/format_text/format-text.c ...
@ 2005-04-06 18:59 agk
  0 siblings, 0 replies; 16+ messages in thread
From: agk @ 2005-04-06 18:59 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-04-06 18:59:56

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

Log message:
	Move from 2-step to 3-step on-disk metadata commit.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.221&r2=1.222
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.109&r2=1.110


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

end of thread, other threads:[~2012-05-09 12:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-20 18:11 LVM2 ./WHATS_NEW lib/format_text/format-text.c agk
2005-04-06 18:59 agk
2005-09-01 18:37 agk
2006-04-29 22:08 agk
2006-08-17 19:31 agk
2006-08-17 19:53 agk
2006-10-05 22:02 agk
2007-01-09 21:12 agk
2007-03-23 12:43 mbroz
2007-04-25 21:10 wysochanski
2007-11-05 17:17 agk
2009-05-07 12:11 mbroz
2011-02-25 14:08 prajnoha
2011-02-28 13:19 prajnoha
2011-04-21 13:13 zkabelac
2012-05-09 12:31 prajnoha

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).