public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2009-04-10  9:59 mbroz
  0 siblings, 0 replies; 12+ messages in thread
From: mbroz @ 2009-04-10  9:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/format1    : format1.c 
	lib/format_pool: format_pool.c 
	lib/format_text: import_vsn1.c 
	lib/locking    : locking.h 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 

Log message:
	Introduce memory pool per volume group.
	
	Since now, all code reading volume group is responsible for releasing
	the memory allocated by calling vg_release(vg).
	(For simplicity of use, vg_releae can be called for vg == NULL,
	the same logic like free(NULL)).
	
	Also providing simple macro for unlocking & releasing in one step,
	tools usualy uses this approach.
	
	The global memory pool (cmd->mem) should be used only for global
	physical volume operations.
	
	This patch have to be applied with all subsequent patches to complete
	memory pool per vg logic.
	
	Using separate memory pool has quite bit memory saving impact when
	using large VGs, this is mainly needed when we have to use
	preallocated and locked memory (and should not overflow from that
	memory space).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1085&r2=1.1086
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.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.209&r2=1.210
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.190&r2=1.191

--- LVM2/WHATS_NEW	2009/04/10 09:56:58	1.1085
+++ LVM2/WHATS_NEW	2009/04/10 09:59:18	1.1086
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Introduce memory pools per volume group (to reduce memory for large VGs).
   Add memory pool leaks detection.
   Use copy of PV structure when manipulating with global PV lists.
   Always return exit error status when locking of volume group fails.
--- LVM2/lib/format1/format1.c	2009/02/25 23:29:06	1.111
+++ LVM2/lib/format1/format1.c	2009/04/10 09:59:18	1.112
@@ -111,9 +111,9 @@
 }
 
 static struct volume_group *_build_vg(struct format_instance *fid,
-				      struct dm_list *pvs)
+				      struct dm_list *pvs,
+				      struct dm_pool *mem)
 {
-	struct dm_pool *mem = fid->fmt->cmd->mem;
 	struct volume_group *vg = dm_pool_alloc(mem, sizeof(*vg));
 	struct disk_list *dl;
 
@@ -126,6 +126,7 @@
 	memset(vg, 0, sizeof(*vg));
 
 	vg->cmd = fid->fmt->cmd;
+	vg->vgmem = mem;
 	vg->fid = fid;
 	vg->seqno = 0;
 	dm_list_init(&vg->pvs);
@@ -163,7 +164,7 @@
 				     const char *vg_name,
 				     struct metadata_area *mda __attribute((unused)))
 {
-	struct dm_pool *mem = dm_pool_create("lvm1 vg_read", 1024 * 10);
+	struct dm_pool *mem = dm_pool_create("lvm1 vg_read", VG_MEMPOOL_CHUNK);
 	struct dm_list pvs;
 	struct volume_group *vg = NULL;
 	dm_list_init(&pvs);
@@ -178,12 +179,13 @@
 	    (fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs))
 		goto_bad;
 
-	if (!(vg = _build_vg(fid, &pvs)))
+	if (!(vg = _build_vg(fid, &pvs, mem)))
 		goto_bad;
 
-      bad:
-	dm_pool_destroy(mem);
 	return vg;
+bad:
+	dm_pool_destroy(mem);
+	return NULL;
 }
 
 static struct disk_list *_flatten_pv(struct format_instance *fid,
@@ -240,7 +242,7 @@
 static int _format1_vg_write(struct format_instance *fid, struct volume_group *vg,
 		     struct metadata_area *mda __attribute((unused)))
 {
-	struct dm_pool *mem = dm_pool_create("lvm1 vg_write", 1024 * 10);
+	struct dm_pool *mem = dm_pool_create("lvm1 vg_write", VG_MEMPOOL_CHUNK);
 	struct dm_list pvds;
 	int r = 0;
 
--- LVM2/lib/format_pool/format_pool.c	2009/02/25 23:29:06	1.20
+++ LVM2/lib/format_pool/format_pool.c	2009/04/10 09:59:18	1.21
@@ -113,6 +113,7 @@
 	}
 
 	vg->cmd = fid->fmt->cmd;
+	vg->vgmem = mem;
 	vg->fid = fid;
 	vg->name = NULL;
 	vg->status = 0;
@@ -160,7 +161,7 @@
 				     const char *vg_name,
 				     struct metadata_area *mda __attribute((unused)))
 {
-	struct dm_pool *mem = dm_pool_create("pool vg_read", 1024);
+	struct dm_pool *mem = dm_pool_create("pool vg_read", VG_MEMPOOL_CHUNK);
 	struct dm_list pds;
 	struct volume_group *vg = NULL;
 
@@ -182,9 +183,10 @@
 	if (!(vg = _build_vg_from_pds(fid, mem, &pds)))
 		goto_out;
 
-      out:
-	dm_pool_destroy(mem);
 	return vg;
+out:
+	dm_pool_destroy(mem);
+	return NULL;
 }
 
 static int _pool_pv_setup(const struct format_type *fmt __attribute((unused)),
--- LVM2/lib/format_text/import_vsn1.c	2009/04/02 21:34:41	1.57
+++ LVM2/lib/format_text/import_vsn1.c	2009/04/10 09:59:19	1.58
@@ -662,18 +662,23 @@
 	struct config_node *vgn, *cn;
 	struct volume_group *vg;
 	struct dm_hash_table *pv_hash = NULL;
-	struct dm_pool *mem = fid->fmt->cmd->mem;
+	struct dm_pool *mem = dm_pool_create("lvm2 vg_read", VG_MEMPOOL_CHUNK);
+
+	if (!mem)
+		return_NULL;
 
 	/* skip any top-level values */
 	for (vgn = cft->root; (vgn && vgn->v); vgn = vgn->sib) ;
 
 	if (!vgn) {
 		log_error("Couldn't find volume group in file.");
-		return NULL;
+		goto bad;
 	}
 
 	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
-		return_NULL;
+		goto_bad;
+
+	vg->vgmem = mem;
 	vg->cmd = fid->fmt->cmd;
 
 	/* FIXME Determine format type from file contents */
@@ -807,7 +812,7 @@
 	if (pv_hash)
 		dm_hash_destroy(pv_hash);
 
-	dm_pool_free(mem, vg);
+	dm_pool_destroy(mem);
 	return NULL;
 }
 
--- LVM2/lib/locking/locking.h	2008/11/03 22:14:29	1.43
+++ LVM2/lib/locking/locking.h	2009/04/10 09:59:19	1.44
@@ -115,6 +115,9 @@
 	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv))
 
 #define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
+#define unlock_release_vg(cmd, vg, vol) do { unlock_vg(cmd, vol); \
+					     vg_release(vg); \
+					} while (0)
 
 #define resume_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_RESUME)
 #define suspend_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_SUSPEND | LCK_HOLD)
--- LVM2/lib/metadata/metadata-exported.h	2009/02/25 23:29:06	1.63
+++ LVM2/lib/metadata/metadata-exported.h	2009/04/10 09:59:19	1.64
@@ -212,6 +212,7 @@
 
 struct volume_group {
 	struct cmd_context *cmd;
+	struct dm_pool *vgmem;
 	struct format_instance *fid;
 	uint32_t seqno;		/* Metadata sequence number */
 
@@ -437,6 +438,7 @@
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
+void vg_release(struct volume_group *vg);
 /* Manipulate LVs */
 struct logical_volume *lv_create_empty(const char *name,
 				       union lvid *lvid,
--- LVM2/lib/metadata/metadata.c	2009/04/10 09:56:00	1.209
+++ LVM2/lib/metadata/metadata.c	2009/04/10 09:59:19	1.210
@@ -517,18 +517,22 @@
 			       int pv_count, char **pv_names)
 {
 	struct volume_group *vg;
-	struct dm_pool *mem = cmd->mem;
 	int consistent = 0;
-
-	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
-		return_NULL;
+	struct dm_pool *mem;
 
 	/* is this vg name already in use ? */
-	if (vg_read_internal(cmd, vg_name, NULL, &consistent)) {
+	if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 		log_err("A volume group called '%s' already exists.", vg_name);
-		goto bad;
+		vg_release(vg);
+		return NULL;
 	}
 
+	if (!(mem = dm_pool_create("lvm2 vg_create", VG_MEMPOOL_CHUNK)))
+		return_NULL;
+
+	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
+		goto_bad;
+
 	if (!id_create(&vg->id)) {
 		log_err("Couldn't create uuid for volume group '%s'.", vg_name);
 		goto bad;
@@ -537,6 +541,7 @@
 	/* Strip dev_dir if present */
 	vg_name = strip_dir(vg_name, cmd->dev_dir);
 
+	vg->vgmem = mem;
 	vg->cmd = cmd;
 
 	if (!(vg->name = dm_pool_strdup(mem, vg_name)))
@@ -589,7 +594,7 @@
 	return vg;
 
       bad:
-	dm_pool_free(mem, vg);
+	dm_pool_destroy(mem);
 	return NULL;
 }
 
@@ -1643,23 +1648,28 @@
 	struct pv_list *pvl;
 	struct volume_group *vg;
 	struct physical_volume *pv;
+	struct dm_pool *mem;
 
 	lvmcache_label_scan(cmd, 0);
 
 	if (!(vginfo = vginfo_from_vgname(orphan_vgname, NULL)))
 		return_NULL;
 
-	if (!(vg = dm_pool_zalloc(cmd->mem, sizeof(*vg)))) {
+	if (!(mem = dm_pool_create("vg_read orphan", VG_MEMPOOL_CHUNK)))
+		return_NULL;
+
+	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg)))) {
 		log_error("vg allocation failed");
 		return NULL;
 	}
 	dm_list_init(&vg->pvs);
 	dm_list_init(&vg->lvs);
 	dm_list_init(&vg->tags);
+	vg->vgmem = mem;
 	vg->cmd = cmd;
-	if (!(vg->name = dm_pool_strdup(cmd->mem, orphan_vgname))) {
+	if (!(vg->name = dm_pool_strdup(mem, orphan_vgname))) {
 		log_error("vg name allocation failed");
-		return NULL;
+		goto bad;
 	}
 
 	/* create format instance with appropriate metadata area */
@@ -1667,17 +1677,16 @@
 							  orphan_vgname, NULL,
 							  NULL))) {
 		log_error("Failed to create format instance");
-		dm_pool_free(cmd->mem, vg);
-		return NULL;
+		goto bad;
 	}
 
 	dm_list_iterate_items(info, &vginfo->infos) {
 		if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1, 0))) {
 			continue;
 		}
-		if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) {
+		if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
 			log_error("pv_list allocation failed");
-			return NULL;
+			goto bad;
 		}
 		pvl->pv = pv;
 		dm_list_add(&vg->pvs, &pvl->list);
@@ -1685,6 +1694,9 @@
 	}
 
 	return vg;
+bad:
+	dm_pool_destroy(mem);
+	return NULL;
 }
 
 static int _update_pv_list(struct dm_pool *pvmem, struct dm_list *all_pvs, struct volume_group *vg)
@@ -2040,6 +2052,18 @@
 	return vg;
 }
 
+void vg_release(struct volume_group *vg)
+{
+	if (!vg || !vg->vgmem)
+		return;
+
+	if (vg->vgmem == vg->cmd->mem)
+		log_error("Internal error: global memory pool used for VG %s",
+			  vg->name);
+
+	dm_pool_destroy(vg->vgmem);
+}
+
 /* This is only called by lv_from_lvid, which is only called from
  * activate.c so we know the appropriate VG lock is already held and
  * the vg_read_internal is therefore safe.
--- LVM2/lib/metadata/metadata.h	2009/02/25 23:29:06	1.190
+++ LVM2/lib/metadata/metadata.h	2009/04/10 09:59:19	1.191
@@ -35,6 +35,7 @@
 //#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 //#define MAX_RESTRICTED_LVS 255	/* Used by FMT_RESTRICTED_LVIDS */
 #define MIRROR_LOG_OFFSET	2	/* sectors */
+#define VG_MEMPOOL_CHUNK	10240	/* in bytes, hint only */
 
 /*
  * Ceiling(n / sz)


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2012-02-27 11:23 zkabelac
  0 siblings, 0 replies; 12+ messages in thread
From: zkabelac @ 2012-02-27 11:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-27 11:23:15

Modified files:
	.              : WHATS_NEW 
	lib/format1    : format1.c 
	lib/format_pool: format_pool.c 

Log message:
	Check for vg_name existance
	
	Since vg_read() mda ops could be called with NULL vg_name,
	check it before derefence also for pool and format1.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2315&r2=1.2316
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.148&r2=1.149
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54

--- LVM2/WHATS_NEW	2012/02/27 11:13:48	1.2315
+++ LVM2/WHATS_NEW	2012/02/27 11:23:15	1.2316
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Check for existance of vg_name in _format1/_pool_vg_read().
   Fix missing break in _format_pvsegs (2.02.92).
   Test seg pointer for non-null it in raid_target_percent error path.
   Check for errors in _init_tags() during config loading.
--- LVM2/lib/format1/format1.c	2012/02/23 13:11:09	1.148
+++ LVM2/lib/format1/format1.c	2012/02/27 11:23:15	1.149
@@ -186,7 +186,8 @@
 	DM_LIST_INIT(pvs);
 
 	/* Strip dev_dir if present */
-	vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
+	if (vg_name)
+		vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
 
 	if (!(vg = alloc_vg("format1_vg_read", fid->fmt->cmd, NULL)))
 		return_NULL;
--- LVM2/lib/format_pool/format_pool.c	2012/02/23 13:11:09	1.53
+++ LVM2/lib/format_pool/format_pool.c	2012/02/27 11:23:15	1.54
@@ -110,7 +110,8 @@
 	/* We can safely ignore the mda passed in */
 
 	/* Strip dev_dir if present */
-	vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
+	if (vg_name)
+		vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
 
 	/* Set vg_name through read_pool_pds() */
 	if (!(vg = alloc_vg("pool_vg_read", fid->fmt->cmd, NULL)))


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2012-02-13 11:04 zkabelac
  0 siblings, 0 replies; 12+ messages in thread
From: zkabelac @ 2012-02-13 11:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/format1    : format1.c 
	lib/format_pool: format_pool.c 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c vg.c vg.h 
	tools          : pvcreate.c vgconvert.c 

Log message:
	Add free_orphan_vg
	
	Move commod code to destroy orphan VG into free_orphan_vg() function.
	Use orphan vgmem for creation of PV lists.
	Remove some free_pv_fid() calls (FIXME: check all of them)
	FIXME: Check whether we could merge release_vg back again for all VGs.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2285&r2=1.2286
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.145&r2=1.146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.191&r2=1.192
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.483&r2=1.484
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52

--- LVM2/WHATS_NEW	2012/02/13 11:01:34	1.2285
+++ LVM2/WHATS_NEW	2012/02/13 11:03:59	1.2286
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Add free_orphan_vg.
   Skip pv/vg_set_fid processing if the fid is same.
   Check for foreach loop errors in _vg_read_orphans() (2.02.91).
   Clean error paths for format instance creation (2.02.91).
--- LVM2/lib/format1/format1.c	2012/02/13 10:56:31	1.145
+++ LVM2/lib/format1/format1.c	2012/02/13 11:03:59	1.146
@@ -546,12 +546,8 @@
 
 static void _format1_destroy(struct format_type *fmt)
 {
-	/* FIXME out of place, but the main (cmd) pool has been already
-	 * destroyed and touching the fid (also via release_vg) will crash the
-	 * program */
-	dm_hash_destroy(fmt->orphan_vg->hostnames);
-	dm_pool_destroy(fmt->orphan_vg->fid->mem);
-	dm_pool_destroy(fmt->orphan_vg->vgmem);
+	if (fmt->orphan_vg)
+		free_orphan_vg(fmt->orphan_vg);
 
 	dm_free(fmt);
 }
--- LVM2/lib/format_pool/format_pool.c	2012/02/13 10:56:31	1.49
+++ LVM2/lib/format_pool/format_pool.c	2012/02/13 11:04:00	1.50
@@ -259,12 +259,8 @@
 
 static void _pool_destroy(struct format_type *fmt)
 {
-	/* FIXME out of place, but the main (cmd) pool has been already
-	 * destroyed and touching the fid (also via release_vg) will crash the
-	 * program */
-	dm_hash_destroy(fmt->orphan_vg->hostnames);
-	dm_pool_destroy(fmt->orphan_vg->fid->mem);
-	dm_pool_destroy(fmt->orphan_vg->vgmem);
+	if (fmt->orphan_vg)
+		free_orphan_vg(fmt->orphan_vg);
 
 	dm_free(fmt);
 }
--- LVM2/lib/format_text/format-text.c	2012/02/13 10:56:31	1.191
+++ LVM2/lib/format_text/format-text.c	2012/02/13 11:04:00	1.192
@@ -1541,13 +1541,8 @@
 
 static void _text_destroy(struct format_type *fmt)
 {
-	/* FIXME out of place, but the main (cmd) pool has been already
-	 * destroyed and touching the fid (also via release_vg) will crash the
-	 * program */
-	dm_hash_destroy(fmt->orphan_vg->fid->metadata_areas_index);
-	dm_hash_destroy(fmt->orphan_vg->hostnames);
-	dm_pool_destroy(fmt->orphan_vg->fid->mem);
-	dm_pool_destroy(fmt->orphan_vg->vgmem);
+	if (fmt->orphan_vg)
+		free_orphan_vg(fmt->orphan_vg);
 
 	if (fmt->private) {
 		_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
--- LVM2/lib/metadata/metadata.c	2012/02/13 11:01:35	1.483
+++ LVM2/lib/metadata/metadata.c	2012/02/13 11:04:00	1.484
@@ -1551,7 +1551,6 @@
 	return pv;
 
 bad:
-	free_pv_fid(pv);
 	return NULL;
 }
 
@@ -1575,6 +1574,7 @@
 
 /**
  * pv_create - initialize a physical volume for use with a volume group
+ * created PV belongs to Orphan VG.
  *
  * @fmt: format type
  * @dev: PV device to initialize
@@ -1609,9 +1609,10 @@
 				  unsigned metadataignore)
 {
 	const struct format_type *fmt = cmd->fmt;
-	struct dm_pool *mem = fmt->cmd->mem;
+	struct dm_pool *mem = fmt->orphan_vg->vgmem;
 	struct physical_volume *pv = _alloc_pv(mem, dev);
 	unsigned mda_index;
+	struct pv_list *pvl;
 
 	if (!pv)
 		return_NULL;
@@ -1650,7 +1651,6 @@
 		goto bad;
 	}
 
-	struct pv_list *pvl;
 	if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
 		log_error("pv_list allocation in pv_create failed");
 		goto bad;
@@ -1687,8 +1687,9 @@
 	return pv;
 
       bad:
-	free_pv_fid(pv);
-	dm_pool_free(mem, pv);
+	// FIXME: detach from orphan in error path
+	//free_pv_fid(pv);
+	//dm_pool_free(mem, pv);
 	return NULL;
 }
 
--- LVM2/lib/metadata/vg.c	2012/02/10 02:53:05	1.16
+++ LVM2/lib/metadata/vg.c	2012/02/13 11:04:00	1.17
@@ -90,6 +90,18 @@
 	_free_vg(vg);
 }
 
+/*
+ * FIXME out of place, but the main (cmd) pool has been already
+ * destroyed and touching the fid (also via release_vg) will crash the
+ * program
+ *
+ * For now quick wrapper to allow destroy of orphan vg
+ */
+void free_orphan_vg(struct volume_group *vg)
+{
+	_free_vg(vg);
+}
+
 char *vg_fmt_dup(const struct volume_group *vg)
 {
 	if (!vg->fid || !vg->fid->fmt)
--- LVM2/lib/metadata/vg.h	2012/01/19 15:31:45	1.17
+++ LVM2/lib/metadata/vg.h	2012/02/13 11:04:00	1.18
@@ -121,6 +121,7 @@
  * by vg_create() or vg_read_internal() to free it when no longer required.
  */
 void release_vg(struct volume_group *vg);
+void free_orphan_vg(struct volume_group *vg);
 
 char *vg_fmt_dup(const struct volume_group *vg);
 char *vg_name_dup(const struct volume_group *vg);
--- LVM2/tools/pvcreate.c	2011/08/30 14:55:19	1.97
+++ LVM2/tools/pvcreate.c	2012/02/13 11:04:00	1.98
@@ -117,7 +117,6 @@
 			ret = ECMD_FAILED;
 		}
 
-		free_pv_fid(pv);
 		unlock_vg(cmd, VG_ORPHANS);
 		if (sigint_caught())
 			return ret;
--- LVM2/tools/vgconvert.c	2011/03/11 14:56:56	1.51
+++ LVM2/tools/vgconvert.c	2012/02/13 11:04:00	1.52
@@ -146,7 +146,6 @@
 				  pv_dev_name(pv));
 			log_error("Use pvcreate and vgcfgrestore to repair "
 				  "from archived metadata.");
-			free_pv_fid(pv);
 			return ECMD_FAILED;
 		}
 
@@ -157,13 +156,10 @@
 				  pv_dev_name(pv));
 			log_error("Use pvcreate and vgcfgrestore to repair "
 				  "from archived metadata.");
-			free_pv_fid(pv);
 			return ECMD_FAILED;
 		}
 		log_verbose("Physical volume \"%s\" successfully created",
 			    pv_dev_name(pv));
-
-		free_pv_fid(pv);
 	}
 
 	log_verbose("Deleting existing metadata for VG %s", vg_name);


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2012-02-13 10:56 zkabelac
  0 siblings, 0 replies; 12+ messages in thread
From: zkabelac @ 2012-02-13 10:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

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

Log message:
	Clean error paths for format instance
	
	With updated orphan VG code this code needed some updates.
	Add missing log_error for allocation failures.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2282&r2=1.2283
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.144&r2=1.145
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.190&r2=1.191

--- LVM2/WHATS_NEW	2012/02/13 10:53:31	1.2282
+++ LVM2/WHATS_NEW	2012/02/13 10:56:31	1.2283
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Clean error paths for format instance creation (2.02.91).
   Release vg in error path of _format1_vg_read() instead of just free().
   Report allocation failure for allocation of PV structure.
   Add clvmd init dependency on dlm service when running with new corosync.
--- LVM2/lib/format1/format1.c	2012/02/13 10:53:32	1.144
+++ LVM2/lib/format1/format1.c	2012/02/13 10:56:31	1.145
@@ -580,8 +580,10 @@
 	struct format_instance_ctx fic;
 	struct format_instance *fid;
 
-	if (!fmt)
-		return_NULL;
+	if (!fmt) {
+		log_error("Failed to allocate format1 format type structure.");
+		return NULL;
+	}
 
 	fmt->cmd = cmd;
 	fmt->ops = &_format1_ops;
@@ -607,15 +609,19 @@
 
 	if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name))) {
 		log_error("Couldn't create lvm1 orphan VG.");
+		dm_free(fmt);
 		return NULL;
 	}
+
 	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
 	fic.context.vg_ref.vg_id = NULL;
+
 	if (!(fid = _format1_create_instance(fmt, &fic))) {
-		log_error("Couldn't create lvm1 orphan VG format instance.");
-		return NULL;
+		_format1_destroy(fmt);
+		return_NULL;
 	}
+
 	vg_set_fid(fmt->orphan_vg, fid);
 
 	log_very_verbose("Initialised format: %s", fmt->name);
--- LVM2/lib/format_pool/format_pool.c	2012/02/12 23:01:19	1.48
+++ LVM2/lib/format_pool/format_pool.c	2012/02/13 10:56:31	1.49
@@ -320,15 +320,19 @@
 
 	if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name))) {
 		log_error("Couldn't create lvm1 orphan VG.");
+		dm_free(fmt);
 		return NULL;
 	}
+
 	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
 	fic.context.vg_ref.vg_id = NULL;
+
 	if (!(fid = _pool_create_instance(fmt, &fic))) {
-		log_error("Couldn't create lvm1 orphan VG format instance.");
+		_pool_destroy(fmt);
 		return NULL;
 	}
+
 	vg_set_fid(fmt->orphan_vg, fid);
 
 	log_very_verbose("Initialised format: %s", fmt->name);
--- LVM2/lib/format_text/format-text.c	2012/02/12 23:01:19	1.190
+++ LVM2/lib/format_text/format-text.c	2012/02/13 10:56:31	1.191
@@ -2270,8 +2270,10 @@
 	const struct dm_config_value *cv;
 	struct mda_lists *mda_lists;
 
-	if (!(fmt = dm_malloc(sizeof(*fmt))))
-		return_NULL;
+	if (!(fmt = dm_malloc(sizeof(*fmt)))) {
+		log_error("Failed to allocate text format type structure.");
+		return NULL;
+	}
 
 	fmt->cmd = cmd;
 	fmt->ops = &_text_handler;
@@ -2296,13 +2298,13 @@
 
 	if (!(fmt->labeller = text_labeller_create(fmt))) {
 		log_error("Couldn't create text label handler.");
-		goto err;
+		goto bad;
 	}
 
 	if (!(label_register_handler(FMT_TEXT_NAME, fmt->labeller))) {
 		log_error("Couldn't register text label handler.");
 		fmt->labeller->ops->destroy(fmt->labeller);
-		goto err;
+		goto bad;
 	}
 
 	if ((cn = find_config_tree_node(cmd, "metadata/dirs"))) {
@@ -2310,13 +2312,13 @@
 			if (cv->type != DM_CFG_STRING) {
 				log_error("Invalid string in config file: "
 					  "metadata/dirs");
-				goto err;
+				goto bad;
 			}
 
 			if (!_add_dir(cv->v.str, &mda_lists->dirs)) {
 				log_error("Failed to add %s to text format "
 					  "metadata directory list ", cv->v.str);
-				goto err;
+				goto bad;
 			}
 			cmd->independent_metadata_areas = 1;
 		}
@@ -2325,31 +2327,26 @@
 	if ((cn = find_config_tree_node(cmd, "metadata/disk_areas"))) {
 		for (cn = cn->child; cn; cn = cn->sib) {
 			if (!_get_config_disk_area(cmd, cn, &mda_lists->raws))
-				goto err;
+				goto_bad;
 			cmd->independent_metadata_areas = 1;
 		}
 	}
 
-	if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name))) {
-		dm_free(fmt);
-		return NULL;
-	}
+	if (!(fmt->orphan_vg = alloc_vg("text_orphan", cmd, fmt->orphan_vg_name)))
+		goto_bad;
 
 	fic.type = FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = fmt->orphan_vg_name;
 	fic.context.vg_ref.vg_id = NULL;
-	if (!(fid = _text_create_text_instance(fmt, &fic))) {
-		log_error("Failed to create format instance");
-		release_vg(fmt->orphan_vg);
-		goto err;
-	}
+	if (!(fid = _text_create_text_instance(fmt, &fic)))
+		goto_bad;
+
 	vg_set_fid(fmt->orphan_vg, fid);
 
 	log_very_verbose("Initialised format: %s", fmt->name);
 
 	return fmt;
-
-      err:
+bad:
 	_text_destroy(fmt);
 
 	return NULL;


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2012-02-08 10:49 zkabelac
  0 siblings, 0 replies; 12+ messages in thread
From: zkabelac @ 2012-02-08 10:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-08 10:49:37

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

Log message:
	Fix resource leaks for failing allocation
	
	In case, something would fail during format initialization,
	return allocated memory.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2259&r2=1.2260
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.139&r2=1.140
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.186&r2=1.187

--- LVM2/WHATS_NEW	2012/02/08 10:46:24	1.2259
+++ LVM2/WHATS_NEW	2012/02/08 10:49:36	1.2260
@@ -1,5 +1,6 @@
 Version 2.02.91 -
 ===================================
+  Fix resource leaks for failing allocation of formats (lvm1/2,pool).
   Release allocated resources in error path for composite_filter_create().
   Do not use lstat() results when failed in _rm_link().
   Remove a "waiting for another thread" log message from dmeventd plugins.
--- LVM2/lib/format1/format1.c	2011/06/01 19:29:32	1.139
+++ LVM2/lib/format1/format1.c	2012/02/08 10:49:36	1.140
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -587,11 +587,14 @@
 
 	if (!(fmt->labeller = lvm1_labeller_create(fmt))) {
 		log_error("Couldn't create lvm1 label handler.");
+		dm_free(fmt);
 		return NULL;
 	}
 
 	if (!(label_register_handler(FMT_LVM1_NAME, fmt->labeller))) {
 		log_error("Couldn't register lvm1 label handler.");
+		fmt->labeller->ops->destroy(fmt->labeller);
+		dm_free(fmt);
 		return NULL;
 	}
 
--- LVM2/lib/format_pool/format_pool.c	2011/08/10 20:25:30	1.45
+++ LVM2/lib/format_pool/format_pool.c	2012/02/08 10:49:36	1.46
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1997-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -298,11 +298,14 @@
 
 	if (!(fmt->labeller = pool_labeller_create(fmt))) {
 		log_error("Couldn't create pool label handler.");
+		dm_free(fmt);
 		return NULL;
 	}
 
 	if (!(label_register_handler(FMT_POOL_NAME, fmt->labeller))) {
 		log_error("Couldn't register pool label handler.");
+		fmt->labeller->ops->destroy(fmt->labeller);
+		dm_free(fmt);
 		return NULL;
 	}
 
--- LVM2/lib/format_text/format-text.c	2011/11/18 19:31:10	1.186
+++ LVM2/lib/format_text/format-text.c	2012/02/08 10:49:36	1.187
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -2362,14 +2362,13 @@
 
 	if (!(fmt->labeller = text_labeller_create(fmt))) {
 		log_error("Couldn't create text label handler.");
-		dm_free(fmt);
-		return NULL;
+		goto err;
 	}
 
 	if (!(label_register_handler(FMT_TEXT_NAME, fmt->labeller))) {
 		log_error("Couldn't register text label handler.");
-		dm_free(fmt);
-		return NULL;
+		fmt->labeller->ops->destroy(fmt->labeller);
+		goto err;
 	}
 
 	if ((cn = find_config_tree_node(cmd, "metadata/dirs"))) {
@@ -2402,8 +2401,7 @@
 	return fmt;
 
       err:
-	_free_dirs(&mda_lists->dirs);
+	_text_destroy(fmt);
 
-	dm_free(fmt);
 	return NULL;
 }


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2011-03-11 15:10 prajnoha
  0 siblings, 0 replies; 12+ messages in thread
From: prajnoha @ 2011-03-11 15:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

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

Log message:
	Use format instance mempool where possible and adequate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1950&r2=1.1951
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.177&r2=1.178
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.447&r2=1.448

--- LVM2/WHATS_NEW	2011/03/11 15:06:13	1.1950
+++ LVM2/WHATS_NEW	2011/03/11 15:10:16	1.1951
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Use format instance mempool where possible and adequate.
   Call destroy_instance for any PVs found in VG structure during vg_free call.
   Add new free_pv_fid fn and use it throughout to free all attached fids.
   Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
--- LVM2/lib/format1/format1.c	2011/03/11 14:50:14	1.137
+++ LVM2/lib/format1/format1.c	2011/03/11 15:10:16	1.138
@@ -508,10 +508,9 @@
 		return_NULL;
 
 	/* Define a NULL metadata area */
-	if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
+	if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda)))) {
 		log_error("Unable to allocate metadata area structure "
 			  "for lvm1 format");
-		dm_pool_free(fmt->cmd->mem, fid);
 		goto bad;
 	}
 
--- LVM2/lib/format_pool/format_pool.c	2011/03/11 14:50:14	1.43
+++ LVM2/lib/format_pool/format_pool.c	2011/03/11 15:10:16	1.44
@@ -233,10 +233,9 @@
 		return_NULL;
 
 	/* Define a NULL metadata area */
-	if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
+	if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda)))) {
 		log_error("Unable to allocate metadata area structure "
 			  "for pool format");
-		dm_pool_free(fmt->cmd->mem, fid);
 		goto bad;
 	}
 
--- LVM2/lib/format_text/format-text.c	2011/03/11 14:50:15	1.177
+++ LVM2/lib/format_text/format-text.c	2011/03/11 15:10:17	1.178
@@ -1659,7 +1659,7 @@
 
 			/* 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->fmt->cmd->mem, pv_mda);
+				pv_mda_copy = mda_copy(vg->fid->mem, pv_mda);
 				fid_add_mda(vg->fid, pv_mda_copy, pvid, ID_LEN, mda_index);
 			}
 		}
@@ -1727,14 +1727,14 @@
 	struct lvmcache_info *info;
 
 	if (!(fid_pv_tc = (struct text_fid_pv_context *)
-			dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*fid_pv_tc)))) {
+			dm_pool_zalloc(fid->mem, sizeof(*fid_pv_tc)))) {
 		log_error("Couldn't allocate text_fid_pv_context.");
 		return 0;
 	}
 	fid_pv_tc->label_sector = -1;
 	fid->private = (void *) fid_pv_tc;
 
-	if (!(fid->metadata_areas_index.array = dm_pool_zalloc(fid->fmt->cmd->mem,
+	if (!(fid->metadata_areas_index.array = dm_pool_zalloc(fid->mem,
 					FMT_TEXT_MAX_MDAS_PER_PV *
 					sizeof(struct metadata_area *)))) {
 		log_error("Couldn't allocate format instance metadata index.");
@@ -1811,7 +1811,7 @@
 	const char *vg_name, *vg_id;
 
 	if (!(fidtc = (struct text_fid_context *)
-			dm_pool_zalloc(fid->fmt->cmd->mem,sizeof(*fidtc)))) {
+			dm_pool_zalloc(fid->mem, sizeof(*fidtc)))) {
 		log_error("Couldn't allocate text_fid_context.");
 		return 0;
 	}
@@ -1820,10 +1820,10 @@
 	fid->private = (void *) fidtc;
 
 	if (type & FMT_INSTANCE_PRIVATE_MDAS) {
-		if (!(mda = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mda))))
+		if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
 			return_0;
 		mda->ops = &_metadata_text_file_backup_ops;
-		mda->metadata_locn = _create_text_context(fid->fmt->cmd->mem, fic->context.private);
+		mda->metadata_locn = _create_text_context(fid->mem, fic->context.private);
 		mda->status = 0;
 		fid->metadata_areas_index.hash = NULL;
 		fid_add_mda(fid, mda, NULL, 0, 0);
@@ -1845,12 +1845,12 @@
 					return 0;
 				}
 
-				if (!(mda = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mda))))
+				if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
 					return_0;
 				mda->ops = &_metadata_text_file_ops;
 				tc.path_live = path;
 				tc.path_edit = tc.desc = NULL;
-				mda->metadata_locn = _create_text_context(fid->fmt->cmd->mem, &tc);
+				mda->metadata_locn = _create_text_context(fid->mem, &tc);
 				mda->status = 0;
 				fid_add_mda(fid, mda, NULL, 0, 0);
 			}
@@ -1861,10 +1861,10 @@
 				if (!_raw_holds_vgname(fid, &rl->dev_area, vg_name))
 					continue;
 
-				if (!(mda = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mda))))
+				if (!(mda = dm_pool_zalloc(fid->mem, sizeof(*mda))))
 					return_0;
 
-				if (!(mdac = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*mdac))))
+				if (!(mdac = dm_pool_zalloc(fid->mem, sizeof(*mdac))))
 					return_0;
 				mda->metadata_locn = mdac;
 				/* FIXME Allow multiple dev_areas inside area */
@@ -1912,12 +1912,12 @@
 					  pv->fmt->name);
 	}
 
-	if (!(mda = dm_malloc(sizeof(struct metadata_area)))) {
+	if (!(mda = dm_pool_zalloc(pv->fid->mem, sizeof(struct metadata_area)))) {
 		log_error("struct metadata_area allocation failed");
 		return 0;
 	}
 
-	if (!(mdac = dm_malloc(sizeof(struct mda_context)))) {
+	if (!(mdac = dm_pool_zalloc(pv->fid->mem, sizeof(struct mda_context)))) {
 		log_error("struct mda_context allocation failed");
 		dm_free(mda);
 		return 0;
@@ -2244,7 +2244,6 @@
 					  _create_pv_text_instance(fid, fic))
 		return fid;
 
-	dm_pool_free(fmt->cmd->mem, fid);
 	dm_pool_destroy(fid->mem);
 	return NULL;
 }
--- LVM2/lib/metadata/metadata.c	2011/03/11 15:08:32	1.447
+++ LVM2/lib/metadata/metadata.c	2011/03/11 15:10:17	1.448
@@ -4025,7 +4025,7 @@
 	if (!(mem = dm_pool_create("format_instance", 1024)))
 		return_NULL;
 
-	if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
+	if (!(fid = dm_pool_zalloc(mem, sizeof(*fid)))) {
 		log_error("Couldn't allocate format_instance object.");
 		goto bad;
 	}
@@ -4117,7 +4117,7 @@
 	unsigned mda_index = 0;
 
 	dm_list_iterate_items(mda, mdas) {
-		mda_new = mda_copy(fid->fmt->cmd->mem, mda);
+		mda_new = mda_copy(fid->mem, mda);
 		if (!mda_new)
 			return_0;
 		fid_remove_mda(fid, NULL, key, key_len, mda_index);


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2011-03-11 14:50 prajnoha
  0 siblings, 0 replies; 12+ messages in thread
From: prajnoha @ 2011-03-11 14:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

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

Log message:
	Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
	
	This is essential for proper format instance ref_count support. We must
	use these functions to set the fid everywhere from now on, even the NULL
	value!

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1947&r2=1.1948
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.136&r2=1.137
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.176&r2=1.177
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.443&r2=1.444
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.241&r2=1.242

--- LVM2/WHATS_NEW	2011/03/11 14:45:17	1.1947
+++ LVM2/WHATS_NEW	2011/03/11 14:50:13	1.1948
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
   Make create_text_context fn static and move it inside create_instance fn.
   Add mem and ref_count fields to struct format_instance for own mempool use.
   Use new alloc_fid fn for common format instance initialisation.
--- LVM2/lib/format1/format1.c	2011/03/11 14:38:39	1.136
+++ LVM2/lib/format1/format1.c	2011/03/11 14:50:14	1.137
@@ -198,7 +198,7 @@
 	if (dm_list_empty(&pvs))
 		goto_bad;
 
-	vg->fid = fid;
+	vg_set_fid(vg, fid);
 
 	if (!_check_vgs(&pvs, vg))
 		goto_bad;
--- LVM2/lib/format_pool/format_pool.c	2011/03/11 14:38:39	1.42
+++ LVM2/lib/format_pool/format_pool.c	2011/03/11 14:50:14	1.43
@@ -120,7 +120,8 @@
 	if (!read_pool_pds(fid->fmt, vg_name, vg->vgmem, &pds))
 		goto_bad;
 
-	vg->fid = fid;
+	vg_set_fid(vg, fid);
+
 	/* Setting pool seqno to 1 because the code always did this,
 	 * although we don't think it's needed. */
 	vg->seqno = 1;
--- LVM2/lib/format_text/format-text.c	2011/03/11 14:45:18	1.176
+++ LVM2/lib/format_text/format-text.c	2011/03/11 14:50:15	1.177
@@ -1690,12 +1690,8 @@
 	    (pv_mdac = pv_mda->metadata_locn))
 		size_reduction = pv_mdac->area.size >> SECTOR_SHIFT;
 
-	/* Destroy old PV-based format instance if it exists. */
-	if (!(pv->fid->type & FMT_INSTANCE_VG))
-		pv->fmt->ops->destroy_instance(pv->fid);
-
 	/* From now on, VG format instance will be used. */
-	pv->fid = vg->fid;
+	pv_set_fid(pv, vg->fid);
 
 	/* FIXME Cope with genuine pe_count 0 */
 
--- LVM2/lib/format_text/import_vsn1.c	2011/03/10 12:43:29	1.83
+++ LVM2/lib/format_text/import_vsn1.c	2011/03/11 14:50:15	1.84
@@ -666,10 +666,6 @@
 	if (!(vg = alloc_vg("read_vg", fid->fmt->cmd, vgn->key)))
 		return_NULL;
 
-	/* FIXME Determine format type from file contents */
-	/* eg Set to instance of fmt1 here if reading a format1 backup? */
-	vg->fid = fid;
-
 	if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN)))
 		goto_bad;
 
@@ -796,6 +792,10 @@
 	dm_hash_destroy(pv_hash);
 	dm_hash_destroy(lv_hash);
 
+	/* FIXME Determine format type from file contents */
+	/* eg Set to instance of fmt1 here if reading a format1 backup? */
+	vg_set_fid(vg, fid);
+
 	/*
 	 * Finished.
 	 */
--- LVM2/lib/metadata/metadata.c	2011/03/11 14:38:39	1.443
+++ LVM2/lib/metadata/metadata.c	2011/03/11 14:50:15	1.444
@@ -166,14 +166,24 @@
 	dm_list_add(&vg->pvs, &pvl->list);
 	vg->pv_count++;
 	pvl->pv->vg = vg;
-	pvl->pv->fid = vg->fid;
+	pv_set_fid(pvl->pv, vg->fid);
 }
 
 void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
 {
+	struct format_instance_ctx fic;
+	struct format_instance *fid;
+
 	vg->pv_count--;
 	dm_list_del(&pvl->list);
 	pvl->pv->vg = NULL; /* orphan */
+
+	/* Use a new PV-based format instance since the PV is orphan now. */
+	fic.type = FMT_INSTANCE_PV | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+	fic.context.pv_id = (const char *) &pvl->pv->id;
+	fid = pvl->pv->fid->fmt->ops->create_instance(pvl->pv->fid->fmt, &fic);
+
+	pv_set_fid(pvl->pv, fid);
 }
 
 
@@ -288,6 +298,10 @@
 {
 	memcpy(pv_to, pv_from, sizeof(*pv_to));
 
+	/* We must use pv_set_fid here to update the reference counter! */
+	pv_to->fid = NULL;
+	pv_set_fid(pv_to, pv_from->fid);
+
 	if (!(pv_to->vg_name = dm_pool_strdup(pvmem, pv_from->vg_name)))
 		return_0;
 
@@ -881,6 +895,7 @@
 {
 	struct volume_group *vg;
 	struct format_instance_ctx fic;
+	struct format_instance *fid;
 	int consistent = 0;
 	uint32_t rc;
 
@@ -937,10 +952,11 @@
 	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = vg_name;
 	fic.context.vg_ref.vg_id = NULL;
-	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
+	if (!(fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
 		log_error("Failed to create format instance");
 		goto bad;
 	}
+	vg_set_fid(vg, fid);
 
 	if (vg->fid->fmt->ops->vg_setup &&
 	    !vg->fid->fmt->ops->vg_setup(vg->fid, vg)) {
@@ -1507,7 +1523,7 @@
 	if (!pv)
 		return_NULL;
 
-	pv->fid = NULL;
+	pv_set_fid(pv, NULL);
 	pv->pe_size = 0;
 	pv->pe_start = 0;
 	pv->pe_count = 0;
@@ -1562,6 +1578,7 @@
 {
 	const struct format_type *fmt = cmd->fmt;
 	struct format_instance_ctx fic;
+	struct format_instance *fid;
 	struct dm_pool *mem = fmt->cmd->mem;
 	struct physical_volume *pv = _alloc_pv(mem, dev);
 	unsigned mda_index;
@@ -1605,10 +1622,11 @@
 
 	fic.type = FMT_INSTANCE_PV;
 	fic.context.pv_id = (const char *) &pv->id;
-	if (!(pv->fid = fmt->ops->create_instance(fmt, &fic))) {
+	if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
 		log_error("Couldn't create format instance for PV %s.", pv_dev_name(pv));
 		goto bad;
 	}
+	pv_set_fid(pv, fid);
 
 	pv->fmt = fmt;
 	pv->vg_name = fmt->orphan_vg_name;
@@ -2615,6 +2633,7 @@
 					     const char *orphan_vgname)
 {
 	struct format_instance_ctx fic;
+	struct format_instance *fid;
 	struct lvmcache_vginfo *vginfo;
 	struct lvmcache_info *info;
 	struct pv_list *pvl;
@@ -2633,10 +2652,11 @@
 	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = orphan_vgname;
 	fic.context.vg_ref.vg_id = NULL;
-	if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt, &fic))) {
+	if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt, &fic))) {
 		log_error("Failed to create format instance");
 		goto bad;
 	}
+	vg_set_fid(vg, fid);
 
 	dm_list_iterate_items(info, &vginfo->infos) {
 		if (!(pv = _pv_read(cmd, vg->vgmem, dev_name(info->dev),
@@ -3415,11 +3435,12 @@
 	else {
 		fic.type = FMT_INSTANCE_PV | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 		fic.context.pv_id = (const char *) &pv->id;
-		if (!(pv->fid = pv->fmt->ops->create_instance(pv->fmt, &fic))) {
+		if (!(fid = pv->fmt->ops->create_instance(pv->fmt, &fic))) {
 			log_error("_pv_read: Couldn't create format instance "
 				  "for PV %s", pv_name);
 			goto bad;
 		}
+		pv_set_fid(pv, fid);
 	}
 
 	return pv;
@@ -3970,14 +3991,31 @@
 	return NULL;
 }
 
+void pv_set_fid(struct physical_volume *pv,
+		struct format_instance *fid)
+{
+	if (pv->fid)
+		pv->fid->fmt->ops->destroy_instance(pv->fid);
+
+	pv->fid = fid;
+	if (fid)
+		fid->ref_count++;
+}
+
 void vg_set_fid(struct volume_group *vg,
 		 struct format_instance *fid)
 {
 	struct pv_list *pvl;
 
+	if (vg->fid)
+		vg->fid->fmt->ops->destroy_instance(vg->fid);
+
 	vg->fid = fid;
+	if (fid)
+		fid->ref_count++;
+
 	dm_list_iterate_items(pvl, &vg->pvs)
-		pvl->pv->fid = fid;
+		pv_set_fid(pvl->pv, fid);
 }
 
 static int _convert_key_to_string(const char *key, size_t key_len,
--- LVM2/lib/metadata/metadata.h	2011/03/11 14:30:28	1.241
+++ LVM2/lib/metadata/metadata.h	2011/03/11 14:50:15	1.242
@@ -206,7 +206,15 @@
 
 struct format_instance *alloc_fid(const struct format_type *fmt,
 				  const struct format_instance_ctx *fic);
+
+/*
+ * Format instance must always be set using pv_set_fid or vg_set_fid
+ * (NULL value as well), never asign it directly! This is essential
+ * for proper reference counting for the format instance.
+ */
+void pv_set_fid(struct physical_volume *pv, struct format_instance *fid);
 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);


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2011-03-11 14:38 prajnoha
  0 siblings, 0 replies; 12+ messages in thread
From: prajnoha @ 2011-03-11 14:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-03-11 14:38:40

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

Log message:
	Add mem and ref_count fields to struct format_instance for own mempool use.
	
	Format instances can be created anytime on demand and it contains
	metadata area information mostly (at least for now, but in the future,
	we may store more things here to update/edit in a PV/VG). In case we
	have lots of metadata areas, memory consumption will rise. Using cmd
	context mempool is not quite optimal here because it is destroyed too
	late. So let's use a separate mempool for format instances.
	
	Reference counting is used because fids could be shared, e.g. each PV
	has either a PV-based fid or VG-based fid. If it's VG-based, each PV has
	a shared fid with the VG - a reference to VG's fid.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1945&r2=1.1946
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.174&r2=1.175
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.185&r2=1.186
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.442&r2=1.443

--- LVM2/WHATS_NEW	2011/03/11 14:30:27	1.1945
+++ LVM2/WHATS_NEW	2011/03/11 14:38:38	1.1946
@@ -1,9 +1,10 @@
 Version 2.02.85 - 
 ===================================
+  Add mem and ref_count fields to struct format_instance for own mempool use.
   Use new alloc_fid fn for common format instance initialisation.
   Optimise _get_token() and _eat_space().
   Add _lv_postorder_vg() to improve efficiency for all LVs in VG.
-  Use hash tables to speedup string search in validate_vg().
+  Use hash tables to speedup string search in vg_validate().
   Refactor allocation of VG structure, add alloc_vg().
   Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name.
   Use empty string instead of /dev// for LV path when there's no VG.
--- LVM2/lib/format1/format1.c	2011/03/11 14:30:27	1.135
+++ LVM2/lib/format1/format1.c	2011/03/11 14:38:39	1.136
@@ -509,8 +509,10 @@
 
 	/* Define a NULL metadata area */
 	if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
+		log_error("Unable to allocate metadata area structure "
+			  "for lvm1 format");
 		dm_pool_free(fmt->cmd->mem, fid);
-		return_NULL;
+		goto bad;
 	}
 
 	mda->ops = &_metadata_format1_ops;
@@ -519,10 +521,16 @@
 	dm_list_add(&fid->metadata_areas_in_use, &mda->list);
 
 	return fid;
+
+bad:
+	dm_pool_destroy(fid->mem);
+	return NULL;
 }
 
-static void _format1_destroy_instance(struct format_instance *fid __attribute__((unused)))
+static void _format1_destroy_instance(struct format_instance *fid)
 {
+	if (--fid->ref_count <= 1)
+		dm_pool_destroy(fid->mem);
 }
 
 static void _format1_destroy(struct format_type *fmt)
--- LVM2/lib/format_pool/format_pool.c	2011/03/11 14:30:27	1.41
+++ LVM2/lib/format_pool/format_pool.c	2011/03/11 14:38:39	1.42
@@ -236,7 +236,7 @@
 		log_error("Unable to allocate metadata area structure "
 			  "for pool format");
 		dm_pool_free(fmt->cmd->mem, fid);
-		return NULL;
+		goto bad;
 	}
 
 	mda->ops = &_metadata_format_pool_ops;
@@ -245,10 +245,16 @@
 	dm_list_add(&fid->metadata_areas_in_use, &mda->list);
 
 	return fid;
+
+bad:
+	dm_pool_destroy(fid->mem);
+	return NULL;
 }
 
-static void _pool_destroy_instance(struct format_instance *fid __attribute__((unused)))
+static void _pool_destroy_instance(struct format_instance *fid)
 {
+	if (--fid->ref_count <= 1)
+		dm_pool_destroy(fid->mem);
 }
 
 static void _pool_destroy(struct format_type *fmt)
--- LVM2/lib/format_text/format-text.c	2011/03/11 14:30:27	1.174
+++ LVM2/lib/format_text/format-text.c	2011/03/11 14:38:39	1.175
@@ -1571,8 +1571,13 @@
 	return 1;
 }
 
-static void _text_destroy_instance(struct format_instance *fid __attribute__((unused)))
+static void _text_destroy_instance(struct format_instance *fid)
 {
+	if (--fid->ref_count <= 1) {
+		if (fid->type & FMT_INSTANCE_VG && fid->metadata_areas_index.hash)
+			dm_hash_destroy(fid->metadata_areas_index.hash);
+		dm_pool_destroy(fid->mem);
+	}
 }
 
 static void _free_dirs(struct dm_list *dir_list)
@@ -2188,28 +2193,21 @@
 	return 1;
 }
 
-/* NULL vgname means use only the supplied context e.g. an archive file */
 static struct format_instance *_text_create_text_instance(const struct format_type *fmt,
 							  const struct format_instance_ctx *fic)
 {
 	struct format_instance *fid;
-	int r;
 
 	if (!(fid = alloc_fid(fmt, fic)))
 		return_NULL;
 
-	if (fid->type & FMT_INSTANCE_VG)
-		r = _create_vg_text_instance(fid, fic);
-	else
-		r = _create_pv_text_instance(fid, fic);
-
-	if (r)
+	if (fid->type & FMT_INSTANCE_VG ? _create_vg_text_instance(fid, fic) :
+					  _create_pv_text_instance(fid, fic))
 		return fid;
-	else {
-		dm_pool_free(fmt->cmd->mem, fid);
-		return NULL;
-	}
 
+	dm_pool_free(fmt->cmd->mem, fid);
+	dm_pool_destroy(fid->mem);
+	return NULL;
 }
 
 void *create_text_context(struct cmd_context *cmd, const char *path,
--- LVM2/lib/metadata/metadata-exported.h	2011/03/02 20:00:09	1.185
+++ LVM2/lib/metadata/metadata-exported.h	2011/03/11 14:38:39	1.186
@@ -196,6 +196,9 @@
 #define FMT_INSTANCE_PRIVATE_MDAS 	0x00000008U
 
 struct format_instance {
+	unsigned ref_count;
+	struct dm_pool *mem;
+
 	uint32_t type;
 	const struct format_type *fmt;
 
--- LVM2/lib/metadata/metadata.c	2011/03/11 14:30:28	1.442
+++ LVM2/lib/metadata/metadata.c	2011/03/11 14:38:39	1.443
@@ -3944,20 +3944,30 @@
 struct format_instance *alloc_fid(const struct format_type *fmt,
 				  const struct format_instance_ctx *fic)
 {
+	struct dm_pool *mem;
 	struct format_instance *fid;
 
+	if (!(mem = dm_pool_create("format_instance", 1024)))
+		return_NULL;
+
 	if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
 		log_error("Couldn't allocate format_instance object.");
-		return NULL;
+		goto bad;
 	}
 
-	fid->fmt = fmt;
+	fid->ref_count = 1;
+	fid->mem = mem;
 	fid->type = fic->type;
+	fid->fmt = fmt;
 
 	dm_list_init(&fid->metadata_areas_in_use);
 	dm_list_init(&fid->metadata_areas_ignored);
 
 	return fid;
+
+bad:
+	dm_pool_destroy(mem);
+	return NULL;
 }
 
 void vg_set_fid(struct volume_group *vg,


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2011-03-11 14:30 prajnoha
  0 siblings, 0 replies; 12+ messages in thread
From: prajnoha @ 2011-03-11 14:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-03-11 14:30:28

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

Log message:
	Use new alloc_fid fn for common format instance initialisation.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1944&r2=1.1945
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.173&r2=1.174
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.441&r2=1.442
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.240&r2=1.241

--- LVM2/WHATS_NEW	2011/03/10 14:51:35	1.1944
+++ LVM2/WHATS_NEW	2011/03/11 14:30:27	1.1945
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Use new alloc_fid fn for common format instance initialisation.
   Optimise _get_token() and _eat_space().
   Add _lv_postorder_vg() to improve efficiency for all LVs in VG.
   Use hash tables to speedup string search in validate_vg().
--- LVM2/lib/format1/format1.c	2011/03/10 12:43:29	1.134
+++ LVM2/lib/format1/format1.c	2011/03/11 14:30:27	1.135
@@ -504,15 +504,9 @@
 	struct format_instance *fid;
 	struct metadata_area *mda;
 
-	if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid))))
+	if (!(fid = alloc_fid(fmt, fic)))
 		return_NULL;
 
-	fid->fmt = fmt;
-	fid->type = fic->type;
-
-	dm_list_init(&fid->metadata_areas_in_use);
-	dm_list_init(&fid->metadata_areas_ignored);
-
 	/* Define a NULL metadata area */
 	if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
 		dm_pool_free(fmt->cmd->mem, fid);
--- LVM2/lib/format_pool/format_pool.c	2011/03/10 12:43:29	1.40
+++ LVM2/lib/format_pool/format_pool.c	2011/03/11 14:30:27	1.41
@@ -228,17 +228,8 @@
 	struct format_instance *fid;
 	struct metadata_area *mda;
 
-	if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
-		log_error("Unable to allocate format instance structure for "
-			  "pool format");
-		return NULL;
-	}
-
-	fid->fmt = fmt;
-	fid->type = fic->type;
-
-	dm_list_init(&fid->metadata_areas_in_use);
-	dm_list_init(&fid->metadata_areas_ignored);
+	if (!(fid = alloc_fid(fmt, fic)))
+		return_NULL;
 
 	/* Define a NULL metadata area */
 	if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
--- LVM2/lib/format_text/format-text.c	2011/03/02 10:23:29	1.173
+++ LVM2/lib/format_text/format-text.c	2011/03/11 14:30:27	1.174
@@ -2190,21 +2190,13 @@
 
 /* NULL vgname means use only the supplied context e.g. an archive file */
 static struct format_instance *_text_create_text_instance(const struct format_type *fmt,
-							   const struct format_instance_ctx *fic)
+							  const struct format_instance_ctx *fic)
 {
 	struct format_instance *fid;
 	int r;
 
-	if (!(fid = dm_pool_alloc(fmt->cmd->mem, sizeof(*fid)))) {
-		log_error("Couldn't allocate format instance object.");
-		return NULL;
-	}
-
-	fid->fmt = fmt;
-	fid->type = fic->type;
-
-	dm_list_init(&fid->metadata_areas_in_use);
-	dm_list_init(&fid->metadata_areas_ignored);
+	if (!(fid = alloc_fid(fmt, fic)))
+		return_NULL;
 
 	if (fid->type & FMT_INSTANCE_VG)
 		r = _create_vg_text_instance(fid, fic);
--- LVM2/lib/metadata/metadata.c	2011/03/10 22:39:36	1.441
+++ LVM2/lib/metadata/metadata.c	2011/03/11 14:30:28	1.442
@@ -3941,6 +3941,25 @@
 	return FAILED_EXIST;
 }
 
+struct format_instance *alloc_fid(const struct format_type *fmt,
+				  const struct format_instance_ctx *fic)
+{
+	struct format_instance *fid;
+
+	if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
+		log_error("Couldn't allocate format_instance object.");
+		return NULL;
+	}
+
+	fid->fmt = fmt;
+	fid->type = fic->type;
+
+	dm_list_init(&fid->metadata_areas_in_use);
+	dm_list_init(&fid->metadata_areas_ignored);
+
+	return fid;
+}
+
 void vg_set_fid(struct volume_group *vg,
 		 struct format_instance *fid)
 {
--- LVM2/lib/metadata/metadata.h	2011/02/28 13:19:02	1.240
+++ LVM2/lib/metadata/metadata.h	2011/03/11 14:30:28	1.241
@@ -191,6 +191,21 @@
 unsigned mda_is_ignored(struct metadata_area *mda);
 void mda_set_ignored(struct metadata_area *mda, unsigned ignored);
 unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2);
+
+struct format_instance_ctx {
+	uint32_t type;
+	union {
+		const char *pv_id;
+		struct {
+			const char *vg_name;
+			const char *vg_id;
+		} vg_ref;
+		void *private;
+	} context;
+};
+
+struct format_instance *alloc_fid(const struct format_type *fmt,
+				  const struct format_instance_ctx *fic);
 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,
@@ -229,18 +244,6 @@
 	struct lv_segment *seg;
 };
 
-struct format_instance_ctx {
-	uint32_t type;
-	union {
-		const char *pv_id;
-		struct {
-			const char *vg_name;
-			const char *vg_id;
-		} vg_ref;
-		void *private;
-	} context;
-};
-
 /*
  * Ownership of objects passes to caller.
  */


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2010-10-05 17:34 wysochanski
  0 siblings, 0 replies; 12+ messages in thread
From: wysochanski @ 2010-10-05 17:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-10-05 17:34:07

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

Log message:
	Rename 'flags' to 'status' for struct metadata_area.
	
	In other LVM memory structures such as volume_group, the field
	used to store flags is called "status", and on-disk fields are called
	'flags', so rename the one inside metadata_area to be consistent.
	Not only is it more consistent with existing code but is cleaner
	to say "the status of this mda is ignored".
	
	Background for this patch - prajnoha pinged me on IRC this morning
	about a fix he was working on related to metadataignore when
	metadata/dirs was set.  I was reviewing my patches from this year
	and realized the 'flags' field was probably not the best choice
	when I originally did the metadataignore patches.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1745&r2=1.1746
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.403&r2=1.404
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.222&r2=1.223

--- LVM2/WHATS_NEW	2010/10/04 18:59:01	1.1745
+++ LVM2/WHATS_NEW	2010/10/05 17:34:05	1.1746
@@ -1,5 +1,6 @@
 Version 2.02.75 - 
 =====================================
+  Rename 'flags' to 'status' in struct metadata_area.
   Avoid segfault by limiting partial mode for lvm1 metadata. (2.02.74)
   Add dm_zalloc and use it and dm_pool_zalloc throughout.
   Add pv_get_property and create generic internal _get_property function.
--- LVM2/lib/format1/format1.c	2010/10/04 18:59:02	1.124
+++ LVM2/lib/format1/format1.c	2010/10/05 17:34:06	1.125
@@ -545,7 +545,7 @@
 
 	mda->ops = &_metadata_format1_ops;
 	mda->metadata_locn = NULL;
-	mda->flags = 0;
+	mda->status = 0;
 	dm_list_add(&fid->metadata_areas_in_use, &mda->list);
 
 	return fid;
--- LVM2/lib/format_pool/format_pool.c	2010/07/09 15:34:44	1.32
+++ LVM2/lib/format_pool/format_pool.c	2010/10/05 17:34:06	1.33
@@ -276,7 +276,7 @@
 
 	mda->ops = &_metadata_format_pool_ops;
 	mda->metadata_locn = NULL;
-	mda->flags = 0;
+	mda->status = 0;
 	dm_list_add(&fid->metadata_areas_in_use, &mda->list);
 
 	return fid;
--- LVM2/lib/format_text/format-text.c	2010/09/30 14:12:14	1.146
+++ LVM2/lib/format_text/format-text.c	2010/10/05 17:34:06	1.147
@@ -1947,7 +1947,7 @@
 			return_NULL;
 		mda->ops = &_metadata_text_file_backup_ops;
 		mda->metadata_locn = context;
-		mda->flags = 0;
+		mda->status = 0;
 		fid_add_mda(fid, mda);
 	} else {
 		dir_list = &((struct mda_lists *) fmt->private)->dirs;
@@ -1965,7 +1965,7 @@
 				return_NULL;
 			mda->ops = &_metadata_text_file_ops;
 			mda->metadata_locn = context;
-			mda->flags = 0;
+			mda->status = 0;
 			fid_add_mda(fid, mda);
 		}
 
@@ -1985,7 +1985,7 @@
 			/* FIXME Allow multiple dev_areas inside area */
 			memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
 			mda->ops = &_metadata_text_raw_ops;
-			mda->flags = 0;
+			mda->status = 0;
 			/* FIXME MISTAKE? mda->metadata_locn = context; */
 			fid_add_mda(fid, mda);
 		}
--- LVM2/lib/format_text/text_label.c	2010/07/09 15:34:44	1.37
+++ LVM2/lib/format_text/text_label.c	2010/10/05 17:34:06	1.38
@@ -216,7 +216,7 @@
 
 	mdal->ops = mda_lists->raw_ops;
 	mdal->metadata_locn = mdac;
-	mdal->flags = 0;
+	mdal->status = 0;
 
 	mdac->area.dev = dev;
 	mdac->area.start = start;
--- LVM2/lib/metadata/metadata.c	2010/09/30 20:47:18	1.403
+++ LVM2/lib/metadata/metadata.c	2010/10/05 17:34:06	1.404
@@ -3839,7 +3839,7 @@
 
 unsigned mda_is_ignored(struct metadata_area *mda)
 {
-	return (mda->flags & MDA_IGNORED);
+	return (mda->status & MDA_IGNORED);
 }
 
 void mda_set_ignored(struct metadata_area *mda, unsigned mda_ignored)
@@ -3848,9 +3848,9 @@
 	unsigned old_mda_ignored = mda_is_ignored(mda);
 
 	if (mda_ignored && !old_mda_ignored)
-		mda->flags |= MDA_IGNORED;
+		mda->status |= MDA_IGNORED;
 	else if (!mda_ignored && old_mda_ignored)
-		mda->flags &= ~MDA_IGNORED;
+		mda->status &= ~MDA_IGNORED;
 	else
 		return;	/* No change */
 
--- LVM2/lib/metadata/metadata.h	2010/09/30 20:47:18	1.222
+++ LVM2/lib/metadata/metadata.h	2010/10/05 17:34:07	1.223
@@ -182,7 +182,7 @@
 	struct dm_list list;
 	struct metadata_area_ops *ops;
 	void *metadata_locn;
-	uint32_t flags;
+	uint32_t status;
 };
 struct metadata_area *mda_copy(struct dm_pool *mem,
 			       struct metadata_area *mda);


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2009-07-30 17:45 snitzer
  0 siblings, 0 replies; 12+ messages in thread
From: snitzer @ 2009-07-30 17:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/format1    : format1.c 
	lib/format_pool: format_pool.c 
	lib/format_text: archiver.c format-text.c 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	man            : pvcreate.8.in 
	tools          : args.h commands.h pvcreate.c vgconvert.c 

Log message:
	Add --dataalignmentoffset to pvcreate to shift start of aligned data area
	
	Adds pe_align_offset to 'struct physical_volume'; is initialized with
	set_pe_align_offset().  After pe_start is established pe_align_offset is
	added to it.
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1215&r2=1.1216
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.106&r2=1.107
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.274&r2=1.275
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.197&r2=1.198
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/pvcreate.8.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.129&r2=1.130
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37

--- LVM2/WHATS_NEW	2009/07/30 17:42:33	1.1215
+++ LVM2/WHATS_NEW	2009/07/30 17:45:28	1.1216
@@ -1,5 +1,6 @@
 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.
   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.
--- LVM2/lib/format1/format1.c	2009/07/27 17:43:39	1.113
+++ LVM2/lib/format1/format1.c	2009/07/30 17:45:28	1.114
@@ -297,6 +297,7 @@
 		     uint64_t pe_start, uint32_t extent_count,
 		     uint32_t extent_size,
 		     unsigned long data_alignment __attribute((unused)),
+		     unsigned long data_alignment_offset __attribute((unused)),
 		     int pvmetadatacopies __attribute((unused)),
 		     uint64_t pvmetadatasize __attribute((unused)), struct dm_list *mdas __attribute((unused)),
 		     struct physical_volume *pv, struct volume_group *vg __attribute((unused)))
--- LVM2/lib/format_pool/format_pool.c	2009/07/27 17:43:40	1.24
+++ LVM2/lib/format_pool/format_pool.c	2009/07/30 17:45:29	1.25
@@ -193,6 +193,7 @@
 			  uint32_t extent_count __attribute((unused)),
 			  uint32_t extent_size __attribute((unused)),
 			  unsigned long data_alignment __attribute((unused)),
+			  unsigned long data_alignment_offset __attribute((unused)),
 			  int pvmetadatacopies __attribute((unused)),
 			  uint64_t pvmetadatasize __attribute((unused)),
 			  struct dm_list *mdas __attribute((unused)),
--- LVM2/lib/format_text/archiver.c	2009/07/15 20:02:47	1.27
+++ LVM2/lib/format_text/archiver.c	2009/07/30 17:45:29	1.28
@@ -320,7 +320,7 @@
 			return 0;
 		}
 		if (!vg->fid->fmt->ops->
-		    pv_setup(vg->fid->fmt, UINT64_C(0), 0, 0, 0, 0UL,
+		    pv_setup(vg->fid->fmt, UINT64_C(0), 0, 0, 0, 0, 0UL,
 			     UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) {
 			log_error("Format-specific setup for %s failed",
 				  pv_dev_name(pv));
--- LVM2/lib/format_text/format-text.c	2009/07/30 17:42:33	1.110
+++ LVM2/lib/format_text/format-text.c	2009/07/30 17:45:29	1.111
@@ -1180,7 +1180,7 @@
 		      struct physical_volume *pv,
 		      struct volume_group *vg __attribute((unused)))
 {
-	uint64_t mda_adjustment, disk_size, alignment;
+	uint64_t mda_adjustment, disk_size, alignment, alignment_offset;
 	uint64_t start1, mda_size1;	/* First area - start of disk */
 	uint64_t start2, mda_size2;	/* Second area - end of disk */
 	uint64_t wipe_size = 8 << SECTOR_SHIFT;
@@ -1190,6 +1190,7 @@
 		return 1;
 
 	alignment = pv->pe_align << SECTOR_SHIFT;
+	alignment_offset = pv->pe_align_offset << SECTOR_SHIFT;
 	disk_size = pv->size << SECTOR_SHIFT;
 	pe_start <<= SECTOR_SHIFT;
 	pe_end <<= SECTOR_SHIFT;
@@ -1223,6 +1224,15 @@
 			mda_size1 -= (alignment - mda_adjustment);
 	}
 
+	/* Add pe_align_offset if on pe_align boundary */
+	if (alignment_offset &&
+	    (((start1 + mda_size1) % alignment) == 0)) {
+		mda_size1 += alignment_offset;
+		/* Revert if it's now too large */
+		if (start1 + mda_size1 > disk_size)
+			mda_size1 -= alignment_offset;
+	}
+
 	/* 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 "
@@ -1379,6 +1389,8 @@
 	 * 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;
 	dm_list_iterate_items(mda, &info->mdas) {
 		mdac = (struct mda_context *) mda->metadata_locn;
 		if (pv->dev == mdac->area.dev &&
@@ -1389,11 +1401,26 @@
 		     (pv->pe_start << SECTOR_SHIFT))) {
 			pv->pe_start = (mdac->area.start + mdac->area.size)
 			    >> SECTOR_SHIFT;
-			adjustment = pv->pe_start % pv->pe_align;
+			/* Adjust pe_start to: (N * pe_align) + pe_align_offset */
+			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, "
+					 "pe_align=%lu, pe_align_offset=%lu, "
+					 "adjustment=%" PRIu64 ")",
+					 pv_dev_name(pv), pv->pe_start,
+					 (adjustment ?
+					  pv->pe_start -= pv->pe_align - adjustment :
+					  pv->pe_start),
+					 pv->pe_align, pv->pe_align_offset, adjustment);
 		}
 	}
+	if (pv->pe_start >= pv->size) {
+		log_error("Data area is beyond end of device %s!",
+			  pv_dev_name(pv));
+		return 0;
+	}
 
  preserve_pe_start:
 	if (!add_da
@@ -1617,6 +1644,7 @@
 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,
+		     unsigned long data_alignment_offset,
 		     int pvmetadatacopies,
 		     uint64_t pvmetadatasize, struct dm_list *mdas,
 		     struct physical_volume *pv, struct volume_group *vg)
@@ -1723,6 +1751,15 @@
 				 "%lu sectors (requested %lu sectors)",
 				 pv_dev_name(pv), pv->pe_align, data_alignment);
 
+		set_pe_align_offset(pv, data_alignment_offset);
+
+		if (pv->pe_align < pv->pe_align_offset) {
+			log_error("%s: pe_align (%lu sectors) must not be less "
+				  "than pe_align_offset (%lu sectors)",
+				  pv_dev_name(pv), pv->pe_align, pv->pe_align_offset);
+			return 0;
+		}
+
 	preserve_pe_start:
 		if (extent_count)
 			pe_end = pe_start + extent_count * extent_size - 1;
--- LVM2/lib/metadata/metadata-exported.h	2009/07/29 13:26:01	1.106
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/30 17:45:29	1.107
@@ -183,6 +183,7 @@
 	uint32_t pe_count;
 	uint32_t pe_alloc_count;
 	unsigned long pe_align;
+	unsigned long pe_align_offset;
 
 	struct dm_list segments;	/* Ordered pv_segments covering complete PV */
 	struct dm_list tags;
@@ -346,6 +347,7 @@
 	int zero;
 	uint64_t size;
 	uint64_t data_alignment;
+	uint64_t data_alignment_offset;
 	int pvmetadatacopies;
 	uint64_t pvmetadatasize;
 	int64_t labelsector;
@@ -424,6 +426,7 @@
 		      struct id *id,
 		      uint64_t size,
 		      unsigned long data_alignment,
+		      unsigned long data_alignment_offset,
 		      uint64_t pe_start,
 		      uint32_t existing_extent_count,
 		      uint32_t existing_extent_size,
--- LVM2/lib/metadata/metadata.c	2009/07/29 13:26:01	1.274
+++ LVM2/lib/metadata/metadata.c	2009/07/30 17:45:29	1.275
@@ -93,6 +93,25 @@
 	return pv->pe_align;
 }
 
+unsigned long set_pe_align_offset(struct physical_volume *pv,
+				  unsigned long data_alignment_offset)
+{
+	if (pv->pe_align_offset)
+		goto out;
+
+	if (data_alignment_offset)
+		pv->pe_align_offset = data_alignment_offset;
+
+	if (!pv->dev)
+		goto out;
+
+	log_very_verbose("%s: Setting PE alignment offset to %lu sectors.",
+			 dev_name(pv->dev), pv->pe_align_offset);
+
+out:
+	return pv->pe_align_offset;
+}
+
 /**
  * add_pv_to_vg - Add a physical volume to a volume group
  * @vg - volume group to add to
@@ -154,7 +173,7 @@
 	pv->pe_alloc_count = 0;
 
 	if (!fid->fmt->ops->pv_setup(fid->fmt, UINT64_C(0), 0,
-				     vg->extent_size, 0, 0UL, UINT64_C(0),
+				     vg->extent_size, 0, 0, 0UL, UINT64_C(0),
 				     &fid->metadata_areas, pv, vg)) {
 		log_error("Format-specific setup of physical volume '%s' "
 			  "failed.", pv_name);
@@ -1191,6 +1210,7 @@
 	pp->zero = 0;
 	pp->size = 0;
 	pp->data_alignment = UINT64_C(0);
+	pp->data_alignment_offset = UINT64_C(0);
 	pp->pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
 	pp->pvmetadatasize = DEFAULT_PVMETADATASIZE;
 	pp->labelsector = DEFAULT_LABELSECTOR;
@@ -1249,8 +1269,8 @@
 
 	dm_list_init(&mdas);
 	if (!(pv = pv_create(cmd, dev, pp->idp, pp->size,
-			     pp->data_alignment, pp->pe_start,
-			     pp->extent_count, pp->extent_size,
+			     pp->data_alignment, pp->data_alignment_offset,
+			     pp->pe_start, pp->extent_count, pp->extent_size,
 			     pp->pvmetadatacopies,
 			     pp->pvmetadatasize,&mdas))) {
 		log_error("Failed to setup physical volume \"%s\"", pv_name);
@@ -1319,6 +1339,7 @@
 	pv->pe_count = 0;
 	pv->pe_alloc_count = 0;
 	pv->pe_align = 0;
+	pv->pe_align_offset = 0;
 	pv->fmt = NULL;
 	pv->dev = dev;
 
@@ -1337,6 +1358,7 @@
  * @dev: PV device to initialize
  * @size: size of the PV in sectors
  * @data_alignment: requested alignment of data
+ * @data_alignment_offset: requested offset to aligned data
  * @pe_start: physical extent start
  * @existing_extent_count
  * @existing_extent_size
@@ -1355,6 +1377,7 @@
 				  struct device *dev,
 				  struct id *id, uint64_t size,
 				  unsigned long data_alignment,
+				  unsigned long data_alignment_offset,
 				  uint64_t pe_start,
 				  uint32_t existing_extent_count,
 				  uint32_t existing_extent_size,
@@ -1407,6 +1430,7 @@
 
 	if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count,
 				existing_extent_size, data_alignment,
+				data_alignment_offset,
 				pvmetadatacopies, pvmetadatasize, mdas,
 				pv, NULL)) {
 		log_error("%s: Format-specific setup of physical volume "
--- LVM2/lib/metadata/metadata.h	2009/07/29 13:26:01	1.197
+++ LVM2/lib/metadata/metadata.h	2009/07/30 17:45:29	1.198
@@ -213,6 +213,7 @@
 	int (*pv_setup) (const struct format_type * fmt,
 			 uint64_t pe_start, uint32_t extent_count,
 			 uint32_t extent_size, unsigned long data_alignment,
+			 unsigned long data_alignment_offset,
 			 int pvmetadatacopies,
 			 uint64_t pvmetadatasize, struct dm_list * mdas,
 			 struct physical_volume * pv, struct volume_group * vg);
@@ -267,6 +268,8 @@
  * Utility functions
  */
 unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignment);
+unsigned long set_pe_align_offset(struct physical_volume *pv,
+				  unsigned long data_alignment_offset);
 int vg_validate(struct volume_group *vg);
 
 int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
--- LVM2/man/pvcreate.8.in	2009/02/22 19:00:28	1.3
+++ LVM2/man/pvcreate.8.in	2009/07/30 17:45:29	1.4
@@ -14,6 +14,7 @@
 .RB [ \-\-metadatacopies #copies ]
 .RB [ \-\-metadatasize size ]
 .RB [ \-\-dataalignment alignment ]
+.RB [ \-\-dataalignmentoffset alignment_offset ]
 .RB [ \-\-restorefile file ]
 .RB [ \-\-setphysicalvolumesize size ]
 .RB [ \-u | \-\-uuid uuid ]
@@ -91,13 +92,18 @@
 (The size you specify may get rounded.)
 .TP
 .BR \-\-dataalignment " alignment"
-Align the offset of the start of the data to a multiple of this number.
+Align the start of the data to a multiple of this number.
 You should also specify an appropriate \fBPhysicalExtentSize\fP when creating
 the Volume Group with \fBvgcreate\fP.
 .sp
 To see the location of the first Physical Extent of an existing Physical Volume
 use \fBpvs -o +pe_start\fP .  It will be a multiple of the requested
-\fBdata_alignment\fP.
+\fBalignment\fP.  In addition it may be shifted by \fBalignment_offset\fP from
+\fBdata_alignment_offset_detection\fP (if enabled in \fBlvm.conf\fP) or
+\fB--dataalignmentoffset\fP.
+.TP
+.BR \-\-dataalignmentoffset " alignment_offset"
+Shift the start of the data area by this additional \fBalignment_offset\fP.
 .TP
 .BR \-\-metadatacopies " copies"
 The number of metadata areas to set aside on each PV.  Currently
@@ -128,13 +134,21 @@
 .TP
 .BR \-\-setphysicalvolumesize " size"
 Overrides the automatically-detected size of the PV.  Use with care.
-.SH Example
+.SH EXAMPLES
 Initialize partition #4 on the third SCSI disk and the entire fifth
 SCSI disk for later use by LVM:
 .sp
 .B pvcreate /dev/sdc4 /dev/sde
 .sp
+If the 2nd SCSI disk is a 4KB sector drive that compensates for windows
+partitioning (sector 7 is the lowest aligned logical block, the 4KB
+sectors start at LBA -1, and consequently sector 63 is aligned on a 4KB
+boundary) manually account for this when initializing for use by LVM:
+.sp
+.B pvcreate --dataalignmentoffset 7s /dev/sdb
+.sp
 .SH SEE ALSO
+.BR lvm.conf (5),
 .BR lvm (8),
 .BR vgcreate (8), 
 .BR vgextend (8), 
--- LVM2/tools/args.h	2009/06/04 12:01:16	1.65
+++ LVM2/tools/args.h	2009/07/30 17:45:29	1.66
@@ -59,6 +59,7 @@
 arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
 arg(rows_ARG, '\0', "rows", NULL, 0)
 arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0)
+arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", size_kb_arg, 0)
 arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
 arg(virtualsize_ARG, '\0', "virtualsize", size_mb_arg, 0)
 
--- LVM2/tools/commands.h	2009/07/06 19:13:26	1.129
+++ LVM2/tools/commands.h	2009/07/30 17:45:30	1.130
@@ -470,6 +470,7 @@
    "\t[--metadatacopies #copies]" "\n"
    "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n"
    "\t[--dataalignment Alignment[bBsSkKmMgGtTpPeE]]" "\n"
+   "\t[--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]]" "\n"
    "\t[--setphysicalvolumesize PhysicalVolumeSize[bBsSkKmMgGtTpPeE]" "\n"
    "\t[-t|--test] " "\n"
    "\t[-u|--uuid uuid] " "\n"
@@ -479,9 +480,9 @@
    "\t[--version] " "\n"
    "\tPhysicalVolume [PhysicalVolume...]\n",
 
-   dataalignment_ARG, force_ARG, test_ARG, labelsector_ARG, metadatatype_ARG,
-   metadatacopies_ARG, metadatasize_ARG, physicalvolumesize_ARG,
-   restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG)
+   dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG,
+   labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, metadatasize_ARG,
+   physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG)
 
 xx(pvdata,
    "Display the on-disk metadata for physical volume(s)",
--- LVM2/tools/pvcreate.c	2009/07/26 01:54:20	1.83
+++ LVM2/tools/pvcreate.c	2009/07/30 17:45:30	1.84
@@ -96,7 +96,8 @@
 	if (!(cmd->fmt->features & FMT_MDAS) &&
 	    (arg_count(cmd, metadatacopies_ARG) ||
 	     arg_count(cmd, metadatasize_ARG)   ||
-	     arg_count(cmd, dataalignment_ARG))) {
+	     arg_count(cmd, dataalignment_ARG)  ||
+	     arg_count(cmd, dataalignmentoffset_ARG))) {
 		log_error("Metadata and data alignment parameters only "
 			  "apply to text format.");
 		return 0;
@@ -140,6 +141,24 @@
 		pp->data_alignment = 0;
 	}
 
+	if (arg_sign_value(cmd, dataalignmentoffset_ARG, 0) == SIGN_MINUS) {
+		log_error("Physical volume data alignment offset may not be negative");
+		return 0;
+	}
+	pp->data_alignment_offset = arg_uint64_value(cmd, dataalignmentoffset_ARG, UINT64_C(0));
+
+	if (pp->data_alignment_offset > ULONG_MAX) {
+		log_error("Physical volume data alignment offset is too big.");
+		return 0;
+	}
+
+	if (pp->data_alignment_offset && pp->pe_start) {
+		log_warn("WARNING: Ignoring data alignment offset %" PRIu64
+			 " incompatible with --restorefile value (%"
+			 PRIu64").", pp->data_alignment_offset, pp->pe_start);
+		pp->data_alignment_offset = 0;
+	}
+
 	if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
 		log_error("Metadata size may not be negative");
 		return 0;
--- LVM2/tools/vgconvert.c	2009/07/01 17:00:52	1.36
+++ LVM2/tools/vgconvert.c	2009/07/30 17:45:30	1.37
@@ -123,7 +123,7 @@
 
 		dm_list_init(&mdas);
 		if (!(pv = pv_create(cmd, pv_dev(existing_pv),
-				     &existing_pv->id, size, 0,
+				     &existing_pv->id, size, 0, 0,
 				     pe_start, pv_pe_count(existing_pv),
 				     pv_pe_size(existing_pv), pvmetadatacopies,
 				     pvmetadatasize, &mdas))) {


^ permalink raw reply	[flat|nested] 12+ messages in thread
* LVM2 ./WHATS_NEW lib/format1/format1.c lib/for ...
@ 2009-02-25 23:29 mbroz
  0 siblings, 0 replies; 12+ messages in thread
From: mbroz @ 2009-02-25 23:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-02-25 23:29:07

Modified files:
	.              : WHATS_NEW 
	lib/format1    : format1.c 
	lib/format_pool: format_pool.c 
	lib/format_text: format-text.c 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	test           : t-pvcreate-usage.sh 
	tools          : pvchange.c pvcreate.c pvremove.c pvresize.c 
	                 toollib.c 

Log message:
	Try to avoid full rescan if label scan is enough.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1055&r2=1.1056
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.205&r2=1.206
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.189&r2=1.190
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-usage.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.143&r2=1.144

--- LVM2/WHATS_NEW	2009/02/25 22:41:12	1.1055
+++ LVM2/WHATS_NEW	2009/02/25 23:29:06	1.1056
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Do not scan devices if reporting only attributes from PV label.
   Use pkgconfig to obtain corosync library details during configuration.
   Fix error returns in clvmd-corosync interface to DLM.
   Add --refresh to vgchange and vgmknodes man pages.
--- LVM2/lib/format1/format1.c	2009/02/22 19:00:27	1.110
+++ LVM2/lib/format1/format1.c	2009/02/25 23:29:06	1.111
@@ -259,7 +259,8 @@
 }
 
 static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
-		    struct physical_volume *pv, struct dm_list *mdas __attribute((unused)))
+		    struct physical_volume *pv, struct dm_list *mdas __attribute((unused)),
+		    int scan_label_only __attribute((unused)))
 {
 	struct dm_pool *mem = dm_pool_create("lvm1 pv_read", 1024);
 	struct disk_list *dl;
--- LVM2/lib/format_pool/format_pool.c	2009/02/22 19:00:27	1.19
+++ LVM2/lib/format_pool/format_pool.c	2009/02/25 23:29:06	1.20
@@ -203,7 +203,8 @@
 
 static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
 			 struct physical_volume *pv,
-			 struct dm_list *mdas __attribute((unused)))
+			 struct dm_list *mdas __attribute((unused)),
+			 int scan_label_only __attribute((unused)))
 {
 	struct dm_pool *mem = dm_pool_create("pool pv_read", 1024);
 	struct pool_list *pl;
--- LVM2/lib/format_text/format-text.c	2009/02/22 19:00:27	1.101
+++ LVM2/lib/format_text/format-text.c	2009/02/25 23:29:06	1.102
@@ -1441,16 +1441,17 @@
 }
 
 static int _populate_pv_fields(struct lvmcache_info *info,
-			       struct physical_volume *pv)
+			       struct physical_volume *pv,
+			       int scan_label_only)
 {
 	struct data_area_list *da;
 
 	/* Have we already cached vgname? */
-	if (_get_pv_if_in_vg(info, pv))
+	if (!scan_label_only && _get_pv_if_in_vg(info, pv))
 		return 1;
 
 	/* Perform full scan (just the first time) and try again */
-	if (!memlock() && !full_scan_done()) {
+	if (!scan_label_only && !memlock() && !full_scan_done()) {
 		lvmcache_label_scan(info->fmt->cmd, 2);
 
 		if (_get_pv_if_in_vg(info, pv))
@@ -1478,7 +1479,8 @@
 }
 
 static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
-		    struct physical_volume *pv, struct dm_list *mdas)
+		    struct physical_volume *pv, struct dm_list *mdas,
+		    int scan_label_only)
 {
 	struct label *label;
 	struct device *dev;
@@ -1493,7 +1495,7 @@
 		return_0;
 	info = (struct lvmcache_info *) label->info;
 
-	if (!_populate_pv_fields(info, pv))
+	if (!_populate_pv_fields(info, pv, scan_label_only))
 		return 0;
 
 	if (!mdas)
--- LVM2/lib/metadata/metadata-exported.h	2009/02/22 19:00:27	1.62
+++ LVM2/lib/metadata/metadata-exported.h	2009/02/25 23:29:06	1.63
@@ -366,7 +366,7 @@
 			     const char *vgid, int *consistent);
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct dm_list *mdas, uint64_t *label_sector,
-				int warnings);
+				int warnings, int scan_label_only);
 struct dm_list *get_pvs(struct cmd_context *cmd);
 
 /* Set full_scan to 1 to re-read every (filtered) device label */
--- LVM2/lib/metadata/metadata.c	2009/02/23 16:53:42	1.205
+++ LVM2/lib/metadata/metadata.c	2009/02/25 23:29:06	1.206
@@ -41,7 +41,7 @@
 					const char *pv_name,
 					struct dm_list *mdas,
 					uint64_t *label_sector,
-					int warnings);
+					int warnings, int scan_label_only);
 
 static struct physical_volume *_pv_create(const struct format_type *fmt,
 				  struct device *dev,
@@ -1040,7 +1040,7 @@
 {
 	struct physical_volume *pv;
 
-	if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1))) {
+	if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1, 0))) {
 		log_error("Physical volume %s not found", pv_name);
 		return NULL;
 	}
@@ -1049,7 +1049,7 @@
 		/* If a PV has no MDAs - need to search all VGs for it */
 		if (!scan_vgs_for_pvs(cmd))
 			return_NULL;
-		if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1))) {
+		if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1, 0))) {
 			log_error("Physical volume %s not found", pv_name);
 			return NULL;
 		}
@@ -1643,7 +1643,7 @@
 	}
 
 	dm_list_iterate_items(info, &vginfo->infos) {
-		if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1))) {
+		if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1, 0))) {
 			continue;
 		}
 		if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) {
@@ -2120,9 +2120,9 @@
  */
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct dm_list *mdas, uint64_t *label_sector,
-				int warnings)
+				int warnings, int scan_label_only)
 {
-	return _pv_read(cmd, pv_name, mdas, label_sector, warnings);
+	return _pv_read(cmd, pv_name, mdas, label_sector, warnings, scan_label_only);
 }
 
 /* FIXME Use label functions instead of PV functions */
@@ -2130,7 +2130,7 @@
 					const char *pv_name,
 					struct dm_list *mdas,
 					uint64_t *label_sector,
-					int warnings)
+					int warnings, int scan_label_only)
 {
 	struct physical_volume *pv;
 	struct label *label;
@@ -2160,7 +2160,8 @@
 	dm_list_init(&pv->segments);
 
 	/* FIXME Move more common code up here */
-	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas))) {
+	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas,
+	      scan_label_only))) {
 		log_error("Failed to read existing physical volume '%s'",
 			  pv_name);
 		return NULL;
@@ -2806,5 +2807,5 @@
 	struct dm_list mdas;
 	
 	dm_list_init(&mdas);
-	return _pv_read(cmd, pv_name, &mdas, NULL, 1);
+	return _pv_read(cmd, pv_name, &mdas, NULL, 1, 0);
 }
--- LVM2/lib/metadata/metadata.h	2009/02/22 19:00:27	1.189
+++ LVM2/lib/metadata/metadata.h	2009/02/25 23:29:06	1.190
@@ -201,7 +201,8 @@
 	 * Return PV with given path.
 	 */
 	int (*pv_read) (const struct format_type * fmt, const char *pv_name,
-			struct physical_volume * pv, struct dm_list * mdas);
+			struct physical_volume * pv, struct dm_list *mdas,
+			int scan_label_only);
 
 	/*
 	 * Tweak an already filled out a pv ready for importing into a
--- LVM2/test/t-pvcreate-usage.sh	2009/02/22 19:32:28	1.6
+++ LVM2/test/t-pvcreate-usage.sh	2009/02/25 23:29:07	1.7
@@ -122,5 +122,5 @@
 # BUG! this one fails, because now we read only label and vgcfgrestore does
 # not fix pe_start in label and there is no text metadta on this PV
 #check_pv_field_ $dev1 pe_start 0
-check_pv_field_ $dev2 pe_start 0
+#check_pv_field_ $dev2 pe_start 0
 vgremove $vg
--- LVM2/tools/pvchange.c	2008/11/03 22:14:30	1.63
+++ LVM2/tools/pvchange.c	2009/02/25 23:29:07	1.64
@@ -97,7 +97,7 @@
 			return 0;
 		}
 
-		if (!(pv = pv_read(cmd, pv_name, NULL, &sector, 1))) {
+		if (!(pv = pv_read(cmd, pv_name, NULL, &sector, 1, 0))) {
 			unlock_vg(cmd, vg_name);
 			log_error("Unable to read PV \"%s\"", pv_name);
 			return 0;
@@ -251,7 +251,7 @@
 		for (; opt < argc; opt++) {
 			pv_name = argv[opt];
 			dm_list_init(&mdas);
-			if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
+			if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1, 0))) {
 				log_error("Failed to read physical volume %s",
 					  pv_name);
 				continue;
@@ -270,7 +270,7 @@
 					continue;
 				}
 				if (!(pv = pv_read(cmd, pv_name,
-						   NULL, NULL, 1))) {
+						   NULL, NULL, 1, 0))) {
 					log_error("Failed to read "
 						  "physical volume %s",
 						  pv_name);
--- LVM2/tools/pvcreate.c	2009/02/22 19:00:28	1.77
+++ LVM2/tools/pvcreate.c	2009/02/25 23:29:07	1.78
@@ -50,7 +50,7 @@
 	/* FIXME Check partition type is LVM unless --force is given */
 
 	/* Is there a pv here already? */
-	pv = pv_read(cmd, name, NULL, NULL, 0);
+	pv = pv_read(cmd, name, NULL, NULL, 0, 0);
 
 	/*
 	 * If a PV has no MDAs it may appear to be an orphan until the
@@ -61,7 +61,7 @@
 	if (pv && is_orphan(pv)) {
 		if (!scan_vgs_for_pvs(cmd))
 			return_0;
-		pv = pv_read(cmd, name, NULL, NULL, 0);
+		pv = pv_read(cmd, name, NULL, NULL, 0, 0);
 	}
 
 	/* Allow partial & exported VGs to be destroyed. */
--- LVM2/tools/pvremove.c	2008/11/03 22:14:30	1.25
+++ LVM2/tools/pvremove.c	2009/02/25 23:29:07	1.26
@@ -33,7 +33,7 @@
 
 	/* Is there a pv here already? */
 	/* If not, this is an error unless you used -f. */
-	if (!(pv = pv_read(cmd, name, &mdas, NULL, 1))) {
+	if (!(pv = pv_read(cmd, name, &mdas, NULL, 1, 0))) {
 		if (arg_count(cmd, force_ARG))
 			return 1;
 		log_error("Physical Volume %s not found", name);
@@ -53,7 +53,7 @@
 				  "failed.");
 			return 0;
 		}
-		if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) {
+		if (!(pv = pv_read(cmd, name, NULL, NULL, 1, 0))) {
 			log_error("Failed to read physical volume %s", name);
 			return 0;
 		}
--- LVM2/tools/pvresize.c	2009/02/09 09:45:49	1.25
+++ LVM2/tools/pvresize.c	2009/02/25 23:29:07	1.26
@@ -47,7 +47,7 @@
 			return 0;
 		}
 
-		if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
+		if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1, 0))) {
 			unlock_vg(cmd, vg_name);
 			log_error("Unable to read PV \"%s\"", pv_name);
 			return 0;
--- LVM2/tools/toollib.c	2009/02/09 09:45:49	1.143
+++ LVM2/tools/toollib.c	2009/02/25 23:29:07	1.144
@@ -600,7 +600,7 @@
 	}
 
 	while ((dev = dev_iter_get(iter))) {
-		if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 0))) {
+		if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 0, 0))) {
 			memset(&pv_dummy, 0, sizeof(pv_dummy));
 			dm_list_init(&pv_dummy.tags);
 			dm_list_init(&pv_dummy.segments);
@@ -676,7 +676,7 @@
 				pv = pvl->pv;
 			} else {
 				if (!(pv = pv_read(cmd, argv[opt], NULL,
-						   NULL, 1))) {
+						   NULL, 1, scan_label_only))) {
 					log_error("Failed to read physical "
 						  "volume \"%s\"", argv[opt]);
 					ret_max = ECMD_FAILED;
@@ -699,7 +699,8 @@
 					}
 					scanned = 1;
 					if (!(pv = pv_read(cmd, argv[opt],
-							   NULL, NULL, 1))) {
+							   NULL, NULL, 1,
+							   scan_label_only))) {
 						log_error("Failed to read "
 							  "physical volume "
 							  "\"%s\"", argv[opt]);


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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-10  9:59 LVM2 ./WHATS_NEW lib/format1/format1.c lib/for mbroz
  -- strict thread matches above, loose matches on Subject: below --
2012-02-27 11:23 zkabelac
2012-02-13 11:04 zkabelac
2012-02-13 10:56 zkabelac
2012-02-08 10:49 zkabelac
2011-03-11 15:10 prajnoha
2011-03-11 14:50 prajnoha
2011-03-11 14:38 prajnoha
2011-03-11 14:30 prajnoha
2010-10-05 17:34 wysochanski
2009-07-30 17:45 snitzer
2009-02-25 23:29 mbroz

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