public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2011-08-11 17:24 zkabelac
  0 siblings, 0 replies; 22+ messages in thread
From: zkabelac @ 2011-08-11 17:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-08-11 17:24:24

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/metadata   : metadata.c vg.c vg.h 

Log message:
	Cache and share generated VG structs
	
	Extend vginfo cache with cached VG structure. So if the same metadata
	are use, skip mda decoding in the case, the same data are in use.
	This helps for operations like activation of all LVs in one VG,
	where same data were decoded giving the same output result.
	
	Patch adds 1-to-1 connection between volume_group and lvmcache_vginfo.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2064&r2=1.2065
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.463&r2=1.464
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.14&r2=1.15

--- LVM2/WHATS_NEW	2011/08/11 16:31:40	1.2064
+++ LVM2/WHATS_NEW	2011/08/11 17:24:23	1.2065
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  Cache and share generated VG structs.
   Fix possible format instance memory leaks and premature releases in _vg_read.
   Suppress locking error messages in monitoring init scripts.
   If pipe in clvmd fails, return busy instead of using uninitialised descriptors.
--- LVM2/lib/cache/lvmcache.c	2011/08/10 20:25:30	1.113
+++ LVM2/lib/cache/lvmcache.c	2011/08/11 17:24:24	1.114
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -90,6 +90,8 @@
 	}
 
 	log_debug("Metadata cache: VG %s wiped.", vginfo->vgname);
+
+	release_vg(vginfo->cached_vg);
 }
 
 /*
@@ -662,6 +664,10 @@
 	    (!precommitted && vginfo->precommitted && !critical_section()))
 		return NULL;
 
+	/* Use already-cached VG struct when available */
+	if ((vg = vginfo->cached_vg))
+		goto out;
+
 	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
 	fic.context.vg_ref.vg_name = vginfo->vgname;
 	fic.context.vg_ref.vg_id = vgid;
@@ -677,17 +683,44 @@
 	if (!(vg = import_vg_from_config_tree(vginfo->cft, fid)))
 		goto_bad;
 
-	log_debug("Using cached %smetadata for VG %s.",
-		  vginfo->precommitted ? "pre-committed" : "", vginfo->vgname);
+	/* Cache VG struct for reuse */
+	vginfo->cached_vg = vg;
+	vginfo->holders = 1;
+	vginfo->vg_use_count = 0;
+	vg->vginfo = vginfo;
+
+out:
+	vginfo->holders++;
+	vginfo->vg_use_count++;
+	log_debug("Using cached %smetadata for VG %s with %u holder(s).",
+		  vginfo->precommitted ? "pre-committed " : "",
+		  vginfo->vgname, vginfo->holders);
 
 	return vg;
 
 bad:
-	release_vg(vg);
 	_free_cached_vgmetadata(vginfo);
 	return NULL;
 }
 
+int vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo)
+{
+	log_debug("VG %s decrementing %d holder(s) at %p.",
+		  vginfo->cached_vg->name, vginfo->holders, vginfo->cached_vg);
+
+	if (--vginfo->holders)
+		return 0;
+
+	if (vginfo->vg_use_count > 1)
+		log_debug("VG %s reused %d times.",
+			  vginfo->cached_vg->name, vginfo->vg_use_count);
+
+	vginfo->cached_vg->vginfo = NULL;
+	vginfo->cached_vg = NULL;
+
+	return 1;
+}
+
 struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd,
 				   int include_internal)
 {
--- LVM2/lib/cache/lvmcache.h	2011/06/01 19:29:32	1.39
+++ LVM2/lib/cache/lvmcache.h	2011/08/11 17:24:24	1.40
@@ -50,6 +50,9 @@
 	char *vgmetadata;	/* Copy of VG metadata as format_text string */
 	struct config_tree *cft; /* Config tree created from vgmetadata */
 				/* Lifetime is directly tied to vgmetadata */
+	struct volume_group *cached_vg;
+	unsigned holders;
+	unsigned vg_use_count;	/* Counter of vg reusage */
 	unsigned precommitted;	/* Is vgmetadata live or precommitted? */
 };
 
@@ -93,6 +96,8 @@
 
 /* Queries */
 const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels);
+/* Decrement and test if there are still vg holders in vginfo. */
+int vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo);
 struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
 					   const char *vgid);
 struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
--- LVM2/lib/metadata/metadata.c	2011/08/11 16:31:40	1.463
+++ LVM2/lib/metadata/metadata.c	2011/08/11 17:24:24	1.464
@@ -866,6 +866,12 @@
 					    struct volume_group *vg,
 					    uint32_t failure)
 {
+	/* Never return a cached VG structure for a failure */
+	if (vg && vg->vginfo && failure != SUCCESS) {
+		release_vg(vg);
+		vg = NULL;
+	}
+
 	if (!vg && !(vg = alloc_vg("vg_make_handle", cmd, NULL)))
 		return_NULL;
 
--- LVM2/lib/metadata/vg.c	2011/08/10 20:25:30	1.11
+++ LVM2/lib/metadata/vg.c	2011/08/11 17:24:24	1.12
@@ -18,6 +18,7 @@
 #include "display.h"
 #include "activate.h"
 #include "toolcontext.h"
+#include "lvmcache.h"
 
 struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
 			      const char *vg_name)
@@ -49,6 +50,8 @@
 	dm_list_init(&vg->tags);
 	dm_list_init(&vg->removed_pvs);
 
+	log_debug("Allocated VG %s at %p.", vg->name, vg);
+
 	return vg;
 }
 
@@ -62,6 +65,8 @@
 		return;
 	}
 
+	log_debug("Freeing VG %s at %p.", vg->name, vg);
+
 	dm_pool_destroy(vg->vgmem);
 }
 
@@ -70,6 +75,11 @@
 	if (!vg)
 		return;
 
+	/* Check if there are any vginfo holders */
+	if (vg->vginfo &&
+	    !vginfo_holders_dec_and_test_for_zero(vg->vginfo))
+		return;
+
 	_free_vg(vg);
 }
 
--- LVM2/lib/metadata/vg.h	2011/08/10 20:26:41	1.14
+++ LVM2/lib/metadata/vg.h	2011/08/11 17:24:24	1.15
@@ -41,6 +41,7 @@
 	struct cmd_context *cmd;
 	struct dm_pool *vgmem;
 	struct format_instance *fid;
+	struct lvmcache_vginfo *vginfo;
 	struct dm_list *cmd_vgs;/* List of wanted/locked and opened VGs */
 	uint32_t cmd_missing_vgs;/* Flag marks missing VG */
 	uint32_t seqno;		/* Metadata sequence number */


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2011-06-01 19:29 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2011-06-01 19:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-06-01 19:29:34

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format1    : format1.c import-export.c 
	lib/format_text: format-text.c import_vsn1.c 
	lib/metadata   : metadata.c metadata.h pv.h vg.c vg.h 
	tools          : pvcreate.c pvremove.c pvresize.c toollib.c 

Log message:
	Defer writing PV labels to vg_write.
	Store label_sector only in struct physical_volume.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2003&r2=1.2004
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.456&r2=1.457
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.243&r2=1.244
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/pv.h.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.226&r2=1.227

--- LVM2/WHATS_NEW	2011/06/01 19:21:04	1.2003
+++ LVM2/WHATS_NEW	2011/06/01 19:29:31	1.2004
@@ -1,5 +1,7 @@
 Version 2.02.86 -  
 =================================
+  Defer writing PV labels to vg_write.
+  Store label_sector only in struct physical_volume.
   Permit --available with lvcreate so non-snapshot LVs need not be activated.
   Report sector containing label in verbose message.
   Clarify error message when unable to convert an LV into a snapshot of an LV.
--- LVM2/lib/cache/lvmcache.c	2011/04/21 13:15:26	1.110
+++ LVM2/lib/cache/lvmcache.c	2011/06/01 19:29:32	1.111
@@ -539,7 +539,7 @@
 	struct lvmcache_info *info;
 	char *vgname;
 
-	if (!device_from_pvid(cmd, (const struct id *)pvid, NULL)) {
+	if (!device_from_pvid(cmd, (const struct id *)pvid, NULL, NULL)) {
 		log_error("Couldn't find device with uuid %s.", pvid);
 		return NULL;
 	}
@@ -769,31 +769,41 @@
 	return pvids;
 }
 
-struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid,
-				unsigned *scan_done_once)
+static struct device *_device_from_pvid(const struct id *pvid,
+					uint64_t *label_sector)
 {
-	struct label *label;
 	struct lvmcache_info *info;
+	struct label *label;
 
-	/* Already cached ? */
 	if ((info = info_from_pvid((const char *) pvid, 0))) {
 		if (label_read(info->dev, &label, UINT64_C(0))) {
 			info = (struct lvmcache_info *) label->info;
-			if (id_equal(pvid, (struct id *) &info->dev->pvid))
+			if (id_equal(pvid, (struct id *) &info->dev->pvid)) {
+				if (label_sector)
+					*label_sector = label->sector;
 				return info->dev;
+                        }
 		}
 	}
+	return NULL;
+}
+
+struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid,
+				unsigned *scan_done_once, uint64_t *label_sector)
+{
+	struct device *dev;
+
+	/* Already cached ? */
+	dev = _device_from_pvid(pvid, label_sector);
+	if (dev)
+		return dev;
 
 	lvmcache_label_scan(cmd, 0);
 
 	/* Try again */
-	if ((info = info_from_pvid((const char *) pvid, 0))) {
-		if (label_read(info->dev, &label, UINT64_C(0))) {
-			info = (struct lvmcache_info *) label->info;
-			if (id_equal(pvid, (struct id *) &info->dev->pvid))
-				return info->dev;
-		}
-	}
+	dev = _device_from_pvid(pvid, label_sector);
+	if (dev)
+		return dev;
 
 	if (critical_section() || (scan_done_once && *scan_done_once))
 		return NULL;
@@ -803,13 +813,9 @@
 		*scan_done_once = 1;
 
 	/* Try again */
-	if ((info = info_from_pvid((const char *) pvid, 0))) {
-		if (label_read(info->dev, &label, UINT64_C(0))) {
-			info = (struct lvmcache_info *) label->info;
-			if (id_equal(pvid, (struct id *) &info->dev->pvid))
-				return info->dev;
-		}
-	}
+	dev = _device_from_pvid(pvid, label_sector);
+	if (dev)
+		return dev;
 
 	return NULL;
 }
--- LVM2/lib/cache/lvmcache.h	2011/03/30 13:14:34	1.38
+++ LVM2/lib/cache/lvmcache.h	2011/06/01 19:29:32	1.39
@@ -99,7 +99,7 @@
 struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
 const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
 struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid,
-				unsigned *scan_done_once);
+				unsigned *scan_done_once, uint64_t *label_sector);
 const char *pvid_from_devname(struct cmd_context *cmd,
 			      const char *dev_name);
 char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid);
--- LVM2/lib/format1/format1.c	2011/03/11 15:10:16	1.138
+++ LVM2/lib/format1/format1.c	2011/06/01 19:29:32	1.139
@@ -406,6 +406,8 @@
 	struct disk_list *dl;
 	struct dm_list pvs;
 	struct lvmcache_info *info;
+	int pe_count, pe_size, pe_start;
+	int r = 1;
 
 	if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
 				  pv->vg_name, NULL, 0)))
@@ -418,6 +420,10 @@
 
 	dm_list_init(&pvs);
 
+	pe_count = pv->pe_count;
+	pe_size = pv->pe_size;
+	pe_start = pv->pe_start;
+
 	/* Ensure any residual PE structure is gone */
 	pv->pe_size = pv->pe_count = 0;
 	pv->pe_start = LVM1_PE_ALIGN;
@@ -430,6 +436,8 @@
 
 	dl->mem = mem;
 	dl->dev = pv->dev;
+	dm_list_init(&dl->uuids);
+	dm_list_init(&dl->lvds);
 
 	if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv))
 		goto_bad;
@@ -444,12 +452,18 @@
 	if (!write_disks(fmt, &pvs))
 		goto_bad;
 
-	dm_pool_destroy(mem);
-	return 1;
+	goto out;
 
       bad:
+	r = 0;
+
+      out:
+	pv->pe_size = pe_size;
+	pv->pe_count = pe_count;
+	pv->pe_start = pe_start;
+
 	dm_pool_destroy(mem);
-	return 0;
+	return r;
 }
 
 static int _format1_vg_setup(struct format_instance *fid, struct volume_group *vg)
--- LVM2/lib/format1/import-export.c	2011/03/13 23:05:48	1.117
+++ LVM2/lib/format1/import-export.c	2011/06/01 19:29:32	1.118
@@ -96,6 +96,8 @@
 	pv->pe_count = pvd->pe_total;
 	pv->pe_alloc_count = 0;
 	pv->pe_align = 0;
+        pv->is_labelled = 0; /* format1 PVs have no label */
+        pv->label_sector = 0;
 
 	/* Fix up pv size if missing or impossibly large */
 	if (!pv->size || pv->size > (1ULL << 62)) {
@@ -149,7 +151,7 @@
 
 	memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN);
 
-	if (pv->vg_name && !is_orphan(pv)) {
+	if (pv->vg_name && !is_orphan(pv) && !(pv->status & UNLABELLED_PV)) {
 		if (!_check_vg_name(pv->vg_name))
 			return_0;
 		strncpy((char *)pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
--- LVM2/lib/format_text/format-text.c	2011/05/28 09:48:15	1.180
+++ LVM2/lib/format_text/format-text.c	2011/06/01 19:29:33	1.181
@@ -45,10 +45,6 @@
 	uint32_t raw_metadata_buf_size;
 };
 
-struct text_fid_pv_context {
-	int64_t label_sector;
-};
-
 struct dir_list {
 	struct dm_list list;
 	char dir[0];
@@ -1252,11 +1248,9 @@
 /* Only for orphans */
 static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv)
 {
-	struct text_fid_pv_context *fid_pv_tc;
 	struct format_instance *fid = pv->fid;
 	const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
 	struct label *label;
-	int64_t label_sector;
 	struct lvmcache_info *info;
 	struct mda_context *mdac;
 	struct metadata_area *mda;
@@ -1271,15 +1265,7 @@
 		return_0;
 
 	label = info->label;
-
-	/*
-	 * We can change the label sector for a
-	 * plain PV that is not part of a VG only!
-	 */
-	if (fid && (!fid->type & FMT_INSTANCE_VG) &&
-	    (fid_pv_tc = (struct text_fid_pv_context *) pv->fid->private) &&
-	    ((label_sector = fid_pv_tc->label_sector) != -1))
-		label->sector = label_sector;
+	label->sector = pv->label_sector;
 
 	info->device_size = pv->size << SECTOR_SHIFT;
 	info->fmt = fmt;
@@ -1517,8 +1503,6 @@
 			       unsigned long data_alignment_offset,
 			       struct physical_volume *pv)
 {
-	struct text_fid_pv_context *fid_pv_tc;
-
 	/*
 	 * Try to keep the value of PE start set to a firm value if requested.
 	 * This is usefull when restoring existing PE start value (backups etc.).
@@ -1569,10 +1553,8 @@
 		return 0;
 	}
 
-	if (label_sector != -1) {
-		fid_pv_tc = (struct text_fid_pv_context *) pv->fid->private;
-		fid_pv_tc->label_sector = label_sector;
-	}
+	if (label_sector != -1)
+                pv->label_sector = label_sector;
 
 	return 1;
 }
@@ -1735,16 +1717,9 @@
 static int _create_pv_text_instance(struct format_instance *fid,
                                     const struct format_instance_ctx *fic)
 {
-	struct text_fid_pv_context *fid_pv_tc;
 	struct lvmcache_info *info;
 
-	if (!(fid_pv_tc = (struct text_fid_pv_context *)
-			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;
+	fid->private = NULL;
 
 	if (!(fid->metadata_areas_index.array = dm_pool_zalloc(fid->mem,
 					FMT_TEXT_MAX_MDAS_PER_PV *
@@ -2332,7 +2307,7 @@
 		return 0;
 	}
 
-	if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL))) {
+	if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL, NULL))) {
 		char buffer[64] __attribute__((aligned(8)));
 
 		if (!id_write_format(&id, buffer, sizeof(buffer)))
--- LVM2/lib/format_text/import_vsn1.c	2011/04/29 19:06:17	1.87
+++ LVM2/lib/format_text/import_vsn1.c	2011/06/01 19:29:33	1.88
@@ -190,10 +190,13 @@
 		return 0;
 	}
 
+        pv->is_labelled = 1; /* All format_text PVs are labelled. */
+
 	/*
 	 * Convert the uuid into a device.
 	 */
-	if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once))) {
+	if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once,
+                                         &pv->label_sector))) {
 		char buffer[64] __attribute__((aligned(8)));
 
 		if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
--- LVM2/lib/metadata/metadata.c	2011/05/07 13:32:05	1.456
+++ LVM2/lib/metadata/metadata.c	2011/06/01 19:29:33	1.457
@@ -38,7 +38,6 @@
 					struct dm_pool *pvmem,
 					const char *pv_name,
 					struct format_instance *fid,
-					uint64_t *label_sector,
 					int warnings, int scan_label_only);
 
 static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
@@ -192,6 +191,7 @@
  * @vg - volume group to add to
  * @pv_name - name of the pv (to be removed)
  * @pv - physical volume to add to volume group
+ * @pp - physical volume creation params (OPTIONAL)
  *
  * Returns:
  *  0 - failure
@@ -199,8 +199,9 @@
  * FIXME: remove pv_name - obtain safely from pv
  */
 int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
-		 struct physical_volume *pv)
+		 struct physical_volume *pv, struct pvcreate_params *pp)
 {
+	struct pv_to_create *pvc;
 	struct pv_list *pvl;
 	struct format_instance *fid = vg->fid;
 	struct dm_pool *mem = vg->vgmem;
@@ -289,6 +290,16 @@
 	vg->extent_count += pv->pe_count;
 	vg->free_count += pv->pe_count;
 
+	if (pv->status & UNLABELLED_PV) {
+		if (!(pvc = dm_pool_zalloc(mem, sizeof(*pvc)))) {
+			log_error("pv_to_create allocation for '%s' failed", pv_name);
+			return 0;
+		}
+		pvc->pv = pv;
+		pvc->pp = pp;
+		dm_list_add(&vg->pvs_to_create, &pvc->list);
+	}
+
 	return 1;
 }
 
@@ -640,11 +651,11 @@
 			  "physical volume", pv_name);
 		return 0;
 	} else if (!pv && pp) {
-		pv = pvcreate_single(vg->cmd, pv_name, pp);
+		pv = pvcreate_single(vg->cmd, pv_name, pp, 0);
 		if (!pv)
 			return 0;
 	}
-	if (!add_pv_to_vg(vg, pv_name, pv)) {
+	if (!add_pv_to_vg(vg, pv_name, pv, pp)) {
 		free_pv_fid(pv);
 		return 0;
 	}
@@ -1318,7 +1329,7 @@
 	/* FIXME Check partition type is LVM unless --force is given */
 
 	/* Is there a pv here already? */
-	pv = pv_read(cmd, name, NULL, 0, 0);
+	pv = pv_read(cmd, name, 0, 0);
 
 	/*
 	 * If a PV has no MDAs it may appear to be an orphan until the
@@ -1330,7 +1341,7 @@
 		free_pv_fid(pv);
 		if (!scan_vgs_for_pvs(cmd, 0))
 			return_0;
-		pv = pv_read(cmd, name, NULL, 0, 0);
+		pv = pv_read(cmd, name, 0, 0);
 	}
 
 	/* Allow partial & exported VGs to be destroyed. */
@@ -1425,6 +1436,47 @@
 	pp->metadataignore = DEFAULT_PVMETADATAIGNORE;
 }
 
+
+static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc)
+{
+	int zero = pvc->pp->zero;
+	struct physical_volume *pv = pvc->pv;
+	struct device *dev = pv->dev;
+	const char *pv_name = dev_name(dev);
+
+	/* Wipe existing label first */
+	if (!label_remove(pv_dev(pv))) {
+		log_error("Failed to wipe existing label on %s", pv_name);
+		return 0;
+	}
+
+	if (zero) {
+		log_verbose("Zeroing start of device %s", pv_name);
+		if (!dev_open_quiet(dev)) {
+			log_error("%s not opened: device not zeroed", pv_name);
+			return 0;
+		}
+
+		if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
+			log_error("%s not wiped: aborting", pv_name);
+			dev_close(dev);
+			return 0;
+		}
+		dev_close(dev);
+	}
+
+	log_error("Writing physical volume data to disk \"%s\"",
+			 pv_name);
+
+	if (!(pv_write(cmd, pv, 1))) {
+		log_error("Failed to write physical volume \"%s\"", pv_name);
+		return 0;
+	}
+
+	log_print("Physical volume \"%s\" successfully created", pv_name);
+	return 1;
+}
+
 /*
  * pvcreate_single() - initialize a device with PV label and metadata area
  *
@@ -1438,7 +1490,8 @@
  */
 struct physical_volume * pvcreate_single(struct cmd_context *cmd,
 					 const char *pv_name,
-					 struct pvcreate_params *pp)
+					 struct pvcreate_params *pp,
+					 int write_now)
 {
 	struct physical_volume *pv = NULL;
 	struct device *dev;
@@ -1451,7 +1504,7 @@
 		pp = &default_pp;
 
 	if (pp->idp) {
-		if ((dev = device_from_pvid(cmd, pp->idp, NULL)) &&
+		if ((dev = device_from_pvid(cmd, pp->idp, NULL, NULL)) &&
 		    (dev != dev_cache_get(pv_name, cmd->filter))) {
 			if (!id_write_format((const struct id*)&pp->idp->uuid,
 			    buffer, sizeof(buffer)))
@@ -1475,6 +1528,7 @@
 	}
 
 	dm_list_init(&mdas);
+
 	if (!(pv = pv_create(cmd, dev, pp->idp, pp->size,
 			     pp->data_alignment, pp->data_alignment_offset,
 			     pp->pe_start ? pp->pe_start : PV_PE_START_CALC,
@@ -1488,37 +1542,16 @@
 	log_verbose("Set up physical volume for \"%s\" with %" PRIu64
 		    " available sectors", pv_name, pv_size(pv));
 
-	/* Wipe existing label first */
-	if (!label_remove(pv_dev(pv))) {
-		log_error("Failed to wipe existing label on %s", pv_name);
-		goto bad;
-	}
-
-	if (pp->zero) {
-		log_verbose("Zeroing start of device %s", pv_name);
-		if (!dev_open_quiet(dev)) {
-			log_error("%s not opened: device not zeroed", pv_name);
-			goto bad;
-		}
-
-		if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
-			log_error("%s not wiped: aborting", pv_name);
-			dev_close(dev);
+	if (write_now) {
+		struct pv_to_create pvc;
+		pvc.pp = pp;
+		pvc.pv = pv;
+		if (!_pvcreate_write(cmd, &pvc))
 			goto bad;
-		}
-		dev_close(dev);
-	}
-
-	log_very_verbose("Writing physical volume data to disk \"%s\"",
-			 pv_name);
-
-	if (!(pv_write(cmd, pv, 0))) {
-		log_error("Failed to write physical volume \"%s\"", pv_name);
-		goto bad;
+	} else {
+		pv->status |= UNLABELLED_PV;
 	}
 
-	log_print("Physical volume \"%s\" successfully created", pv_name);
-
 	return pv;
 
 bad:
@@ -1815,7 +1848,7 @@
 {
 	struct physical_volume *pv;
 
-	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
+	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) {
 		log_error("Physical volume %s not found", pv_name);
 		goto bad;
 	}
@@ -1825,7 +1858,7 @@
 		if (!scan_vgs_for_pvs(cmd, 1))
 			goto_bad;
 		free_pv_fid(pv);
-		if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
+		if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) {
 			log_error("Physical volume %s not found", pv_name);
 			goto bad;
 		}
@@ -2470,6 +2503,7 @@
 int vg_write(struct volume_group *vg)
 {
 	struct dm_list *mdah;
+        struct pv_to_create *pv_to_create;
 	struct metadata_area *mda;
 
 	if (!vg_validate(vg))
@@ -2507,6 +2541,12 @@
 
 	vg->seqno++;
 
+        dm_list_iterate_items(pv_to_create, &vg->pvs_to_create) {
+		if (!_pvcreate_write(vg->cmd, pv_to_create))
+			return 0;
+		pv_to_create->pv->status &= ~UNLABELLED_PV;
+        }
+
 	/* Write to each copy of the metadata area */
 	dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
 		if (!mda->ops->vg_write) {
@@ -2676,7 +2716,7 @@
 
 	dm_list_iterate_items(info, &vginfo->infos) {
 		if (!(pv = _pv_read(cmd, vg->vgmem, dev_name(info->dev),
-				    vg->fid, NULL, warnings, 0))) {
+				    vg->fid, warnings, 0))) {
 			continue;
 		}
 		if (!(pvl = dm_pool_zalloc(vg->vgmem, sizeof(*pvl)))) {
@@ -3429,10 +3469,10 @@
  *   FIXME - liblvm todo - make into function that returns handle
  */
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
-				uint64_t *label_sector, int warnings,
+				int warnings,
 				int scan_label_only)
 {
-	return _pv_read(cmd, cmd->mem, pv_name, NULL, label_sector, warnings, scan_label_only);
+	return _pv_read(cmd, cmd->mem, pv_name, NULL, warnings, scan_label_only);
 }
 
 /* FIXME Use label functions instead of PV functions */
@@ -3440,7 +3480,6 @@
 					struct dm_pool *pvmem,
 					const char *pv_name,
 					struct format_instance *fid,
-					uint64_t *label_sector,
 					int warnings, int scan_label_only)
 {
 	struct physical_volume *pv;
@@ -3460,8 +3499,6 @@
 	}
 
 	info = (struct lvmcache_info *) label->info;
-	if (label_sector && *label_sector)
-		*label_sector = label->sector;
 
 	pv = _alloc_pv(pvmem, dev);
 	if (!pv) {
@@ -3469,6 +3506,8 @@
 		return NULL;
 	}
 
+	pv->label_sector = label->sector;
+
 	/* FIXME Move more common code up here */
 	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, scan_label_only))) {
 		log_error("Failed to read existing physical volume '%s'",
@@ -4367,5 +4406,5 @@
  */
 struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name)
 {
-	return _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0);
+	return _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0);
 }
--- LVM2/lib/metadata/metadata.h	2011/05/07 13:32:05	1.243
+++ LVM2/lib/metadata/metadata.h	2011/06/01 19:29:33	1.244
@@ -470,7 +470,8 @@
 
 struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name);
 int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
-		 struct physical_volume *pv);
+		 struct physical_volume *pv, struct pvcreate_params *pp);
+
 int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
 
 uint64_t find_min_mda_size(struct dm_list *mdas);
--- LVM2/lib/metadata/pv.h	2011/02/21 12:31:28	1.10
+++ LVM2/lib/metadata/pv.h	2011/06/01 19:29:33	1.11
@@ -51,6 +51,12 @@
 	unsigned long pe_align;
 	unsigned long pe_align_offset;
 
+        /* This is true whenever the represented PV has a label associated. */
+        uint64_t is_labelled:1;
+
+        /* NB. label_sector is valid whenever is_labelled is true */
+	uint64_t label_sector;
+
 	struct dm_list segments;	/* Ordered pv_segments covering complete PV */
 	struct dm_list tags;
 };
--- LVM2/lib/metadata/vg.c	2011/03/10 12:43:30	1.9
+++ LVM2/lib/metadata/vg.c	2011/06/01 19:29:33	1.10
@@ -43,6 +43,7 @@
 	vg->alloc = ALLOC_NORMAL;
 
 	dm_list_init(&vg->pvs);
+	dm_list_init(&vg->pvs_to_create);
 	dm_list_init(&vg->lvs);
 	dm_list_init(&vg->tags);
 	dm_list_init(&vg->removed_pvs);
--- LVM2/lib/metadata/vg.h	2011/04/29 19:06:17	1.11
+++ LVM2/lib/metadata/vg.h	2011/06/01 19:29:33	1.12
@@ -31,6 +31,12 @@
 	ALLOC_INHERIT
 } alloc_policy_t;
 
+struct pv_to_create {
+	struct dm_list list;
+	struct physical_volume *pv;
+	struct pvcreate_params *pp;
+};
+
 struct volume_group {
 	struct cmd_context *cmd;
 	struct dm_pool *vgmem;
@@ -59,6 +65,13 @@
 	struct dm_list pvs;
 
 	/*
+	 * List of physical volumes that were used in vgextend but do not carry
+	 * a PV label yet. They need to be pvcreate'd at vg_write time.
+	 */
+
+	struct dm_list pvs_to_create;
+
+	/*
 	 * logical volumes
 	 * The following relationship should always hold:
 	 * dm_list_size(lvs) = user visible lv_count + snapshot_count + other invisible LVs
--- LVM2/tools/pvcreate.c	2011/03/11 14:56:56	1.94
+++ LVM2/tools/pvcreate.c	2011/06/01 19:29:34	1.95
@@ -112,7 +112,7 @@
 
 		unescape_colons_and_at_signs(argv[i], NULL, NULL);
 
-		if (!(pv = pvcreate_single(cmd, argv[i], &pp))) {
+		if (!(pv = pvcreate_single(cmd, argv[i], &pp, 1))) {
 			stack;
 			ret = ECMD_FAILED;
 		}
--- LVM2/tools/pvremove.c	2011/03/11 14:56:56	1.34
+++ LVM2/tools/pvremove.c	2011/06/01 19:29:34	1.35
@@ -30,7 +30,7 @@
 
 	/* Is there a pv here already? */
 	/* If not, this is an error unless you used -f. */
-	if (!(pv = pv_read(cmd, name, NULL, 1, 0))) {
+	if (!(pv = pv_read(cmd, name, 1, 0))) {
 		if (arg_count(cmd, force_ARG))
 			return 1;
 		log_error("Physical Volume %s not found", name);
@@ -52,7 +52,7 @@
 			goto bad;
 		}
 		free_pv_fid(pv);
-		if (!(pv = pv_read(cmd, name, NULL, 1, 0))) {
+		if (!(pv = pv_read(cmd, name, 1, 0))) {
 			log_error("Failed to read physical volume %s", name);
 			goto bad;
 		}
--- LVM2/tools/pvresize.c	2011/03/11 14:56:56	1.44
+++ LVM2/tools/pvresize.c	2011/06/01 19:29:34	1.45
@@ -43,7 +43,7 @@
 			return 0;
 		}
 
-		if (!(pv = pv_read(cmd, pv_name, NULL, 1, 0))) {
+		if (!(pv = pv_read(cmd, pv_name, 1, 0))) {
 			unlock_vg(cmd, vg_name);
 			log_error("Unable to read PV \"%s\"", pv_name);
 			return 0;
--- LVM2/tools/toollib.c	2011/05/19 13:59:22	1.226
+++ LVM2/tools/toollib.c	2011/06/01 19:29:34	1.227
@@ -651,7 +651,7 @@
 	}
 
 	while ((dev = dev_iter_get(iter))) {
-		if (!(pv = pv_read(cmd, dev_name(dev), NULL, 0, 0))) {
+		if (!(pv = pv_read(cmd, dev_name(dev), 0, 0))) {
 			memset(&pv_dummy, 0, sizeof(pv_dummy));
 			dm_list_init(&pv_dummy.tags);
 			dm_list_init(&pv_dummy.segments);
@@ -737,7 +737,7 @@
 				}
 				pv = pvl->pv;
 			} else {
-				if (!(pv = pv_read(cmd, argv[opt], NULL,
+				if (!(pv = pv_read(cmd, argv[opt],
 						   1, scan_label_only))) {
 					log_error("Failed to read physical "
 						  "volume \"%s\"", argv[opt]);
@@ -764,7 +764,7 @@
 					scanned = 1;
 					free_pv_fid(pv);
 					if (!(pv = pv_read(cmd, argv[opt],
-							   NULL, 1,
+							   1,
 							   scan_label_only))) {
 						log_error("Failed to read "
 							  "physical volume "


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2011-03-30 13:14 zkabelac
  0 siblings, 0 replies; 22+ messages in thread
From: zkabelac @ 2011-03-30 13:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 

Log message:
	Keep the cache content when the exported vg buffer is matching
	
	Instead of regenerating config tree and parsing same data again,
	check whether export_vg_to_buffer does not produce same string as
	the one already cached - in this case keep it, otherwise throw cached
	content away.
	
	For the code simplicity calling _free_cached_vgmetadata() with
	vgmetadata == NULL as the function handles this itself.
	
	Note: sometimes export_vg_to_buffer() generates almost the same data
	with just different time stamp, but for the patch simplicity,
	data are reparsed in this case.
	
	This patch currently helps for vgrefresh.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1966&r2=1.1967
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38

--- LVM2/WHATS_NEW	2011/03/30 13:06:13	1.1966
+++ LVM2/WHATS_NEW	2011/03/30 13:14:34	1.1967
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Keep the cache content when the exported vg buffer is matching.
   Extend the set of memory regions, that are not locked to memory.
   Enhance usability with the valgrind memcheck tool.
   Support regular quit of the lvm_thread_fn function in clvmd.
--- LVM2/lib/cache/lvmcache.c	2011/03/29 21:34:18	1.108
+++ LVM2/lib/cache/lvmcache.c	2011/03/30 13:14:34	1.109
@@ -99,6 +99,7 @@
 {
 	char uuid[64] __attribute__((aligned(8)));
 	struct lvmcache_vginfo *vginfo;
+	char *data;
 	int size;
 
 	if (!(vginfo = vginfo_from_vgid((const char *)&vg->id))) {
@@ -106,14 +107,22 @@
 		return;
 	}
 
-	if (vginfo->vgmetadata)
-		_free_cached_vgmetadata(vginfo);
-
-	if (!(size = export_vg_to_buffer(vg, &vginfo->vgmetadata))) {
+	if (!(size = export_vg_to_buffer(vg, &data))) {
 		stack;
+		_free_cached_vgmetadata(vginfo);
 		return;
 	}
 
+	/* Avoid reparsing of the same data string */
+	if (vginfo->vgmetadata && vginfo->vgmetadata_size == size &&
+	    strcmp(vginfo->vgmetadata, data) == 0)
+		dm_free(data);
+	else {
+		_free_cached_vgmetadata(vginfo);
+		vginfo->vgmetadata_size = size;
+		vginfo->vgmetadata = data;
+	}
+
 	vginfo->precommitted = precommitted;
 
 	if (!id_write_format((const struct id *)vginfo->vgid, uuid, sizeof(uuid))) {
--- LVM2/lib/cache/lvmcache.h	2011/01/10 13:15:57	1.37
+++ LVM2/lib/cache/lvmcache.h	2011/03/30 13:14:34	1.38
@@ -46,6 +46,7 @@
 	char _padding[7];
 	struct lvmcache_vginfo *next; /* Another VG with same name? */
 	char *creation_host;
+	size_t vgmetadata_size;
 	char *vgmetadata;	/* Copy of VG metadata as format_text string */
 	struct config_tree *cft; /* Config tree created from vgmetadata */
 				/* Lifetime is directly tied to vgmetadata */


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2011-01-10 13:15 zkabelac
  0 siblings, 0 replies; 22+ messages in thread
From: zkabelac @ 2011-01-10 13:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-01-10 13:15:57

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 

Log message:
	Cache config_tree
	
	Start to use config_tree for cache just like vgmetadata.
	When vgmetadata are erased destroy its cached config tree.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1867&r2=1.1868
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.36&r2=1.37

--- LVM2/WHATS_NEW	2011/01/10 13:13:42	1.1867
+++ LVM2/WHATS_NEW	2011/01/10 13:15:57	1.1868
@@ -1,5 +1,6 @@
 Version 2.02.80 - 
 ====================================
+  Speedup command processing by caching resolved config tree.
   Pass config_tree to renamed function import_vg_from_config_tree().
   Detect NULL handle in get_property().
   Fix superfluous /usr in ocf_scriptdir instalation path.
--- LVM2/lib/cache/lvmcache.c	2011/01/10 13:13:42	1.101
+++ LVM2/lib/cache/lvmcache.c	2011/01/10 13:15:57	1.102
@@ -83,6 +83,12 @@
 
 	vginfo->vgmetadata = NULL;
 
+	/* Release also cached config tree */
+	if (vginfo->cft) {
+		destroy_config_tree(vginfo->cft);
+		vginfo->cft = NULL;
+	}
+
 	log_debug("Metadata cache: VG %s wiped.", vginfo->vgname);
 }
 
@@ -651,7 +657,9 @@
 						      vgid, NULL)))
 		return_NULL;
 
-	if (!(vginfo->cft =
+	/* Build config tree from vgmetadata, if not yet cached */
+	if (!vginfo->cft &&
+	    !(vginfo->cft =
 	      create_config_tree_from_string(fid->fmt->cmd,
 					     vginfo->vgmetadata))) {
 		_free_cached_vgmetadata(vginfo);
@@ -660,10 +668,8 @@
 
 	if (!(vg = import_vg_from_config_tree(vginfo->cft, fid))) {
 		_free_cached_vgmetadata(vginfo);
-		destroy_config_tree(vginfo->cft);
 		return_NULL;
 	}
-	destroy_config_tree(vginfo->cft);
 
 	log_debug("Using cached %smetadata for VG %s.",
 		  vginfo->precommitted ? "pre-committed" : "", vginfo->vgname);
--- LVM2/lib/cache/lvmcache.h	2011/01/10 13:13:42	1.36
+++ LVM2/lib/cache/lvmcache.h	2011/01/10 13:15:57	1.37
@@ -48,6 +48,7 @@
 	char *creation_host;
 	char *vgmetadata;	/* Copy of VG metadata as format_text string */
 	struct config_tree *cft; /* Config tree created from vgmetadata */
+				/* Lifetime is directly tied to vgmetadata */
 	unsigned precommitted;	/* Is vgmetadata live or precommitted? */
 };
 


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2011-01-10 13:13 zkabelac
  0 siblings, 0 replies; 22+ messages in thread
From: zkabelac @ 2011-01-10 13:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-01-10 13:13:43

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format_text: import.c 
	lib/metadata   : metadata.h 

Log message:
	Change import_vg_from_buffer to use config_tree
	
	Change function import_vg_from_buffer() to import_vg_from_config_tree().
	Instead of creating config tree inside the function allow config tree to
	be passed as parameter - usable later for caching.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1866&r2=1.1867
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.227&r2=1.228

--- LVM2/WHATS_NEW	2011/01/10 13:07:58	1.1866
+++ LVM2/WHATS_NEW	2011/01/10 13:13:42	1.1867
@@ -1,5 +1,6 @@
 Version 2.02.80 - 
 ====================================
+  Pass config_tree to renamed function import_vg_from_config_tree().
   Detect NULL handle in get_property().
   Fix superfluous /usr in ocf_scriptdir instalation path.
   Add --with-ocfdir configurable option.
--- LVM2/lib/cache/lvmcache.c	2010/12/10 22:39:54	1.100
+++ LVM2/lib/cache/lvmcache.c	2011/01/10 13:13:42	1.101
@@ -26,6 +26,7 @@
 #include "format-text.h"
 #include "format_pool.h"
 #include "format1.h"
+#include "config.h"
 
 static struct dm_hash_table *_pvid_hash = NULL;
 static struct dm_hash_table *_vgid_hash = NULL;
@@ -650,12 +651,20 @@
 						      vgid, NULL)))
 		return_NULL;
 
-	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid))) {
+	if (!(vginfo->cft =
+	      create_config_tree_from_string(fid->fmt->cmd,
+					     vginfo->vgmetadata))) {
 		_free_cached_vgmetadata(vginfo);
-		free_vg(vg);
 		return_NULL;
 	}
 
+	if (!(vg = import_vg_from_config_tree(vginfo->cft, fid))) {
+		_free_cached_vgmetadata(vginfo);
+		destroy_config_tree(vginfo->cft);
+		return_NULL;
+	}
+	destroy_config_tree(vginfo->cft);
+
 	log_debug("Using cached %smetadata for VG %s.",
 		  vginfo->precommitted ? "pre-committed" : "", vginfo->vgname);
 
--- LVM2/lib/cache/lvmcache.h	2010/12/10 22:39:54	1.35
+++ LVM2/lib/cache/lvmcache.h	2011/01/10 13:13:42	1.36
@@ -33,6 +33,7 @@
 struct cmd_context;
 struct format_type;
 struct volume_group;
+struct config_tree;
 
 /* One per VG */
 struct lvmcache_vginfo {
@@ -46,6 +47,7 @@
 	struct lvmcache_vginfo *next; /* Another VG with same name? */
 	char *creation_host;
 	char *vgmetadata;	/* Copy of VG metadata as format_text string */
+	struct config_tree *cft; /* Config tree created from vgmetadata */
 	unsigned precommitted;	/* Is vgmetadata live or precommitted? */
 };
 
--- LVM2/lib/format_text/import.c	2010/12/20 13:19:14	1.52
+++ LVM2/lib/format_text/import.c	2011/01/10 13:13:42	1.53
@@ -131,18 +131,14 @@
 				 when, desc);
 }
 
-struct volume_group *import_vg_from_buffer(const char *buf,
-                                           struct format_instance *fid)
+struct volume_group *import_vg_from_config_tree(const struct config_tree *cft,
+						struct format_instance *fid)
 {
 	struct volume_group *vg = NULL;
-	struct config_tree *cft;
 	struct text_vg_version_ops **vsn;
 
 	_init_text_import();
 
-	if (!(cft = create_config_tree_from_string(fid->fmt->cmd, buf)))
-		return_NULL;
-
 	for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
 		if (!(*vsn)->check_version(cft))
 			continue;
@@ -155,6 +151,5 @@
 		break;
 	}
 
-	destroy_config_tree(cft);
 	return vg;
 }
--- LVM2/lib/metadata/metadata.h	2010/12/20 13:32:49	1.227
+++ LVM2/lib/metadata/metadata.h	2011/01/10 13:13:43	1.228
@@ -100,6 +100,7 @@
 //#define FMT_RESIZE_PV		0x00000080U	/* Supports pvresize? */
 //#define FMT_UNLIMITED_STRIPESIZE 0x00000100U	/* Unlimited stripe size? */
 
+struct config_tree;
 struct metadata_area;
 
 /* Per-format per-metadata area operations */
@@ -388,6 +389,8 @@
 int export_vg_to_buffer(struct volume_group *vg, char **buf);
 struct volume_group *import_vg_from_buffer(const char *buf,
 					   struct format_instance *fid);
+struct volume_group *import_vg_from_config_tree(const struct config_tree *cft,
+						struct format_instance *fid);
 
 /*
  * Mirroring functions


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2010-12-10 22:40 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2010-12-10 22:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-12-10 22:39:57

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/commands   : toolcontext.c toolcontext.h 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c metadata.h 

Log message:
	Fix scanning of VGs without in-PV mdas.
	
	Set cmd->independent_metadata_areas if metadata/dirs or disk_areas in use.
	- Identify and record this state.
	
	Don't skip full scan when independent mdas are present even if memlock is set.
	- Clusters and OOM aren't supported, so no problem doing the proper scans.
	
	Avoid revalidating the label cache immediately after scanning.
	- A simple optimisation.
	
	Support scanning for a single VG in independent mdas.
	- Not used by the fix but I left it in anyway as later patches might use it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1834&r2=1.1835
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.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.150&r2=1.151
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.415&r2=1.416
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.224&r2=1.225

--- LVM2/WHATS_NEW	2010/12/09 00:10:24	1.1834
+++ LVM2/WHATS_NEW	2010/12/10 22:39:52	1.1835
@@ -1,5 +1,9 @@
 Version 2.02.79 -  
 ===================================
+  Avoid revalidating the label cache immediately after scanning.
+  Support scanning for a single VG in independent mdas.
+  Don't skip full scan when independent mdas are present even if memlock is set.
+  Set cmd->independent_metadata_areas if metadata/dirs or disk_areas in use.
   Cope better with an undefined target_percent operation in _percent_run.
   Fix write to released memory in vg_release and rename to free_vg.  (2.02.78)
 
--- LVM2/lib/cache/lvmcache.c	2010/12/08 20:50:49	1.99
+++ LVM2/lib/cache/lvmcache.c	2010/12/10 22:39:54	1.100
@@ -366,7 +366,7 @@
 	return vginfo;
 }
 
-const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid)
+const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels)
 {
 	struct lvmcache_vginfo *vginfo;
 	struct lvmcache_info *info;
@@ -379,8 +379,16 @@
 	if (!(vginfo = vginfo_from_vgname(vgname, vgid)))
 		return NULL;
 
-	/* This function is normally called before reading metadata so
- 	 * we check cached labels here. Unfortunately vginfo is volatile. */
+	/*
+	 * If this function is called repeatedly, only the first one needs to revalidate.
+	 */
+	if (!revalidate_labels)
+		goto out;
+
+	/*
+	 * This function is normally called before reading metadata so
+ 	 * we check cached labels here. Unfortunately vginfo is volatile.
+ 	 */
 	dm_list_init(&devs);
 	dm_list_iterate_items(info, &vginfo->infos) {
 		if (!(devl = dm_malloc(sizeof(*devl)))) {
@@ -405,6 +413,7 @@
 	    strncmp(vginfo->vgid, vgid_found, ID_LEN))
 		return NULL;
 
+out:
 	return vginfo->fmt;
 }
 
@@ -588,10 +597,10 @@
 	_has_scanned = 1;
 
 	/* Perform any format-specific scanning e.g. text files */
-	dm_list_iterate_items(fmt, &cmd->formats) {
-		if (fmt->ops->scan && !fmt->ops->scan(fmt))
-			goto out;
-	}
+	if (cmd->independent_metadata_areas)
+		dm_list_iterate_items(fmt, &cmd->formats)
+			if (fmt->ops->scan && !fmt->ops->scan(fmt, NULL))
+				goto out;
 
 	/*
 	 * If we are a long-lived process, write out the updated persistent
--- LVM2/lib/cache/lvmcache.h	2010/10/25 13:02:26	1.34
+++ LVM2/lib/cache/lvmcache.h	2010/12/10 22:39:54	1.35
@@ -88,7 +88,7 @@
 int lvmcache_verify_lock_order(const char *vgname);
 
 /* Queries */
-const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid);
+const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid, unsigned revalidate_labels);
 struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
 					   const char *vgid);
 struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
--- LVM2/lib/commands/toolcontext.c	2010/11/29 10:58:32	1.110
+++ LVM2/lib/commands/toolcontext.c	2010/12/10 22:39:54	1.111
@@ -1138,6 +1138,7 @@
 	cmd->is_long_lived = is_long_lived;
 	cmd->handles_missing_pvs = 0;
 	cmd->handles_unknown_segments = 0;
+	cmd->independent_metadata_areas = 0;
 	cmd->hosttags = 0;
 	dm_list_init(&cmd->arg_value_groups);
 	dm_list_init(&cmd->formats);
@@ -1246,6 +1247,8 @@
 			dlclose(lib);
 #endif
 	}
+
+	cmd->independent_metadata_areas = 0;
 }
 
 static void _destroy_segtypes(struct dm_list *segtypes)
--- LVM2/lib/commands/toolcontext.h	2010/11/11 17:29:06	1.41
+++ LVM2/lib/commands/toolcontext.h	2010/12/10 22:39:54	1.42
@@ -78,6 +78,8 @@
 	unsigned si_unit_consistency:1;
 	unsigned metadata_read_only:1;
 
+	unsigned independent_metadata_areas:1;	/* Active formats have MDAs outside PVs */
+
 	struct dev_filter *filter;
 	int dump_filter;	/* Dump filter when exiting? */
 
--- LVM2/lib/format_text/format-text.c	2010/12/08 20:50:49	1.150
+++ LVM2/lib/format_text/format-text.c	2010/12/10 22:39:55	1.151
@@ -1045,7 +1045,7 @@
 	return 1;
 }
 
-static int _scan_file(const struct format_type *fmt)
+static int _scan_file(const struct format_type *fmt, const char *vgname)
 {
 	struct dirent *dirent;
 	struct dir_list *dl;
@@ -1055,7 +1055,7 @@
 	struct volume_group *vg;
 	struct format_instance *fid;
 	char path[PATH_MAX];
-	char *vgname;
+	char *scanned_vgname;
 
 	dir_list = &((struct mda_lists *) fmt->private)->dirs;
 
@@ -1070,18 +1070,23 @@
 			    (!(tmp = strstr(dirent->d_name, ".tmp")) ||
 			     tmp != dirent->d_name + strlen(dirent->d_name)
 			     - 4)) {
-				vgname = dirent->d_name;
+				scanned_vgname = dirent->d_name;
+
+				/* If vgname supplied, only scan that one VG */
+				if (vgname && strcmp(vgname, scanned_vgname))
+					continue;
+
 				if (dm_snprintf(path, PATH_MAX, "%s/%s",
-						 dl->dir, vgname) < 0) {
+						 dl->dir, scanned_vgname) < 0) {
 					log_error("Name too long %s/%s",
-						  dl->dir, vgname);
+						  dl->dir, scanned_vgname);
 					break;
 				}
 
 				/* FIXME stat file to see if it's changed */
 				fid = _text_create_text_instance(fmt, NULL, NULL,
 							    NULL);
-				if ((vg = _vg_read_file_name(fid, vgname,
+				if ((vg = _vg_read_file_name(fid, scanned_vgname,
 							     path))) {
 					/* FIXME Store creation host in vg */
 					lvmcache_update_vg(vg, 0);
@@ -1195,11 +1200,11 @@
 	return vgname;
 }
 
-static int _scan_raw(const struct format_type *fmt)
+static int _scan_raw(const struct format_type *fmt, const char *vgname __attribute__((unused)))
 {
 	struct raw_list *rl;
 	struct dm_list *raw_list;
-	const char *vgname;
+	const char *scanned_vgname;
 	struct volume_group *vg;
 	struct format_instance fid;
 	struct id vgid;
@@ -1224,10 +1229,10 @@
 			goto close_dev;
 		}
 
-		if ((vgname = vgname_from_mda(fmt, mdah,
+		if ((scanned_vgname = vgname_from_mda(fmt, mdah,
 					      &rl->dev_area, &vgid, &vgstatus,
 					      NULL, NULL))) {
-			vg = _vg_read_raw_area(&fid, vgname, &rl->dev_area, 0);
+			vg = _vg_read_raw_area(&fid, scanned_vgname, &rl->dev_area, 0);
 			if (vg)
 				lvmcache_update_vg(vg, 0);
 
@@ -1240,9 +1245,9 @@
 	return 1;
 }
 
-static int _text_scan(const struct format_type *fmt)
+static int _text_scan(const struct format_type *fmt, const char *vgname)
 {
-	return (_scan_file(fmt) & _scan_raw(fmt));
+	return (_scan_file(fmt, vgname) & _scan_raw(fmt, vgname));
 }
 
 /* For orphan, creates new mdas according to policy.
@@ -2181,6 +2186,7 @@
 					  "metadata directory list ", cv->v.str);
 				goto err;
 			}
+			cmd->independent_metadata_areas = 1;
 		}
 	}
 
@@ -2188,6 +2194,7 @@
 		for (cn = cn->child; cn; cn = cn->sib) {
 			if (!_get_config_disk_area(cmd, cn, &mda_lists->raws))
 				goto err;
+			cmd->independent_metadata_areas = 1;
 		}
 	}
 
--- LVM2/lib/metadata/metadata.c	2010/12/08 20:50:50	1.415
+++ LVM2/lib/metadata/metadata.c	2010/12/10 22:39:55	1.416
@@ -2706,13 +2706,14 @@
 
 	/* Find the vgname in the cache */
 	/* If it's not there we must do full scan to be completely sure */
-	if (!(fmt = fmt_from_vgname(vgname, vgid))) {
+	if (!(fmt = fmt_from_vgname(vgname, vgid, 1))) {
 		lvmcache_label_scan(cmd, 0);
-		if (!(fmt = fmt_from_vgname(vgname, vgid))) {
-			if (memlock())
+		if (!(fmt = fmt_from_vgname(vgname, vgid, 1))) {
+			/* Independent MDAs aren't supported under low memory */
+			if (!cmd->independent_metadata_areas && memlock())
 				return_NULL;
 			lvmcache_label_scan(cmd, 2);
-			if (!(fmt = fmt_from_vgname(vgname, vgid)))
+			if (!(fmt = fmt_from_vgname(vgname, vgid, 0)))
 				return_NULL;
 		}
 	}
@@ -2868,10 +2869,11 @@
 	if (!correct_vg) {
 		inconsistent = 0;
 
-		if (memlock())
+		/* Independent MDAs aren't supported under low memory */
+		if (!cmd->independent_metadata_areas && memlock())
 			return_NULL;
 		lvmcache_label_scan(cmd, 2);
-		if (!(fmt = fmt_from_vgname(vgname, vgid)))
+		if (!(fmt = fmt_from_vgname(vgname, vgid, 0)))
 			return_NULL;
 
 		if (precommitted && !(fmt->features & FMT_PRECOMMIT))
@@ -3795,10 +3797,11 @@
 
 	/* Find the vgname in the cache */
 	/* If it's not there we must do full scan to be completely sure */
-	if (!fmt_from_vgname(vgname, NULL)) {
+	if (!fmt_from_vgname(vgname, NULL, 1)) {
 		lvmcache_label_scan(cmd, 0);
-		if (!fmt_from_vgname(vgname, NULL)) {
-			if (memlock()) {
+		if (!fmt_from_vgname(vgname, NULL, 1)) {
+			/* Independent MDAs aren't supported under low memory */
+			if (!cmd->independent_metadata_areas && memlock()) {
 				/*
 				 * FIXME: Disallow calling this function if
 				 * memlock() is true.
@@ -3807,7 +3810,7 @@
 				return FAILED_LOCKING;
 			}
 			lvmcache_label_scan(cmd, 2);
-			if (!fmt_from_vgname(vgname, NULL)) {
+			if (!fmt_from_vgname(vgname, NULL, 0)) {
 				/* vgname not found after scanning */
 				return SUCCESS;
 			}
--- LVM2/lib/metadata/metadata.h	2010/10/25 13:54:29	1.224
+++ LVM2/lib/metadata/metadata.h	2010/12/10 22:39:55	1.225
@@ -227,7 +227,7 @@
 	/*
 	 * Scan any metadata areas that aren't referenced in PV labels
 	 */
-	int (*scan) (const struct format_type * fmt);
+	int (*scan) (const struct format_type * fmt, const char *vgname);
 
 	/*
 	 * Return PV with given path.


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2010-03-17  2:11 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2010-03-17  2:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-03-17 02:11:19

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format_text: import-export.h import.c import_vsn1.c 

Log message:
	Suppress repeated errors about the same missing PV uuids.
	Bypass full device scans when using internally-cached VG metadata.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1464&r2=1.1465
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69

--- LVM2/WHATS_NEW	2010/03/16 17:30:00	1.1464
+++ LVM2/WHATS_NEW	2010/03/17 02:11:18	1.1465
@@ -1,5 +1,7 @@
 Version 2.02.63 - 
 ================================
+  Suppress repeated errors about the same missing PV uuids.
+  Bypass full device scans when using internally-cached VG metadata.
   Only do one full device scan during each read of text format metadata.
   Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls.
   Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
--- LVM2/lib/cache/lvmcache.c	2010/03/16 19:06:57	1.81
+++ LVM2/lib/cache/lvmcache.c	2010/03/17 02:11:18	1.82
@@ -704,7 +704,7 @@
 }
 
 struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
-				int *scan_done_once)
+				unsigned *scan_done_once)
 {
 	struct label *label;
 	struct lvmcache_info *info;
--- LVM2/lib/cache/lvmcache.h	2010/03/16 17:30:01	1.29
+++ LVM2/lib/cache/lvmcache.h	2010/03/17 02:11:18	1.30
@@ -94,7 +94,7 @@
 struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
 const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
 struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
-				int *scan_done_once);
+				unsigned *scan_done_once);
 int vgs_locked(void);
 int vgname_is_locked(const char *vgname);
 
--- LVM2/lib/format_text/import-export.h	2009/11/24 22:55:56	1.23
+++ LVM2/lib/format_text/import-export.h	2010/03/17 02:11:19	1.24
@@ -46,7 +46,8 @@
 struct text_vg_version_ops {
 	int (*check_version) (struct config_tree * cf);
 	struct volume_group *(*read_vg) (struct format_instance * fid,
-					 struct config_tree * cf);
+					 struct config_tree * cf,
+					 unsigned use_cached_pvs);
 	void (*read_desc) (struct dm_pool * mem, struct config_tree * cf,
 			   time_t *when, char **desc);
 	const char *(*read_vgname) (const struct format_type *fmt,
--- LVM2/lib/format_text/import.c	2009/11/24 22:55:56	1.48
+++ LVM2/lib/format_text/import.c	2010/03/17 02:11:19	1.49
@@ -111,7 +111,7 @@
 		if (!(*vsn)->check_version(cft))
 			continue;
 
-		if (!(vg = (*vsn)->read_vg(fid, cft)))
+		if (!(vg = (*vsn)->read_vg(fid, cft, 0)))
 			goto_out;
 
 		(*vsn)->read_desc(fid->fmt->cmd->mem, cft, when, desc);
@@ -146,7 +146,11 @@
 	for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
 		if (!(*vsn)->check_version(cft))
 			continue;
-		if (!(vg = (*vsn)->read_vg(fid, cft)))
+		/*
+		 * The only path to this point uses cached vgmetadata,
+		 * so it can use cached PV state too.
+		 */
+		if (!(vg = (*vsn)->read_vg(fid, cft, 1)))
 			stack;
 		break;
 	}
--- LVM2/lib/format_text/import_vsn1.c	2010/03/16 17:30:01	1.68
+++ LVM2/lib/format_text/import_vsn1.c	2010/03/17 02:11:19	1.69
@@ -28,7 +28,8 @@
 			   struct volume_group * vg, struct config_node * pvn,
 			   struct config_node * vgn,
 			   struct dm_hash_table * pv_hash,
-			   int *scan_done_once);
+			   unsigned *scan_done_once,
+			   unsigned report_missing_devices);
 
 #define _read_int32(root, path, result) \
 	get_config_uint32(root, path, (uint32_t *) result)
@@ -154,7 +155,8 @@
 static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
 		    struct volume_group *vg, struct config_node *pvn,
 		    struct config_node *vgn __attribute((unused)),
-		    struct dm_hash_table *pv_hash, int *scan_done_once)
+		    struct dm_hash_table *pv_hash, unsigned *scan_done_once,
+		    unsigned report_missing_devices)
 {
 	struct physical_volume *pv;
 	struct pv_list *pvl;
@@ -191,10 +193,11 @@
 		char buffer[64] __attribute((aligned(8)));
 
 		if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
-			log_error("Couldn't find device.");
+			buffer[0] = '\0';
+		if (report_missing_devices)
+			log_error("Couldn't find device with uuid %s.", buffer);
 		else
-			log_error("Couldn't find device with uuid '%s'.",
-				  buffer);
+			log_very_verbose("Couldn't find device with uuid %s.", buffer);
 	}
 
 	if (!(pv->vg_name = dm_pool_strdup(mem, vg->name)))
@@ -492,7 +495,8 @@
 			 struct volume_group *vg, struct config_node *lvn,
 			 struct config_node *vgn __attribute((unused)),
 			 struct dm_hash_table *pv_hash __attribute((unused)),
-			 int *scan_done_once __attribute((unused)))
+			 unsigned *scan_done_once __attribute((unused)),
+			 unsigned report_missing_devices __attribute((unused)))
 {
 	struct logical_volume *lv;
 	struct config_node *cn;
@@ -559,7 +563,8 @@
 			struct volume_group *vg, struct config_node *lvn,
 			struct config_node *vgn __attribute((unused)),
 			struct dm_hash_table *pv_hash,
-			int *scan_done_once __attribute((unused)))
+			unsigned *scan_done_once __attribute((unused)),
+			unsigned report_missing_devices __attribute((unused)))
 {
 	struct logical_volume *lv;
 	struct lv_list *lvl;
@@ -612,10 +617,12 @@
 			  const char *section, section_fn fn,
 			  struct dm_pool *mem,
 			  struct volume_group *vg, struct config_node *vgn,
-			  struct dm_hash_table *pv_hash, int optional)
+			  struct dm_hash_table *pv_hash, int optional,
+			  unsigned *scan_done_once)
 {
 	struct config_node *n;
-	int scan_done_once = 0;
+	/* Only report missing devices when doing a scan */
+	unsigned report_missing_devices = scan_done_once ? !*scan_done_once : 1;
 
 	if (!(n = find_config_node(vgn, section))) {
 		if (!optional) {
@@ -627,7 +634,7 @@
 	}
 
 	for (n = n->child; n; n = n->sib) {
-		if (!fn(fid, mem, vg, n, vgn, pv_hash, &scan_done_once))
+		if (!fn(fid, mem, vg, n, vgn, pv_hash, scan_done_once, report_missing_devices))
 			return_0;
 	}
 
@@ -635,12 +642,14 @@
 }
 
 static struct volume_group *_read_vg(struct format_instance *fid,
-				     struct config_tree *cft)
+				     struct config_tree *cft,
+				     unsigned use_cached_pvs)
 {
 	struct config_node *vgn, *cn;
 	struct volume_group *vg;
 	struct dm_hash_table *pv_hash = NULL;
 	struct dm_pool *mem = dm_pool_create("lvm2 vg_read", VG_MEMPOOL_CHUNK);
+	unsigned scan_done_once = use_cached_pvs;
 
 	if (!mem)
 		return_NULL;
@@ -743,7 +752,7 @@
 
 	dm_list_init(&vg->pvs);
 	if (!_read_sections(fid, "physical_volumes", _read_pv, mem, vg,
-			    vgn, pv_hash, 0)) {
+			    vgn, pv_hash, 0, &scan_done_once)) {
 		log_error("Couldn't find all physical volumes for volume "
 			  "group %s.", vg->name);
 		goto bad;
@@ -761,14 +770,14 @@
 	}
 
 	if (!_read_sections(fid, "logical_volumes", _read_lvnames, mem, vg,
-			    vgn, pv_hash, 1)) {
+			    vgn, pv_hash, 1, NULL)) {
 		log_error("Couldn't read all logical volume names for volume "
 			  "group %s.", vg->name);
 		goto bad;
 	}
 
 	if (!_read_sections(fid, "logical_volumes", _read_lvsegs, mem, vg,
-			    vgn, pv_hash, 1)) {
+			    vgn, pv_hash, 1, NULL)) {
 		log_error("Couldn't read all logical volumes for "
 			  "volume group %s.", vg->name);
 		goto bad;


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2010-03-16 17:30 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2010-03-16 17:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-03-16 17:30:02

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

Log message:
	Only do one full device scan during each read of text format metadata.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1463&r2=1.1464
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.321&r2=1.322

--- LVM2/WHATS_NEW	2010/03/16 16:57:03	1.1463
+++ LVM2/WHATS_NEW	2010/03/16 17:30:00	1.1464
@@ -1,5 +1,6 @@
 Version 2.02.63 - 
 ================================
+  Only do one full device scan during each read of text format metadata.
   Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls.
   Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
   Make find_pv_in_vg_by_uuid() return same type as related functions.
--- LVM2/lib/cache/lvmcache.c	2010/03/16 16:57:04	1.79
+++ LVM2/lib/cache/lvmcache.c	2010/03/16 17:30:01	1.80
@@ -703,7 +703,8 @@
 	return pvids;
 }
 
-struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
+struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
+				int *scan_done_once)
 {
 	struct label *label;
 	struct lvmcache_info *info;
@@ -728,10 +729,11 @@
 		}
 	}
 
-	if (memlock())
+	if (memlock() || (scan_done_once && *scan_done_once))
 		return NULL;
 
 	lvmcache_label_scan(cmd, 2);
+	*scan_done_once = 1;
 
 	/* Try again */
 	if ((info = info_from_pvid((char *) pvid, 0))) {
--- LVM2/lib/cache/lvmcache.h	2010/03/16 16:57:04	1.28
+++ LVM2/lib/cache/lvmcache.h	2010/03/16 17:30:01	1.29
@@ -93,7 +93,8 @@
 struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
 struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
 const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
-struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid);
+struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
+				int *scan_done_once);
 int vgs_locked(void);
 int vgname_is_locked(const char *vgname);
 
--- LVM2/lib/format_text/format-text.c	2010/02/15 23:53:15	1.119
+++ LVM2/lib/format_text/format-text.c	2010/03/16 17:30:01	1.120
@@ -2025,7 +2025,7 @@
 		return 0;
 	}
 
-	if (!(dev_area.dev = device_from_pvid(cmd, &id))) {
+	if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL))) {
 		char buffer[64] __attribute((aligned(8)));
 
 		if (!id_write_format(&id, buffer, sizeof(buffer)))
--- LVM2/lib/format_text/import_vsn1.c	2009/12/04 17:48:32	1.67
+++ LVM2/lib/format_text/import_vsn1.c	2010/03/16 17:30:01	1.68
@@ -27,7 +27,8 @@
 typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem,
 			   struct volume_group * vg, struct config_node * pvn,
 			   struct config_node * vgn,
-			   struct dm_hash_table * pv_hash);
+			   struct dm_hash_table * pv_hash,
+			   int *scan_done_once);
 
 #define _read_int32(root, path, result) \
 	get_config_uint32(root, path, (uint32_t *) result)
@@ -153,7 +154,7 @@
 static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
 		    struct volume_group *vg, struct config_node *pvn,
 		    struct config_node *vgn __attribute((unused)),
-		    struct dm_hash_table *pv_hash)
+		    struct dm_hash_table *pv_hash, int *scan_done_once)
 {
 	struct physical_volume *pv;
 	struct pv_list *pvl;
@@ -186,7 +187,7 @@
 	/*
 	 * Convert the uuid into a device.
 	 */
-	if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id))) {
+	if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once))) {
 		char buffer[64] __attribute((aligned(8)));
 
 		if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
@@ -490,7 +491,8 @@
 			 struct dm_pool *mem,
 			 struct volume_group *vg, struct config_node *lvn,
 			 struct config_node *vgn __attribute((unused)),
-			 struct dm_hash_table *pv_hash __attribute((unused)))
+			 struct dm_hash_table *pv_hash __attribute((unused)),
+			 int *scan_done_once __attribute((unused)))
 {
 	struct logical_volume *lv;
 	struct config_node *cn;
@@ -556,7 +558,8 @@
 			struct dm_pool *mem,
 			struct volume_group *vg, struct config_node *lvn,
 			struct config_node *vgn __attribute((unused)),
-			struct dm_hash_table *pv_hash)
+			struct dm_hash_table *pv_hash,
+			int *scan_done_once __attribute((unused)))
 {
 	struct logical_volume *lv;
 	struct lv_list *lvl;
@@ -612,6 +615,7 @@
 			  struct dm_hash_table *pv_hash, int optional)
 {
 	struct config_node *n;
+	int scan_done_once = 0;
 
 	if (!(n = find_config_node(vgn, section))) {
 		if (!optional) {
@@ -623,7 +627,7 @@
 	}
 
 	for (n = n->child; n; n = n->sib) {
-		if (!fn(fid, mem, vg, n, vgn, pv_hash))
+		if (!fn(fid, mem, vg, n, vgn, pv_hash, &scan_done_once))
 			return_0;
 	}
 
--- LVM2/lib/metadata/metadata.c	2010/03/16 16:57:04	1.321
+++ LVM2/lib/metadata/metadata.c	2010/03/16 17:30:02	1.322
@@ -1416,7 +1416,7 @@
 		pp = &default_pp;
 
 	if (pp->idp) {
-		if ((dev = device_from_pvid(cmd, pp->idp)) &&
+		if ((dev = device_from_pvid(cmd, pp->idp, NULL)) &&
 		    (dev != dev_cache_get(pv_name, cmd->filter))) {
 			if (!id_write_format((const struct id*)&pp->idp->uuid,
 			    buffer, sizeof(buffer)))


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2010-03-16 16:57 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2010-03-16 16:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-03-16 16:57:05

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 
	tools          : toollib.c vgrename.c 

Log message:
	Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1462&r2=1.1463
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.135&r2=1.136
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.320&r2=1.321
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.186&r2=1.187
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71

--- LVM2/WHATS_NEW	2010/03/16 15:30:48	1.1462
+++ LVM2/WHATS_NEW	2010/03/16 16:57:03	1.1463
@@ -1,5 +1,6 @@
 Version 2.02.63 - 
 ================================
+  Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls.
   Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
   Make find_pv_in_vg_by_uuid() return same type as related functions.
   Introduce is_missing_pv().
--- LVM2/lib/cache/lvmcache.c	2010/02/03 14:08:39	1.78
+++ LVM2/lib/cache/lvmcache.c	2010/03/16 16:57:04	1.79
@@ -623,13 +623,13 @@
 	return vg;
 }
 
-struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan,
-				    int include_internal)
+struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd,
+				   int include_internal)
 {
 	struct dm_list *vgids;
 	struct lvmcache_vginfo *vginfo;
 
-	lvmcache_label_scan(cmd, full_scan);
+	lvmcache_label_scan(cmd, 0);
 
 	if (!(vgids = str_list_create(cmd->mem))) {
 		log_error("vgids list allocation failed");
@@ -650,13 +650,13 @@
 	return vgids;
 }
 
-struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan,
-				      int include_internal)
+struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd,
+				     int include_internal)
 {
 	struct dm_list *vgnames;
 	struct lvmcache_vginfo *vginfo;
 
-	lvmcache_label_scan(cmd, full_scan);
+	lvmcache_label_scan(cmd, 0);
 
 	if (!(vgnames = str_list_create(cmd->mem))) {
 		log_errno(ENOMEM, "vgnames list allocation failed");
--- LVM2/lib/cache/lvmcache.h	2010/02/03 14:08:39	1.27
+++ LVM2/lib/cache/lvmcache.h	2010/03/16 16:57:04	1.28
@@ -98,16 +98,14 @@
 int vgname_is_locked(const char *vgname);
 
 /* Returns list of struct str_lists containing pool-allocated copy of vgnames */
-/* Set full_scan to 1 to reread every filtered device label. If include_internal
- * is not set, return only proper vg names. */
-struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan,
-				      int include_internal);
+/* If include_internal is not set, return only proper vg names. */
+struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd,
+				     int include_internal);
 
 /* Returns list of struct str_lists containing pool-allocated copy of vgids */
-/* Set full_scan to 1 to reread every filtered device label. If include_internal
- * is not set, return only proper vg ids. */
-struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan,
-				    int include_internal);
+/* If include_internal is not set, return only proper vg ids. */
+struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd,
+				   int include_internal);
 
 /* Returns list of struct str_lists containing pool-allocated copy of pvids */
 struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
--- LVM2/lib/metadata/metadata-exported.h	2010/03/16 15:30:49	1.135
+++ LVM2/lib/metadata/metadata-exported.h	2010/03/16 16:57:04	1.136
@@ -398,11 +398,8 @@
 void lv_set_visible(struct logical_volume *lv);
 void lv_set_hidden(struct logical_volume *lv);
 
-/* Set full_scan to 1 to re-read every (filtered) device label */
-struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan,
-			     int include_internal);
-struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan,
-			   int include_internal);
+struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal);
+struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal);
 int scan_vgs_for_pvs(struct cmd_context *cmd);
 
 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
--- LVM2/lib/metadata/metadata.c	2010/03/16 15:30:49	1.320
+++ LVM2/lib/metadata/metadata.c	2010/03/16 16:57:04	1.321
@@ -2967,7 +2967,8 @@
 	 *       allowed to do a full scan here any more. */
 
 	// The slow way - full scan required to cope with vgrename
-	if (!(vgnames = get_vgnames(cmd, 2, 0))) {
+	lvmcache_label_scan(cmd, 2);
+	if (!(vgnames = get_vgnames(cmd, 0))) {
 		log_error("vg_read_by_vgid: get_vgnames failed");
 		goto out;
 	}
@@ -3103,16 +3104,14 @@
 }
 
 /* May return empty list */
-struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan,
-			     int include_internal)
+struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal)
 {
-	return lvmcache_get_vgnames(cmd, full_scan, include_internal);
+	return lvmcache_get_vgnames(cmd, include_internal);
 }
 
-struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan,
-			   int include_internal)
+struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal)
 {
-	return lvmcache_get_vgids(cmd, full_scan, include_internal);
+	return lvmcache_get_vgids(cmd, include_internal);
 }
 
 static int _get_pvs(struct cmd_context *cmd, struct dm_list **pvslist)
@@ -3138,7 +3137,7 @@
 	}
 
 	/* Get list of VGs */
-	if (!(vgids = get_vgids(cmd, 0, 1))) {
+	if (!(vgids = get_vgids(cmd, 1))) {
 		log_error("get_pvs: get_vgids failed");
 		return 0;
 	}
--- LVM2/liblvm/lvm_vg.c	2010/02/24 18:16:18	1.37
+++ LVM2/liblvm/lvm_vg.c	2010/03/16 16:57:04	1.38
@@ -351,12 +351,12 @@
 
 struct dm_list *lvm_list_vg_names(lvm_t libh)
 {
-	return get_vgnames((struct cmd_context *)libh, 0, 0);
+	return get_vgnames((struct cmd_context *)libh, 0);
 }
 
 struct dm_list *lvm_list_vg_uuids(lvm_t libh)
 {
-	return get_vgids((struct cmd_context *)libh, 0, 0);
+	return get_vgids((struct cmd_context *)libh, 0);
 }
 
 /*
--- LVM2/tools/toollib.c	2010/03/16 14:37:39	1.186
+++ LVM2/tools/toollib.c	2010/03/16 16:57:05	1.187
@@ -275,7 +275,7 @@
 
 	if (!argc || !dm_list_empty(&tags)) {
 		log_verbose("Finding all logical volumes");
-		if (!(vgnames = get_vgnames(cmd, 0, 0)) || dm_list_empty(vgnames)) {
+		if (!(vgnames = get_vgnames(cmd, 0)) || dm_list_empty(vgnames)) {
 			log_error("No volume groups found");
 			return ret_max;
 		}
@@ -518,7 +518,7 @@
 
 	if (!argc || !dm_list_empty(&tags)) {
 		log_verbose("Finding all volume groups");
-		if (!(vgids = get_vgids(cmd, 0, 0)) || dm_list_empty(vgids)) {
+		if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) {
 			log_error("No volume groups found");
 			return ret_max;
 		}
@@ -723,7 +723,7 @@
 			if (sigint_caught())
 				goto out;
 		}
-		if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 0, 1)) &&
+		if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 1)) &&
 			   !dm_list_empty(vgnames)) {
 			dm_list_iterate_items(sll, vgnames) {
 				vg = vg_read(cmd, sll->str, NULL, flags);
--- LVM2/tools/vgrename.c	2010/02/24 20:01:41	1.70
+++ LVM2/tools/vgrename.c	2010/03/16 16:57:05	1.71
@@ -87,7 +87,7 @@
 	log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
 
 	/* Avoid duplicates */
-	if (!(vgids = get_vgids(cmd, 0, 0)) || dm_list_empty(vgids)) {
+	if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) {
 		log_error("No complete volume groups found");
 		return 0;
 	}


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2010-02-03 14:08 prajnoha
  0 siblings, 0 replies; 22+ messages in thread
From: prajnoha @ 2010-02-03 14:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-02-03 14:08:40

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 
	tools          : toollib.c vgrename.c 

Log message:
	This is related to liblvm and its lvm_list_vg_names() and lvm_list_vg_uuids() functions
	where we should not expose internal VG names/uuids (the ones with "#" prefix )through the
	interface. Otherwise, we could end up with library users opening internal VGs which will
	initiate locking mechanism that won't be cleaned up properly.
	
	"#orphans_{lvm1, lvm2, pool}" names are treated in a special way, they are truncated first
	to "orphans" and this is used as a part of the lock name then (e.g. while calling lvm_vg_open()).
	When library user calls lvm_vg_close(), the original name "orphans_{lvm1, lvm2, pool}"
	is used directly and therefore no unlock occurs.
	
	We should exclude internal VG names and uuids in the lists provided by lvmcache:
	lvmcache_get_vgids() and lvmcache_get_vgnames().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1419&r2=1.1420
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.312&r2=1.313
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.184&r2=1.185
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69

--- LVM2/WHATS_NEW	2010/02/03 03:58:08	1.1419
+++ LVM2/WHATS_NEW	2010/02/03 14:08:39	1.1420
@@ -1,5 +1,6 @@
 Version 2.02.61 - 
 ===================================
+  Exclude internal VG names and uuids in lists returned via liblvm interface.
   Add %ORIGIN support to lv{create,extend,reduce,resize} --extents option.
   Add copy constructor for metadata_area.
   Remove pointless versioned symlinks to dmeventd plugin libraries.
--- LVM2/lib/cache/lvmcache.c	2010/01/11 19:12:25	1.77
+++ LVM2/lib/cache/lvmcache.c	2010/02/03 14:08:39	1.78
@@ -623,7 +623,8 @@
 	return vg;
 }
 
-struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan)
+struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan,
+				    int include_internal)
 {
 	struct dm_list *vgids;
 	struct lvmcache_vginfo *vginfo;
@@ -636,6 +637,9 @@
 	}
 
 	dm_list_iterate_items(vginfo, &_vginfos) {
+		if (!include_internal && is_orphan_vg(vginfo->vgname))
+			continue;
+
 		if (!str_list_add(cmd->mem, vgids,
 				  dm_pool_strdup(cmd->mem, vginfo->vgid))) {
 			log_error("strlist allocation failed");
@@ -646,7 +650,8 @@
 	return vgids;
 }
 
-struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan)
+struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan,
+				      int include_internal)
 {
 	struct dm_list *vgnames;
 	struct lvmcache_vginfo *vginfo;
@@ -659,6 +664,9 @@
 	}
 
 	dm_list_iterate_items(vginfo, &_vginfos) {
+		if (!include_internal && is_orphan_vg(vginfo->vgname))
+			continue;
+
 		if (!str_list_add(cmd->mem, vgnames,
 				  dm_pool_strdup(cmd->mem, vginfo->vgname))) {
 			log_errno(ENOMEM, "strlist allocation failed");
--- LVM2/lib/cache/lvmcache.h	2010/01/05 16:06:43	1.26
+++ LVM2/lib/cache/lvmcache.h	2010/02/03 14:08:39	1.27
@@ -98,12 +98,16 @@
 int vgname_is_locked(const char *vgname);
 
 /* Returns list of struct str_lists containing pool-allocated copy of vgnames */
-/* Set full_scan to 1 to reread every filtered device label */
-struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan);
+/* Set full_scan to 1 to reread every filtered device label. If include_internal
+ * is not set, return only proper vg names. */
+struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan,
+				      int include_internal);
 
 /* Returns list of struct str_lists containing pool-allocated copy of vgids */
-/* Set full_scan to 1 to reread every filtered device label */
-struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan);
+/* Set full_scan to 1 to reread every filtered device label. If include_internal
+ * is not set, return only proper vg ids. */
+struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan,
+				    int include_internal);
 
 /* Returns list of struct str_lists containing pool-allocated copy of pvids */
 struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
--- LVM2/lib/metadata/metadata-exported.h	2010/01/13 01:56:18	1.128
+++ LVM2/lib/metadata/metadata-exported.h	2010/02/03 14:08:40	1.129
@@ -398,8 +398,10 @@
 void lv_set_hidden(struct logical_volume *lv);
 
 /* Set full_scan to 1 to re-read every (filtered) device label */
-struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan);
-struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan);
+struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan,
+			     int include_internal);
+struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan,
+			   int include_internal);
 int scan_vgs_for_pvs(struct cmd_context *cmd);
 
 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
--- LVM2/lib/metadata/metadata.c	2010/01/21 21:09:23	1.312
+++ LVM2/lib/metadata/metadata.c	2010/02/03 14:08:40	1.313
@@ -2911,14 +2911,14 @@
 	 *       allowed to do a full scan here any more. */
 
 	// The slow way - full scan required to cope with vgrename
-	if (!(vgnames = get_vgnames(cmd, 2))) {
+	if (!(vgnames = get_vgnames(cmd, 2, 0))) {
 		log_error("vg_read_by_vgid: get_vgnames failed");
 		goto out;
 	}
 
 	dm_list_iterate_items(strl, vgnames) {
 		vgname = strl->str;
-		if (!vgname || is_orphan_vg(vgname))
+		if (!vgname)
 			continue;	// FIXME Unnecessary?
 		consistent = 0;
 		if ((vg = _vg_read(cmd, vgname, vgid, &consistent,
@@ -3047,14 +3047,16 @@
 }
 
 /* May return empty list */
-struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan)
+struct dm_list *get_vgnames(struct cmd_context *cmd, int full_scan,
+			     int include_internal)
 {
-	return lvmcache_get_vgnames(cmd, full_scan);
+	return lvmcache_get_vgnames(cmd, full_scan, include_internal);
 }
 
-struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan)
+struct dm_list *get_vgids(struct cmd_context *cmd, int full_scan,
+			   int include_internal)
 {
-	return lvmcache_get_vgids(cmd, full_scan);
+	return lvmcache_get_vgids(cmd, full_scan, include_internal);
 }
 
 static int _get_pvs(struct cmd_context *cmd, struct dm_list **pvslist)
@@ -3080,7 +3082,7 @@
 	}
 
 	/* Get list of VGs */
-	if (!(vgids = get_vgids(cmd, 0))) {
+	if (!(vgids = get_vgids(cmd, 0, 1))) {
 		log_error("get_pvs: get_vgids failed");
 		return 0;
 	}
--- LVM2/liblvm/lvm_vg.c	2009/11/01 19:51:55	1.33
+++ LVM2/liblvm/lvm_vg.c	2010/02/03 14:08:40	1.34
@@ -315,19 +315,14 @@
 	return name;
 }
 
-/*
- * FIXME: These functions currently return hidden VGs.  We should either filter
- * these out and not return them in the list, or export something like
- * is_orphan_vg and tell the caller to filter.
- */
 struct dm_list *lvm_list_vg_names(lvm_t libh)
 {
-	return get_vgnames((struct cmd_context *)libh, 0);
+	return get_vgnames((struct cmd_context *)libh, 0, 0);
 }
 
 struct dm_list *lvm_list_vg_uuids(lvm_t libh)
 {
-	return get_vgids((struct cmd_context *)libh, 0);
+	return get_vgids((struct cmd_context *)libh, 0, 0);
 }
 
 /*
--- LVM2/tools/toollib.c	2010/01/13 01:56:18	1.184
+++ LVM2/tools/toollib.c	2010/02/03 14:08:40	1.185
@@ -275,7 +275,7 @@
 
 	if (!argc || !dm_list_empty(&tags)) {
 		log_verbose("Finding all logical volumes");
-		if (!(vgnames = get_vgnames(cmd, 0)) || dm_list_empty(vgnames)) {
+		if (!(vgnames = get_vgnames(cmd, 0, 0)) || dm_list_empty(vgnames)) {
 			log_error("No volume groups found");
 			return ret_max;
 		}
@@ -284,8 +284,6 @@
 	vg = NULL;
 	dm_list_iterate_items(strl, vgnames) {
 		vgname = strl->str;
-		if (is_orphan_vg(vgname))
-			continue;	/* FIXME Unnecessary? */
 		vg = vg_read(cmd, vgname, NULL, flags);
 
 		if (vg_read_error(vg)) {
@@ -520,14 +518,13 @@
 
 	if (!argc || !dm_list_empty(&tags)) {
 		log_verbose("Finding all volume groups");
-		if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) {
+		if (!(vgids = get_vgids(cmd, 0, 0)) || dm_list_empty(vgids)) {
 			log_error("No volume groups found");
 			return ret_max;
 		}
 		dm_list_iterate_items(sl, vgids) {
 			vgid = sl->str;
-			if (!vgid || !(vg_name = vgname_from_vgid(cmd->mem, vgid)) ||
-			    is_orphan_vg(vg_name))
+			if (!(vgid) || !(vg_name = vgname_from_vgid(cmd->mem, vgid)))
 				continue;
 			ret_max = _process_one_vg(cmd, vg_name, vgid, &tags,
 						  &arg_vgnames,
@@ -726,7 +723,7 @@
 			if (sigint_caught())
 				goto out;
 		}
-		if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 0)) &&
+		if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 0, 1)) &&
 			   !dm_list_empty(vgnames)) {
 			dm_list_iterate_items(sll, vgnames) {
 				vg = vg_read(cmd, sll->str, NULL, flags);
--- LVM2/tools/vgrename.c	2009/09/14 22:47:50	1.68
+++ LVM2/tools/vgrename.c	2010/02/03 14:08:40	1.69
@@ -87,15 +87,14 @@
 	log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
 
 	/* Avoid duplicates */
-	if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) {
+	if (!(vgids = get_vgids(cmd, 0, 0)) || dm_list_empty(vgids)) {
 		log_error("No complete volume groups found");
 		return 0;
 	}
 
 	dm_list_iterate_items(sl, vgids) {
 		vgid = sl->str;
-		if (!vgid || !(vg_name = vgname_from_vgid(NULL, vgid)) ||
-		    is_orphan_vg(vg_name))
+		if (!vgid || !(vg_name = vgname_from_vgid(NULL, vgid)))
 			continue;
 		if (!strcmp(vg_name, vg_name_old)) {
 			if (match) {


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2009-09-02 21:34 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/locking    : locking.c locking.h 

Log message:
	Enforce an alphabetical lock ordering for vgname locks.
	
	Add a new constraint that vgname locks must be obtained in
	alphabetical order.  At this point, we have test coverage for
	the 3 commands affected - vgsplit, vgmerge, and vgrename.
	Tests have been updated to cover these commands.
	Going forward any command or library call that must obtain
	more than one vgname lock must do so in alphabetical order.
	Future patches will update lvm2app to enforce this ordering.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1252&r2=1.1253
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.50&r2=1.51

--- LVM2/WHATS_NEW	2009/09/02 14:47:39	1.1252
+++ LVM2/WHATS_NEW	2009/09/02 21:34:11	1.1253
@@ -1,5 +1,7 @@
 Version 2.02.52 -
 =================================
+  Enforce an alphabetical lock ordering for vgname locks.
+  Refactor vgsplit, vgmerge, and vgrename to obey vgname ordering rules.
   Implement write lock prioritisation for file locking and make it default.
   Fix clogd build direcory.
   Drop unrequired clogd Makefile.
--- LVM2/lib/cache/lvmcache.c	2009/07/27 11:00:17	1.66
+++ LVM2/lib/cache/lvmcache.c	2009/09/02 21:34:11	1.67
@@ -186,6 +186,45 @@
 		_drop_metadata(vgname);
 }
 
+/*
+ * Ensure vgname2 comes after vgname1 alphabetically.
+ * Special VG names beginning with '#' don't count.
+ */
+static int _vgname_order_correct(const char *vgname1, const char *vgname2)
+{
+	if ((*vgname1 == '#')|(*vgname2 == '#'))
+		return 1;
+
+	if (strcmp(vgname1, vgname2) < 0)
+		return 1;
+	return 0;
+}
+
+/*
+ * Ensure VG locks are acquired in alphabetical order.
+ */
+int lvmcache_verify_lock_order(const char *vgname)
+{
+	struct dm_hash_node *n;
+	const char *vgname2;
+
+	if (!_lock_hash)
+		return_0;
+
+	dm_hash_iterate(n, _lock_hash) {
+		if (!dm_hash_get_data(_lock_hash, n))
+			return_0;
+		vgname2 = dm_hash_get_key(_lock_hash, n);
+		if (!_vgname_order_correct(vgname2, vgname)) {
+			log_errno(EDEADLK, "Internal error: VG lock %s must "
+				  "be requested before %s, not after.",
+				  vgname, vgname2);
+			return_0;
+		}
+	}
+	return 1;
+}
+
 void lvmcache_lock_vgname(const char *vgname, int read_only __attribute((unused)))
 {
 	if (!_lock_hash && !lvmcache_init()) {
@@ -196,7 +235,7 @@
 	if (dm_hash_lookup(_lock_hash, vgname))
 		log_error("Internal error: Nested locking attempted on VG %s.",
 			  vgname);
-		
+
 	if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
 		log_error("Cache locking failure for %s", vgname);
 
--- LVM2/lib/cache/lvmcache.h	2008/11/03 22:14:27	1.24
+++ LVM2/lib/cache/lvmcache.h	2009/09/02 21:34:11	1.25
@@ -84,6 +84,7 @@
 
 void lvmcache_lock_vgname(const char *vgname, int read_only);
 void lvmcache_unlock_vgname(const char *vgname);
+int lvmcache_verify_lock_order(const char *vgname);
 
 /* Queries */
 const struct format_type *fmt_from_vgname(const char *vgname, const char *vgid);
--- LVM2/lib/locking/locking.c	2009/07/24 23:29:03	1.64
+++ LVM2/lib/locking/locking.c	2009/09/02 21:34:11	1.65
@@ -387,6 +387,12 @@
 		if (!_blocking_supported || vgs_locked())
 			flags |= LCK_NONBLOCK;
 
+		if (vol[0] != '#' &&
+		    ((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
+		    (!(flags & LCK_CACHE)) &&
+		    !lvmcache_verify_lock_order(vol))
+			return 0;
+
 		/* Lock VG to change on-disk metadata. */
 		/* If LVM1 driver knows about the VG, it can't be accessed. */
 		if (!check_lvm1_vg_inactive(cmd, vol))
--- LVM2/lib/locking/locking.h	2009/07/24 18:26:42	1.50
+++ LVM2/lib/locking/locking.h	2009/09/02 21:34:11	1.51
@@ -34,6 +34,8 @@
  *   Use VG_GLOBAL as a global lock and to wipe the internal cache.
  *   char *vol holds volume group name.
  *   Set the LCK_CACHE flag to invalidate 'vol' in the internal cache.
+ *   If more than one lock needs to be held simultaneously, they must be
+ *   acquired in alphabetical order of 'vol' (to avoid deadlocks).
  *
  * LCK_LV:
  *   Lock/unlock an individual logical volume


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2008-04-14 19:24 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2008-04-14 19:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-04-14 19:24:16

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 

Log message:
	Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.847&r2=1.848
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21

--- LVM2/WHATS_NEW	2008/04/10 21:38:52	1.847
+++ LVM2/WHATS_NEW	2008/04/14 19:24:15	1.848
@@ -1,5 +1,6 @@
 Version 2.02.35 - 
 =================================
+  Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34)
   Update vgsplit tests to verify loosening of active LV restriction.
   Update vgsplit to only restrict split with active LVs involved in split.
   Add lv_is_active() to determine whether an lv is active.
--- LVM2/lib/cache/lvmcache.c	2008/04/08 12:49:20	1.43
+++ LVM2/lib/cache/lvmcache.c	2008/04/14 19:24:15	1.44
@@ -63,7 +63,6 @@
 	dm_free(vginfo->vgmetadata);
 
 	vginfo->vgmetadata = NULL;
-	vginfo->fid = NULL;
 
 	log_debug("Metadata cache: VG %s wiped.", vginfo->vgname);
 }
@@ -81,7 +80,6 @@
 		return;
 	}
 
-	vginfo->fid = vg->fid;
 	vginfo->precommitted = precommitted;
 
 	log_debug("Metadata cache: VG %s stored (%d bytes%s).", vginfo->vgname,
@@ -400,6 +398,7 @@
 {
 	struct lvmcache_vginfo *vginfo;
 	struct volume_group *vg;
+	struct format_instance *fid;
 
 	if (!vgid || !(vginfo = vginfo_from_vgid(vgid)) || !vginfo->vgmetadata)
 		return NULL;
@@ -411,7 +410,12 @@
 	    (!precommitted && vginfo->precommitted))
 		return NULL;
 
-	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, vginfo->fid)) ||
+	fid =  vginfo->fmt->ops->create_instance(vginfo->fmt, vginfo->vgname,
+						 vgid, NULL);
+	if (!fid)
+		return NULL;
+
+	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid)) ||
 	    !vg_validate(vg)) {
 		_free_cached_vgmetadata(vginfo);
 		return_NULL;
--- LVM2/lib/cache/lvmcache.h	2008/04/08 12:49:20	1.20
+++ LVM2/lib/cache/lvmcache.h	2008/04/14 19:24:16	1.21
@@ -45,7 +45,6 @@
 	struct lvmcache_vginfo *next; /* Another VG with same name? */
 	char *creation_host;
 	char *vgmetadata;	/* Copy of VG metadata as format_text string */
-	struct format_instance *fid;	/* fid associated with vgmetadata */
 	unsigned precommitted;	/* Is vgmetadata live or precommitted? */
 };
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-04-08 12:49:21

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/commands   : toolcontext.c toolcontext.h 
	lib/format_pool: format_pool.c format_pool.h 
	lib/metadata   : metadata.c 
	tools          : lvmcmdline.c pvcreate.c pvscan.c vgreduce.c 
	                 vgrename.c vgscan.c 

Log message:
	Fix vgreduce to use vg_split_mdas to check sufficient mdas remain.
	Add (empty) orphan VGs to lvmcache during initialisation.
	Fix orphan VG name used for format_pool.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.829&r2=1.830
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvscan.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgscan.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30

--- LVM2/WHATS_NEW	2008/04/07 22:12:35	1.829
+++ LVM2/WHATS_NEW	2008/04/08 12:49:20	1.830
@@ -1,5 +1,8 @@
 Version 2.02.34 -
 ===================================
+  Fix vgreduce to use vg_split_mdas to check sufficient mdas remain.
+  Add (empty) orphan VGs to lvmcache during initialisation.
+  Fix orphan VG name used for format_pool.
   Create a fid for internal orphan VGs.
   Update lvmcache VG lock state for all locking types now.
   Fix output if overriding command_names on cmdline.
--- LVM2/lib/cache/lvmcache.c	2008/04/03 18:56:40	1.42
+++ LVM2/lib/cache/lvmcache.c	2008/04/08 12:49:20	1.43
@@ -536,34 +536,38 @@
 	return NULL;
 }
 
-static int _drop_vginfo(struct lvmcache_info *info)
+/*
+ * vginfo must be info->vginfo unless info is NULL
+ */
+static int _drop_vginfo(struct lvmcache_info *info, struct lvmcache_vginfo *vginfo)
 {
-	if (!list_empty(&info->list)) {
+	if (info && !list_empty(&info->list)) {
 		list_del(&info->list);
 		list_init(&info->list);
 	}
 
-	if (info->vginfo && list_empty(&info->vginfo->infos)) {
-		dm_hash_remove(_vgname_hash, info->vginfo->vgname);
-		if (info->vginfo->next) {
-			if (!dm_hash_insert(_vgname_hash, info->vginfo->vgname, info->vginfo->next)) {
+	if (vginfo && !is_orphan_vg(vginfo->vgname) && list_empty(&vginfo->infos)) {
+		dm_hash_remove(_vgname_hash, vginfo->vgname);
+		if (vginfo->next) {
+			if (!dm_hash_insert(_vgname_hash, vginfo->vgname, vginfo->next)) {
 				log_error("vg hash re-insertion failed: %s",
-					  info->vginfo->vgname);
+					  vginfo->vgname);
 				return 0;
 			}
 		}
 
-		if (info->vginfo->vgname)
-			dm_free(info->vginfo->vgname);
-		if (info->vginfo->creation_host)
-			dm_free(info->vginfo->creation_host);
-		if (*info->vginfo->vgid)
-			dm_hash_remove(_vgid_hash, info->vginfo->vgid);
-		list_del(&info->vginfo->list);
+		if (vginfo->vgname)
+			dm_free(vginfo->vgname);
+		if (vginfo->creation_host)
+			dm_free(vginfo->creation_host);
+		if (*vginfo->vgid)
+			dm_hash_remove(_vgid_hash, vginfo->vgid);
+		list_del(&vginfo->list);
 		dm_free(info->vginfo);
 	}
 
-	info->vginfo = NULL;
+	if (info)
+		info->vginfo = NULL;
 
 	return 1;
 }
@@ -574,7 +578,7 @@
 	if (info->dev->pvid[0] && _pvid_hash)
 		dm_hash_remove(_pvid_hash, info->dev->pvid);
 
-	_drop_vginfo(info);
+	_drop_vginfo(info, info->vginfo);
 
 	info->label->labeller->ops->destroy_label(info->label->labeller,
 						info->label);
@@ -599,31 +603,36 @@
 	return 1;
 }
 
-static int _lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
+/*
+ * vginfo must be info->vginfo unless info is NULL (orphans)
+ */
+static int _lvmcache_update_vgid(struct lvmcache_info *info,
+				 struct lvmcache_vginfo *vginfo,
+				 const char *vgid)
 {
-	if (!vgid || !info->vginfo ||
-	    !strncmp(info->vginfo->vgid, vgid, ID_LEN))
+	if (!vgid || !vginfo ||
+	    !strncmp(vginfo->vgid, vgid, ID_LEN))
 		return 1;
 
-	if (info->vginfo && *info->vginfo->vgid)
-		dm_hash_remove(_vgid_hash, info->vginfo->vgid);
+	if (vginfo && *vginfo->vgid)
+		dm_hash_remove(_vgid_hash, vginfo->vgid);
 	if (!vgid) {
-		log_debug("lvmcache: %s: clearing VGID", dev_name(info->dev));
+		log_debug("lvmcache: %s: clearing VGID", info ? dev_name(info->dev) : vginfo->vgname);
 		return 1;
 	}
 
-	strncpy(info->vginfo->vgid, vgid, ID_LEN);
-	info->vginfo->vgid[ID_LEN] = '\0';
-	if (!dm_hash_insert(_vgid_hash, info->vginfo->vgid, info->vginfo)) {
+	strncpy(vginfo->vgid, vgid, ID_LEN);
+	vginfo->vgid[ID_LEN] = '\0';
+	if (!dm_hash_insert(_vgid_hash, vginfo->vgid, vginfo)) {
 		log_error("_lvmcache_update: vgid hash insertion failed: %s",
-			  info->vginfo->vgid);
+			  vginfo->vgid);
 		return 0;
 	}
 
-	if (!is_orphan_vg(info->vginfo->vgname))
+	if (!is_orphan_vg(vginfo->vgname))
 		log_debug("lvmcache: %s: setting %s VGID to %s",
-			  dev_name(info->dev), info->vginfo->vgname,
-			  info->vginfo->vgid);
+			  dev_name(info->dev), vginfo->vgname,
+			  vginfo->vgid);
 
 	return 1;
 }
@@ -714,16 +723,18 @@
 
 static int _lvmcache_update_vgname(struct lvmcache_info *info,
 				   const char *vgname, const char *vgid,
-				   uint32_t vgstatus, const char *creation_host)
+				   uint32_t vgstatus, const char *creation_host,
+				   const struct format_type *fmt)
 {
 	struct lvmcache_vginfo *vginfo, *primary_vginfo;
 	// struct lvmcache_vginfo  *old_vginfo, *next;
 
-	if (!vgname || (info->vginfo && !strcmp(info->vginfo->vgname, vgname)))
+	if (!vgname || (info && info->vginfo && !strcmp(info->vginfo->vgname, vgname)))
 		return 1;
 
 	/* Remove existing vginfo entry */
-	_drop_vginfo(info);
+	if (info)
+		_drop_vginfo(info, info->vginfo);
 
 	/* Get existing vginfo or create new one */
 	if (!(vginfo = vginfo_from_vgname(vgname, vgid))) {
@@ -791,18 +802,25 @@
 ***/
 	}
 
-	info->vginfo = vginfo;
-	list_add(&vginfo->infos, &info->list);
+	if (info) {
+		info->vginfo = vginfo;
+		list_add(&vginfo->infos, &info->list);
+	} else if (!_lvmcache_update_vgid(info, vginfo, vgid)) /* Orphans */
+		return_0;
 
 	_update_cache_vginfo_lock_state(vginfo, vgname_is_locked(vgname));
 
 	/* FIXME Check consistency of list! */
-	vginfo->fmt = info->fmt;
+	vginfo->fmt = fmt;
 
-	log_debug("lvmcache: %s: now in VG %s%s%s%s", dev_name(info->dev),
-		  vgname, vginfo->vgid[0] ? " (" : "",
-		  vginfo->vgid[0] ? vginfo->vgid : "",
-		  vginfo->vgid[0] ? ")" : "");
+	if (info)
+		log_debug("lvmcache: %s: now in VG %s%s%s%s",
+			  dev_name(info->dev),
+			  vgname, vginfo->vgid[0] ? " (" : "",
+			  vginfo->vgid[0] ? vginfo->vgid : "",
+			  vginfo->vgid[0] ? ")" : "");
+	else
+		log_debug("lvmcache: initialised VG %s", vgname);
 
 	return 1;
 }
@@ -842,6 +860,16 @@
 	return 1;
 }
 
+int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt)
+{
+	if (!_lock_hash && !lvmcache_init()) {
+		log_error("Internal cache initialisation failed");
+		return 0;
+	}
+
+	return _lvmcache_update_vgname(NULL, vgname, vgname, 0, "", fmt);
+}
+
 int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
 				  const char *vgname, const char *vgid,
 				  uint32_t vgstatus, const char *creation_host)
@@ -852,9 +880,10 @@
 		vgname = info->fmt->orphan_vg_name;
 		vgid = vgname;
 	}
+
 	if (!_lvmcache_update_vgname(info, vgname, vgid, vgstatus,
-				     creation_host) ||
-	    !_lvmcache_update_vgid(info, vgid) ||
+				     creation_host, info->fmt) ||
+	    !_lvmcache_update_vgid(info, info->vginfo, vgid) ||
 	    !_lvmcache_update_vgstatus(info, vgstatus, creation_host))
 		return_0;
 
@@ -1036,7 +1065,7 @@
 			  dm_hash_get_key(_lock_hash, n));
 }
 
-void lvmcache_destroy(void)
+void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans)
 {
 	struct dm_hash_node *n;
 	log_verbose("Wiping internal VG cache");
@@ -1069,4 +1098,7 @@
 	}
 
 	list_init(&_vginfos);
+
+	if (retain_orphans)
+		init_lvmcache_orphans(cmd);
 }
--- LVM2/lib/cache/lvmcache.h	2008/04/01 22:40:12	1.19
+++ LVM2/lib/cache/lvmcache.h	2008/04/08 12:49:20	1.20
@@ -63,7 +63,7 @@
 };
 
 int lvmcache_init(void);
-void lvmcache_destroy(void);
+void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans);
 
 /* Set full_scan to 1 to reread every filtered device label or
  * 2 to rescan /dev for new devices */
@@ -74,6 +74,7 @@
 				   struct device *dev,
 				   const char *vgname, const char *vgid,
 				   uint32_t vgstatus);
+int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt);
 void lvmcache_del(struct lvmcache_info *info);
 
 /* Update things */
--- LVM2/lib/commands/toolcontext.c	2008/04/02 21:31:14	1.58
+++ LVM2/lib/commands/toolcontext.c	2008/04/08 12:49:20	1.59
@@ -721,6 +721,17 @@
 	return 0;
 }
 
+int init_lvmcache_orphans(struct cmd_context *cmd)
+{
+	struct format_type *fmt;
+
+	list_iterate_items(fmt, &cmd->formats)
+		if (!lvmcache_add_orphan_vginfo(fmt->orphan_vg_name, fmt))
+			return_0;
+
+	return 1;
+}
+
 static int _init_segtypes(struct cmd_context *cmd)
 {
 	struct segment_type *segtype;
@@ -981,6 +992,9 @@
 	if (!_init_formats(cmd))
 		goto error;
 
+	if (!init_lvmcache_orphans(cmd))
+		goto error;
+
 	if (!_init_segtypes(cmd))
 		goto error;
 
@@ -1044,7 +1058,7 @@
 	 */
 
 	activation_release();
-	lvmcache_destroy();
+	lvmcache_destroy(cmd, 0);
 	label_exit();
 	_destroy_segtypes(&cmd->segtypes);
 	_destroy_formats(&cmd->formats);
@@ -1086,6 +1100,9 @@
 	if (!_init_formats(cmd))
 		return 0;
 
+	if (!init_lvmcache_orphans(cmd))
+		return 0;
+
 	if (!_init_segtypes(cmd))
 		return 0;
 
@@ -1107,7 +1124,7 @@
 
 	archive_exit(cmd);
 	backup_exit(cmd);
-	lvmcache_destroy();
+	lvmcache_destroy(cmd, 0);
 	label_exit();
 	_destroy_segtypes(&cmd->segtypes);
 	_destroy_formats(&cmd->formats);
--- LVM2/lib/commands/toolcontext.h	2008/04/02 21:23:39	1.22
+++ LVM2/lib/commands/toolcontext.h	2008/04/08 12:49:20	1.23
@@ -95,5 +95,6 @@
 void destroy_toolcontext(struct cmd_context *cmd);
 int refresh_toolcontext(struct cmd_context *cmd);
 int config_files_changed(struct cmd_context *cmd);
+int init_lvmcache_orphans(struct cmd_context *cmd);
 
 #endif
--- LVM2/lib/format_pool/format_pool.c	2008/02/06 15:47:27	1.14
+++ LVM2/lib/format_pool/format_pool.c	2008/04/08 12:49:20	1.15
@@ -24,8 +24,6 @@
 #include "format_pool.h"
 #include "pool_label.h"
 
-#define FMT_POOL_NAME "pool"
-
 /* Must be called after pvs are imported */
 static struct user_subpool *_build_usp(struct list *pls, struct dm_pool *mem,
 				       int *sps)
@@ -316,7 +314,7 @@
 	fmt->ops = &_format_pool_ops;
 	fmt->name = FMT_POOL_NAME;
 	fmt->alias = NULL;
-	fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_POOL_NAME);
+	fmt->orphan_vg_name = FMT_POOL_ORPHAN_VG_NAME;
 	fmt->features = 0;
 	fmt->private = NULL;
 
--- LVM2/lib/format_pool/format_pool.h	2007/08/20 20:55:25	1.2
+++ LVM2/lib/format_pool/format_pool.h	2008/04/08 12:49:20	1.3
@@ -18,6 +18,9 @@
 
 #include "metadata.h"
 
+#define FMT_POOL_NAME "pool"
+#define FMT_POOL_ORPHAN_VG_NAME ORPHAN_VG_NAME(FMT_POOL_NAME)
+
 #ifdef POOL_INTERNAL
 struct format_type *init_pool_format(struct cmd_context *cmd);
 #endif
--- LVM2/lib/metadata/metadata.c	2008/04/07 22:12:37	1.166
+++ LVM2/lib/metadata/metadata.c	2008/04/08 12:49:20	1.167
@@ -692,6 +692,10 @@
 	return 1;
 }
 
+/*
+ * Separate metadata areas after splitting a VG.
+ * Also accepts orphan VG as destination (for vgreduce).
+ */
 int vg_split_mdas(struct cmd_context *cmd __attribute((unused)),
 		  struct volume_group *vg_from, struct volume_group *vg_to)
 {
@@ -708,11 +712,16 @@
 			continue;
 		}
 
-		if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda))
-			list_move(&mda->list, mdas_to);
+		if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda)) {
+			if (is_orphan_vg(vg_to->name))
+				list_del(&mda->list);
+			else
+				list_move(&mda->list, mdas_to);
+		}
 	}
 
-	if (list_empty(mdas_from) || list_empty(mdas_to))
+	if (list_empty(mdas_from) ||
+	    (!is_orphan_vg(vg_to->name) && list_empty(mdas_to)))
 		return common_mda;
 
 	return 1;
@@ -1366,6 +1375,8 @@
 	struct volume_group *vg;
 	struct physical_volume *pv;
 
+	lvmcache_label_scan(cmd, 0);
+
 	if (!(vginfo = vginfo_from_vgname(orphan_vgname, NULL)))
 		return_NULL;
 
--- LVM2/tools/lvmcmdline.c	2008/04/02 21:23:39	1.62
+++ LVM2/tools/lvmcmdline.c	2008/04/08 12:49:21	1.63
@@ -938,7 +938,7 @@
       out:
 	if (test_mode()) {
 		log_verbose("Test mode: Wiping internal cache");
-		lvmcache_destroy();
+		lvmcache_destroy(cmd, 1);
 	}
 
 	if (cmd->cft_override) {
--- LVM2/tools/pvcreate.c	2008/01/30 14:00:02	1.61
+++ LVM2/tools/pvcreate.c	2008/04/08 12:49:21	1.62
@@ -81,7 +81,7 @@
 		unlock_vg(cmd, VG_ORPHANS);
 
 		persistent_filter_wipe(cmd->filter);
-		lvmcache_destroy();
+		lvmcache_destroy(cmd, 1);
 
 		init_md_filtering(0);
 		if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
--- LVM2/tools/pvscan.c	2008/01/30 14:00:02	1.45
+++ LVM2/tools/pvscan.c	2008/04/08 12:49:21	1.46
@@ -130,7 +130,7 @@
 	}
 
 	persistent_filter_wipe(cmd->filter);
-	lvmcache_destroy();
+	lvmcache_destroy(cmd, 1);
 
 	log_verbose("Walking through all physical volumes");
 	if (!(pvslist = get_pvs(cmd))) {
--- LVM2/tools/vgreduce.c	2008/02/06 15:47:28	1.79
+++ LVM2/tools/vgreduce.c	2008/04/08 12:49:21	1.80
@@ -353,6 +353,8 @@
 			    void *handle __attribute((unused)))
 {
 	struct pv_list *pvl;
+	struct volume_group *orphan_vg;
+	int consistent = 1;
 	const char *name = pv_dev_name(pv);
 
 	if (pv_pe_alloc_count(pv)) {
@@ -366,10 +368,17 @@
 		return ECMD_FAILED;
 	}
 
+	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE | LCK_NONBLOCK)) {
+		log_error("Can't get lock for orphan PVs");
+		return ECMD_FAILED;
+	}
+
 	pvl = find_pv_in_vg(vg, name);
 
-	if (!archive(vg))
+	if (!archive(vg)) {
+		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
+	}
 
 	log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name);
 
@@ -381,6 +390,7 @@
 
 	if (!dev_get_size(pv_dev(pv), &pv->size)) {
 		log_error("%s: Couldn't get size.", pv_dev_name(pv));
+		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
 	}
 
@@ -388,9 +398,24 @@
 	vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
 	vg->extent_count -= pv_pe_count(pv);
 
+	if(!(orphan_vg = vg_read(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
+	   !consistent) {
+		log_error("Unable to read existing orphan PVs");
+		unlock_vg(cmd, VG_ORPHANS);
+		return ECMD_FAILED;
+	}
+
+	if (!vg_split_mdas(cmd, vg, orphan_vg) || !vg->pv_count) {
+		log_error("Cannot remove final metadata area on \"%s\" from \"%s\"",
+			  name, vg->name);
+		unlock_vg(cmd, VG_ORPHANS);
+		return ECMD_FAILED;
+	}
+
 	if (!vg_write(vg) || !vg_commit(vg)) {
 		log_error("Removal of physical volume \"%s\" from "
 			  "\"%s\" failed", name, vg->name);
+		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
 	}
 
@@ -398,9 +423,11 @@
 		log_error("Failed to clear metadata from physical "
 			  "volume \"%s\" "
 			  "after removal from \"%s\"", name, vg->name);
+		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
 	}
 
+	unlock_vg(cmd, VG_ORPHANS);
 	backup(vg);
 
 	log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name);
--- LVM2/tools/vgrename.c	2008/01/30 14:00:02	1.50
+++ LVM2/tools/vgrename.c	2008/04/08 12:49:21	1.51
@@ -151,7 +151,7 @@
 
 	/* FIXME lvmcache corruption - vginfo duplicated instead of renamed */
 	persistent_filter_wipe(cmd->filter);
-	lvmcache_destroy();
+	lvmcache_destroy(cmd, 1);
 
 	return 1;
 
--- LVM2/tools/vgscan.c	2008/01/30 14:00:02	1.29
+++ LVM2/tools/vgscan.c	2008/04/08 12:49:21	1.30
@@ -57,7 +57,7 @@
 	}
 
 	persistent_filter_wipe(cmd->filter);
-	lvmcache_destroy();
+	lvmcache_destroy(cmd, 1);
 
 	log_print("Reading all physical volumes.  This may take a while...");
 


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2008-04-01 22:40 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2008-04-01 22:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-04-01 22:40:13

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format_text: export.c import.c 
	lib/metadata   : metadata.c metadata.h 

Log message:
	Cache VG metadata internally while VG lock is held.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.814&r2=1.815
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.179&r2=1.180

--- LVM2/WHATS_NEW	2008/04/01 22:15:16	1.814
+++ LVM2/WHATS_NEW	2008/04/01 22:40:12	1.815
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Cache VG metadata internally while VG lock is held.
   Fix redundant lvresize message if vg doesn't exist.
   Fix another allocation bug with clvmd and large node IDs.
   Add find_lv_in_lv_list() and find_pv_in_pv_list().
--- LVM2/lib/cache/lvmcache.c	2008/03/17 16:51:31	1.39
+++ LVM2/lib/cache/lvmcache.c	2008/04/01 22:40:12	1.40
@@ -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-2008 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -49,15 +49,53 @@
 	return 1;
 }
 
-static void _update_cache_info_lock_state(struct lvmcache_info *info, int locked)
+/* Volume Group metadata cache functions */
+static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo)
+{
+	if (!vginfo || !vginfo->vgmetadata)
+		return;
+
+	dm_free(vginfo->vgmetadata);
+
+	vginfo->vgmetadata = NULL;
+	vginfo->fid = NULL;
+
+	log_debug("Metadata cache: VG %s wiped.", vginfo->vgname);
+}
+
+static void _store_metadata(struct lvmcache_vginfo *vginfo,
+			    struct volume_group *vg, unsigned precommitted)
+{
+	int size;
+
+	if (vginfo->vgmetadata)
+		_free_cached_vgmetadata(vginfo);
+
+	if (!(size = export_vg_to_buffer(vg, &vginfo->vgmetadata))) {
+		stack;
+		return;
+	}
+
+	vginfo->fid = vg->fid;
+	vginfo->precommitted = precommitted;
+
+	log_debug("Metadata cache: VG %s stored (%d bytes%s).", vginfo->vgname,
+		  size, precommitted ? ", precommitted" : "");
+}
+
+static void _update_cache_info_lock_state(struct lvmcache_info *info,
+					  int locked,
+					  int *cached_vgmetadata_valid)
 {
 	int was_locked = (info->status & CACHE_LOCKED) ? 1 : 0;
 
 	/*
 	 * Cache becomes invalid whenever lock state changes
 	 */
-	if (was_locked != locked)
+	if (was_locked != locked) {
 		info->status |= CACHE_INVALID;
+		*cached_vgmetadata_valid = 0;
+	}
 
 	if (locked)
 		info->status |= CACHE_LOCKED;
@@ -69,9 +107,14 @@
 					    int locked)
 {
 	struct lvmcache_info *info;
+	int cached_vgmetadata_valid = 1;
 
 	list_iterate_items(info, &vginfo->infos)
-		_update_cache_info_lock_state(info, locked);
+		_update_cache_info_lock_state(info, locked,
+					      &cached_vgmetadata_valid);
+
+	if (!cached_vgmetadata_valid)
+		_free_cached_vgmetadata(vginfo);
 }
 
 static void _update_cache_lock_state(const char *vgname, int locked)
@@ -238,6 +281,17 @@
 	return 1;
 }
 
+static int _vginfo_is_valid(struct lvmcache_vginfo *vginfo)
+{
+	struct lvmcache_info *info;
+
+	list_iterate_items(info, &vginfo->infos)
+		if (!_info_is_valid(info))
+			return 0;
+
+	return 1;
+}
+
 /*
  * If valid_only is set, data will only be returned if the cached data is
  * known still to be valid.
@@ -329,6 +383,32 @@
 	return r;
 }
 
+struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
+{
+	struct lvmcache_vginfo *vginfo;
+	struct volume_group *vg;
+
+	if (!vgid || !(vginfo = vginfo_from_vgid(vgid)) || !vginfo->vgmetadata)
+		return NULL;
+
+	if (!_vginfo_is_valid(vginfo))
+		return NULL;
+
+	if ((precommitted && !vginfo->precommitted) ||
+	    (!precommitted && vginfo->precommitted))
+		return NULL;
+
+	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, vginfo->fid)) ||
+	    !vg_validate(vg)) {
+		_free_cached_vgmetadata(vginfo);
+		return_NULL;
+	}
+
+	log_debug("Using cached metadata for VG %s.", vginfo->vgname);
+
+	return vg;
+}
+
 struct list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan)
 {
 	struct list *vgids;
@@ -490,20 +570,6 @@
 	return;
 } */
 
-int lvmcache_store_vg(struct lvmcache_vginfo *vginfo, struct volume_group *vg,
-		      unsigned precommitted)
-{
-	return 1;
-}
-
-void lvmcache_drop_vg(const char *vgname)
-{
-	struct lvmcache_vginfo *vginfo;
-
-	if (!(vginfo = vginfo_from_vgname(vgname, NULL)))
-		return;
-}
-
 static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid)
 {
 	if (!strcmp(info->dev->pvid, pvid))
@@ -803,7 +869,7 @@
 
 	/* store text representation of vg to cache */
 	if ((vginfo = vginfo_from_vgname(vg->name, NULL)))
-		lvmcache_store_vg(vginfo, vg, precommitted);
+		_store_metadata(vginfo, vg, precommitted);
 
 	return 1;
 }
@@ -935,6 +1001,7 @@
 			dm_free(vginfo->vgname);
 		if (vginfo->creation_host)
 			dm_free(vginfo->creation_host);
+		_free_cached_vgmetadata(vginfo);
 		dm_free(vginfo);
 	} while ((vginfo = next));
 }
--- LVM2/lib/cache/lvmcache.h	2008/03/17 16:51:31	1.18
+++ LVM2/lib/cache/lvmcache.h	2008/04/01 22:40:12	1.19
@@ -109,4 +109,7 @@
 struct list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
 				const char *vgid);
 
+/* Returns cached volume group metadata. */
+struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted);
+
 #endif
--- LVM2/lib/format_text/export.c	2008/03/12 16:03:22	1.62
+++ LVM2/lib/format_text/export.c	2008/04/01 22:40:12	1.63
@@ -742,5 +742,10 @@
 	return r;
 }
 
+int export_vg_to_buffer(struct volume_group *vg, char **buf)
+{
+	return text_vg_export_raw(vg, "", buf);
+}
+
 #undef outf
 #undef outnl
--- LVM2/lib/format_text/import.c	2008/03/13 12:33:22	1.46
+++ LVM2/lib/format_text/import.c	2008/04/01 22:40:12	1.47
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -130,3 +130,27 @@
 	return text_vg_import_fd(fid, file, NULL, (off_t)0, 0, (off_t)0, 0, NULL, 0,
 				 when, desc);
 }
+
+struct volume_group *import_vg_from_buffer(char *buf,
+                                           struct format_instance *fid)
+{
+	struct volume_group *vg = NULL;
+	struct config_tree *cft;
+	struct text_vg_version_ops **vsn;
+
+	_init_text_import();
+
+	if (!(cft = create_config_tree_from_string(fid->fmt->cmd, buf)))
+		return_NULL;
+
+	for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
+		if (!(*vsn)->check_version(cft))
+			continue;
+		if (!(vg = (*vsn)->read_vg(fid, cft)))
+			stack;
+		break;
+	}
+
+	destroy_config_tree(cft);
+	return vg;
+}
--- LVM2/lib/metadata/metadata.c	2008/03/28 19:08:23	1.163
+++ LVM2/lib/metadata/metadata.c	2008/04/01 22:40:12	1.164
@@ -1316,9 +1316,6 @@
 	int cache_updated = 0;
 	int failed = 0;
 
-	/* Forget all cached instances of vg and force reread */
-	lvmcache_drop_vg(vg->name);             
-
 	/* Commit to each copy of the metadata area */
 	list_iterate_items(mda, &vg->fid->metadata_areas) {
 		failed = 0;
@@ -1455,6 +1452,11 @@
 		return _vg_read_orphans(cmd, vgname);
 	}
 
+	if ((correct_vg = lvmcache_get_vg(vgid, precommitted))) {
+		*consistent = 1;
+		return correct_vg;
+	}
+
 	/* Find the vgname in the cache */
 	/* If it's not there we must do full scan to be completely sure */
 	if (!(fmt = fmt_from_vgname(vgname, vgid))) {
--- LVM2/lib/metadata/metadata.h	2008/03/28 19:08:23	1.179
+++ LVM2/lib/metadata/metadata.h	2008/04/01 22:40:13	1.180
@@ -313,6 +313,13 @@
 struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv);
 
 /*
+ * For internal metadata caching.
+ */
+int export_vg_to_buffer(struct volume_group *vg, char **buf);
+struct volume_group *import_vg_from_buffer(char *buf,
+					   struct format_instance *fid);
+
+/*
  * Mirroring functions
  */
 


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2008-02-06 15:47 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2008-02-06 15:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-02-06 15:47:28

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/display    : display.c 
	lib/format1    : disk-rep.c format1.c format1.h import-export.c 
	                 lvm1-label.c 
	lib/format_pool: format_pool.c 
	lib/format_text: format-text.c format-text.h text_label.c 
	lib/label      : label.c 
	lib/metadata   : metadata-exported.h metadata.c 
	lib/report     : report.c 
	tools          : pvchange.c vgreduce.c 

Log message:
	split orphan VG by format type

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.789&r2=1.790
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.h.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/lvm1-label.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.156&r2=1.157
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79

--- LVM2/WHATS_NEW	2008/02/06 12:45:32	1.789
+++ LVM2/WHATS_NEW	2008/02/06 15:47:27	1.790
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Divide up internal orphan volume group by format type.
   Update usage message for clvmd.
   Fix clvmd man page printing <br>, clarified debug options.
   Fix lvresize to support /dev/mapper prefix in the lvname
--- LVM2/lib/cache/lvmcache.c	2008/01/30 16:18:37	1.37
+++ LVM2/lib/cache/lvmcache.c	2008/02/06 15:47:27	1.38
@@ -208,9 +208,6 @@
 	struct lvmcache_vginfo *vginfo;
 	const char *vgname = NULL;
 
-	if (!*vgid)
-		vgname = ORPHAN;
-
 	if ((vginfo = vginfo_from_vgid(vgid)))
 		vgname = vginfo->vgname;
 
@@ -530,8 +527,10 @@
 		return 0;
 	}
 
-	log_debug("lvmcache: %s: setting %s VGID to %s", dev_name(info->dev),
-		  info->vginfo->vgname, info->vginfo->vgid);
+	if (!is_orphan_vg(info->vginfo->vgname))
+		log_debug("lvmcache: %s: setting %s VGID to %s",
+			  dev_name(info->dev), info->vginfo->vgname,
+			  info->vginfo->vgid);
 
 	return 1;
 }
@@ -627,15 +626,6 @@
 	struct lvmcache_vginfo *vginfo, *primary_vginfo;
 	// struct lvmcache_vginfo  *old_vginfo, *next;
 
-	/* If vgname is NULL and we don't already have a vgname,
-	 * assume ORPHAN - we want every entry to have a vginfo
-	 * attached for scanning reasons.
-	 */
-	if (!vgname && !info->vginfo) {
-		vgname = ORPHAN;
-		vgid = ORPHAN;
-	}
-
 	if (!vgname || (info->vginfo && !strcmp(info->vginfo->vgname, vgname)))
 		return 1;
 
@@ -716,9 +706,8 @@
 	/* FIXME Check consistency of list! */
 	vginfo->fmt = info->fmt;
 
-	log_debug("lvmcache: %s: now %s%s%s%s%s", dev_name(info->dev),
-		  !is_orphan_vg(vgname) ? "in VG " : "orphaned", vgname,
-		  vginfo->vgid[0] ? " (" : "",
+	log_debug("lvmcache: %s: now in VG %s%s%s%s", dev_name(info->dev),
+		  vgname, vginfo->vgid[0] ? " (" : "",
 		  vginfo->vgid[0] ? vginfo->vgid : "",
 		  vginfo->vgid[0] ? ")" : "");
 
@@ -764,6 +753,12 @@
 				  const char *vgname, const char *vgid,
 				  uint32_t vgstatus, const char *creation_host)
 {
+	if (!vgname && !info->vginfo) {
+		log_error("Internal error: NULL vgname handed to cache");
+		/* FIXME Remove this */
+		vgname = info->fmt->orphan_vg_name;
+		vgid = vgname;
+	}
 	if (!_lvmcache_update_vgname(info, vgname, vgid, vgstatus,
 				     creation_host) ||
 	    !_lvmcache_update_vgid(info, vgid) ||
--- LVM2/lib/cache/lvmcache.h	2008/01/29 23:45:47	1.16
+++ LVM2/lib/cache/lvmcache.h	2008/02/06 15:47:27	1.17
@@ -20,7 +20,8 @@
 #include "uuid.h"
 #include "label.h"
 
-#define ORPHAN ""
+#define ORPHAN_PREFIX "#"
+#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "orphans_" fmt
 
 #define CACHE_INVALID	0x00000001
 #define CACHE_LOCKED	0x00000002
--- LVM2/lib/display/display.c	2008/01/30 13:59:58	1.85
+++ LVM2/lib/display/display.c	2008/02/06 15:47:27	1.86
@@ -307,7 +307,8 @@
 
 	log_print("--- %sPhysical volume ---", pv->pe_size ? "" : "NEW ");
 	log_print("PV Name               %s", pv_dev_name(pv));
-	log_print("VG Name               %s%s", pv->vg_name,
+	log_print("VG Name               %s%s",
+		  is_orphan(pv) ? "" : pv->vg_name,
 		  pv->status & EXPORTED_VG ? " (exported)" : "");
 
 	data_size = (uint64_t) pv->pe_count * pv->pe_size;
--- LVM2/lib/format1/disk-rep.c	2008/01/30 13:59:59	1.72
+++ LVM2/lib/format1/disk-rep.c	2008/02/06 15:47:27	1.73
@@ -326,10 +326,11 @@
 			      unsigned exported)
 {
 	struct lvmcache_info *info;
+	const char *vgname = *((char *)dl->pvd.vg_name) ?
+			     (char *)dl->pvd.vg_name : fmt->orphan_vg_name;
 
 	if (!(info = lvmcache_add(fmt->labeller, (char *)dl->pvd.pv_uuid, dev,
-				  (char *)dl->pvd.vg_name, vgid,
-				  exported ? EXPORTED_VG : 0))) {
+				  vgname, vgid, exported ? EXPORTED_VG : 0))) {
 		stack;
 		return;
 	}
@@ -363,20 +364,20 @@
 	if (!*dl->pvd.vg_name) {
 		log_very_verbose("%s is not a member of any format1 VG", name);
 
-		__update_lvmcache(fmt, dl, dev, NULL, 0);
+		__update_lvmcache(fmt, dl, dev, fmt->orphan_vg_name, 0);
 		return (vg_name) ? NULL : dl;
 	}
 
 	if (!read_vgd(dl->dev, &dl->vgd, &dl->pvd)) {
 		log_error("Failed to read VG data from PV (%s)", name);
-		__update_lvmcache(fmt, dl, dev, NULL, 0);
+		__update_lvmcache(fmt, dl, dev, fmt->orphan_vg_name, 0);
 		goto bad;
 	}
 
 	if (vg_name && strcmp(vg_name, (char *)dl->pvd.vg_name)) {
 		log_very_verbose("%s is not a member of the VG %s",
 				 name, vg_name);
-		__update_lvmcache(fmt, dl, dev, NULL, 0);
+		__update_lvmcache(fmt, dl, dev, fmt->orphan_vg_name, 0);
 		goto bad;
 	}
 
--- LVM2/lib/format1/format1.c	2008/01/30 13:59:59	1.105
+++ LVM2/lib/format1/format1.c	2008/02/06 15:47:27	1.106
@@ -18,13 +18,10 @@
 #include "limits.h"
 #include "display.h"
 #include "toolcontext.h"
-#include "lvmcache.h"
 #include "lvm1-label.h"
 #include "format1.h"
 #include "segtype.h"
 
-#define FMT_LVM1_NAME "lvm1"
-
 /* VG consistency checks */
 static int _check_vgs(struct list *pvs, int *partial)
 {
@@ -523,6 +520,7 @@
 	fmt->ops = &_format1_ops;
 	fmt->name = FMT_LVM1_NAME;
 	fmt->alias = NULL;
+	fmt->orphan_vg_name = FMT_LVM1_ORPHAN_VG_NAME;
 	fmt->features = FMT_RESTRICTED_LVIDS | FMT_ORPHAN_ALLOCATABLE |
 			FMT_RESTRICTED_READAHEAD;
 	fmt->private = NULL;
--- LVM2/lib/format1/format1.h	2007/08/20 20:55:25	1.12
+++ LVM2/lib/format1/format1.h	2008/02/06 15:47:27	1.13
@@ -17,6 +17,10 @@
 #define _LVM_FORMAT1_H
 
 #include "metadata.h"
+#include "lvmcache.h"
+
+#define FMT_LVM1_NAME "lvm1"
+#define FMT_LVM1_ORPHAN_VG_NAME ORPHAN_VG_NAME(FMT_LVM1_NAME)
 
 #ifdef LVM1_INTERNAL
 struct format_type *init_lvm1_format(struct cmd_context *cmd);
--- LVM2/lib/format1/import-export.c	2008/01/30 13:59:59	1.94
+++ LVM2/lib/format1/import-export.c	2008/02/06 15:47:27	1.95
@@ -26,6 +26,7 @@
 #include "pv_alloc.h"
 #include "display.h"
 #include "lvmcache.h"
+#include "metadata.h"
 
 #include <time.h>
 
@@ -61,7 +62,7 @@
 
 	pv->dev = dev;
 	if (!*pvd->vg_name)
-		pv->vg_name = ORPHAN;
+		pv->vg_name = fmt->orphan_vg_name;
 	else if (!(pv->vg_name = dm_pool_strdup(mem, (char *)pvd->vg_name))) {
 		log_error("Volume Group name allocation failed.");
 		return 0;
@@ -147,7 +148,7 @@
 
 	memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN);
 
-	if (pv->vg_name) {
+	if (pv->vg_name && !is_orphan(pv)) {
 		if (!_check_vg_name(pv->vg_name))
 			return_0;
 		strncpy((char *)pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
--- LVM2/lib/format1/lvm1-label.c	2008/01/30 13:59:59	1.18
+++ LVM2/lib/format1/lvm1-label.c	2008/02/06 15:47:27	1.19
@@ -19,7 +19,7 @@
 #include "label.h"
 #include "metadata.h"
 #include "xlate.h"
-#include "lvmcache.h"
+#include "format1.h"
 
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -60,17 +60,21 @@
 	struct pv_disk *pvd = (struct pv_disk *) buf;
 	struct vg_disk vgd;
 	struct lvmcache_info *info;
-	const char *vgid = NULL;
+	const char *vgid = FMT_LVM1_ORPHAN_VG_NAME;
+	const char *vgname = FMT_LVM1_ORPHAN_VG_NAME;
 	unsigned exported = 0;
 
 	munge_pvd(dev, pvd);
 
-	if (*pvd->vg_name && read_vgd(dev, &vgd, pvd)) {
+	if (*pvd->vg_name) {
+		if (!read_vgd(dev, &vgd, pvd))
+			return_0;
 		vgid = (char *) vgd.vg_uuid;
+		vgname = (char *) pvd->vg_name;
 		exported = pvd->pv_status & VG_EXPORTED;
 	}
 
-	if (!(info = lvmcache_add(l, (char *)pvd->pv_uuid, dev, (char *)pvd->vg_name, vgid,
+	if (!(info = lvmcache_add(l, (char *)pvd->pv_uuid, dev, vgname, vgid,
 				  exported)))
 		return_0;
 	*label = info->label;
--- LVM2/lib/format_pool/format_pool.c	2008/01/30 13:59:59	1.13
+++ LVM2/lib/format_pool/format_pool.c	2008/02/06 15:47:27	1.14
@@ -316,6 +316,7 @@
 	fmt->ops = &_format_pool_ops;
 	fmt->name = FMT_POOL_NAME;
 	fmt->alias = NULL;
+	fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_POOL_NAME);
 	fmt->features = 0;
 	fmt->private = NULL;
 
--- LVM2/lib/format_text/format-text.c	2008/01/30 13:59:59	1.88
+++ LVM2/lib/format_text/format-text.c	2008/02/06 15:47:27	1.89
@@ -36,9 +36,6 @@
 #include <dirent.h>
 #include <ctype.h>
 
-#define FMT_TEXT_NAME "lvm2"
-#define FMT_TEXT_ALIAS "text"
-
 static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
 					       struct device_area *dev_area);
 
@@ -387,7 +384,8 @@
 
       bad:
 	if ((info = info_from_pvid(dev_area->dev->pvid, 0)))
-		lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN, 0, NULL);
+		lvmcache_update_vgname_and_id(info, FMT_TEXT_ORPHAN_VG_NAME,
+					      FMT_TEXT_ORPHAN_VG_NAME, 0, NULL);
 
 	return NULL;
 }
@@ -1293,7 +1291,7 @@
 	/* FIXME Test mode don't update cache? */
 
 	if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
-				  ORPHAN, NULL, 0)))
+				  FMT_TEXT_ORPHAN_VG_NAME, NULL, 0)))
 		return_0;
 	label = info->label;
 
@@ -1438,7 +1436,7 @@
 	pv->dev = info->dev;
 	pv->fmt = info->fmt;
 	pv->size = info->device_size >> SECTOR_SHIFT;
-	pv->vg_name = ORPHAN;
+	pv->vg_name = FMT_TEXT_ORPHAN_VG_NAME;
 	memcpy(&pv->id, &info->dev->pvid, sizeof(pv->id));
 
 	/* Currently only support exactly one data area */
@@ -1887,6 +1885,7 @@
 	fmt->ops = &_text_handler;
 	fmt->name = FMT_TEXT_NAME;
 	fmt->alias = FMT_TEXT_ALIAS;
+	fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_TEXT_NAME);
 	fmt->features = FMT_SEGMENTS | FMT_MDAS | FMT_TAGS | FMT_PRECOMMIT |
 			FMT_UNLIMITED_VOLS | FMT_RESIZE_PV |
 			FMT_UNLIMITED_STRIPESIZE;
--- LVM2/lib/format_text/format-text.h	2007/11/05 17:17:55	1.23
+++ LVM2/lib/format_text/format-text.h	2008/02/06 15:47:27	1.24
@@ -19,6 +19,10 @@
 #include "lvm-types.h"
 #include "metadata.h"
 
+#define FMT_TEXT_NAME "lvm2"
+#define FMT_TEXT_ALIAS "text"
+#define FMT_TEXT_ORPHAN_VG_NAME ORPHAN_VG_NAME(FMT_TEXT_NAME)
+
 /*
  * Archives a vg config.  'retain_days' is the minimum number of
  * days that an archive file must be held for.  'min_archives' is
--- LVM2/lib/format_text/text_label.c	2008/01/30 13:59:59	1.20
+++ LVM2/lib/format_text/text_label.c	2008/02/06 15:47:27	1.21
@@ -207,7 +207,9 @@
 
 	pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
 
-	if (!(info = lvmcache_add(l, (char *)pvhdr->pv_uuid, dev, NULL, NULL, 0)))
+	if (!(info = lvmcache_add(l, (char *)pvhdr->pv_uuid, dev,
+				  FMT_TEXT_ORPHAN_VG_NAME,
+				  FMT_TEXT_ORPHAN_VG_NAME, 0)))
 		return_0;
 	*label = info->label;
 
--- LVM2/lib/label/label.c	2008/01/31 12:35:31	1.41
+++ LVM2/lib/label/label.c	2008/02/06 15:47:28	1.42
@@ -178,7 +178,8 @@
       out:
 	if (!found) {
 		if ((info = info_from_pvid(dev->pvid, 0)))
-			lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
+			lvmcache_update_vgname_and_id(info, info->fmt->orphan_vg_name,
+						      info->fmt->orphan_vg_name,
 						      0, NULL);
 		log_very_verbose("%s: No label detected", dev_name(dev));
 	}
@@ -275,7 +276,8 @@
 		stack;
 
 		if ((info = info_from_pvid(dev->pvid, 0)))
-			lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
+			lvmcache_update_vgname_and_id(info, info->fmt->orphan_vg_name,
+						      info->fmt->orphan_vg_name,
 						      0, NULL);
 
 		return r;
@@ -351,7 +353,8 @@
 
 	if (!dev_open(dev)) {
 		if ((info = info_from_pvid(dev->pvid, 0)))
-			lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
+			lvmcache_update_vgname_and_id(info, info->fmt->orphan_vg_name,
+						      info->fmt->orphan_vg_name,
 						      0, NULL);
 
 		return_0;
--- LVM2/lib/metadata/metadata-exported.h	2008/01/26 00:25:04	1.42
+++ LVM2/lib/metadata/metadata-exported.h	2008/02/06 15:47:28	1.43
@@ -133,6 +133,7 @@
 	struct labeller *labeller;
 	const char *name;
 	const char *alias;
+	const char *orphan_vg_name;
 	uint32_t features;
 	void *library;
 	void *private;
--- LVM2/lib/metadata/metadata.c	2008/01/30 14:00:00	1.156
+++ LVM2/lib/metadata/metadata.c	2008/02/06 15:47:28	1.157
@@ -356,7 +356,7 @@
 		pv = pvl->pv;
 		log_verbose("Removing physical volume \"%s\" from "
 			    "volume group \"%s\"", pv_dev_name(pv), vg_name);
-		pv->vg_name = ORPHAN;
+		pv->vg_name = vg->fid->fmt->orphan_vg_name;
 		pv->status = ALLOCATABLE_PV;
 
 		if (!dev_get_size(pv_dev(pv), &pv->size)) {
@@ -833,6 +833,7 @@
 	}
 
 	pv->fmt = fmt;
+	pv->vg_name = fmt->orphan_vg_name;
 
 	if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count,
 				existing_extent_size,
@@ -1324,7 +1325,8 @@
 }
 
 /* Make orphan PVs look like a VG */
-static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
+static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
+					     const char *orphan_vgname)
 {
 	struct lvmcache_vginfo *vginfo;
 	struct lvmcache_info *info;
@@ -1332,7 +1334,7 @@
 	struct volume_group *vg;
 	struct physical_volume *pv;
 
-	if (!(vginfo = vginfo_from_vgname(ORPHAN, NULL)))
+	if (!(vginfo = vginfo_from_vgname(orphan_vgname, NULL)))
 		return_NULL;
 
 	if (!(vg = dm_pool_zalloc(cmd->mem, sizeof(*vg)))) {
@@ -1343,7 +1345,7 @@
 	list_init(&vg->lvs);
 	list_init(&vg->tags);
 	vg->cmd = cmd;
-	if (!(vg->name = dm_pool_strdup(cmd->mem, ORPHAN))) {
+	if (!(vg->name = dm_pool_strdup(cmd->mem, orphan_vgname))) {
 		log_error("vg name allocation failed");
 		return NULL;
 	}
@@ -1421,7 +1423,7 @@
 			return NULL;
 		}
 		*consistent = 1;
-		return _vg_read_orphans(cmd);
+		return _vg_read_orphans(cmd, vgname);
 	}
 
 	/* Find the vgname in the cache */
@@ -1942,7 +1944,7 @@
 {
 	const char *old_vg_name = pv->vg_name;
 
-	pv->vg_name = ORPHAN;
+	pv->vg_name = cmd->fmt->orphan_vg_name;
 	pv->status = ALLOCATABLE_PV;
 
 	if (!dev_get_size(pv->dev, &pv->size)) {
@@ -1966,7 +1968,7 @@
  */
 int is_orphan_vg(const char *vg_name)
 {
-	return (!strcmp(vg_name, ORPHAN) ? 1 : 0);
+	return (vg_name && vg_name[0] == ORPHAN_PREFIX[0]) ? 1 : 0;
 }
 
 /**
--- LVM2/lib/report/report.c	2008/01/31 12:19:36	1.76
+++ LVM2/lib/report/report.c	2008/02/06 15:47:28	1.77
@@ -1004,7 +1004,7 @@
 
 /* necessary for displaying something for PVs not belonging to VG */
 static struct volume_group _dummy_vg = {
-	.name = (char *) ORPHAN,
+	.name = (char *) "",
 };
 
 static void *_obj_get_vg(void *obj)
--- LVM2/tools/pvchange.c	2008/01/30 14:00:02	1.58
+++ LVM2/tools/pvchange.c	2008/02/06 15:47:28	1.59
@@ -171,7 +171,7 @@
 		if (!is_orphan(pv)) {
 			orig_vg_name = pv_vg_name(pv);
 			orig_pe_alloc_count = pv_pe_alloc_count(pv);
-			pv->vg_name = ORPHAN;
+			pv->vg_name = pv->fmt->orphan_vg_name;
 			pv->pe_alloc_count = 0;
 			if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
 				log_error("pv_write with new uuid failed "
--- LVM2/tools/vgreduce.c	2008/01/30 14:17:29	1.78
+++ LVM2/tools/vgreduce.c	2008/02/06 15:47:28	1.79
@@ -376,7 +376,7 @@
 	if (pvl)
 		list_del(&pvl->list);
 
-	pv->vg_name = ORPHAN;
+	pv->vg_name = vg->fid->fmt->orphan_vg_name;
 	pv->status = ALLOCATABLE_PV;
 
 	if (!dev_get_size(pv_dev(pv), &pv->size)) {


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2008-01-29 23:45 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2008-01-29 23:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-29 23:45:48

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/device     : dev-io.c 
	lib/format_text: archiver.c format-text.c 
	lib/label      : label.c 
	lib/report     : report.c 

Log message:
	Rely upon internally-cached PV labels while corresponding VG lock is held.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.781&r2=1.782
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-io.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73

--- LVM2/WHATS_NEW	2008/01/29 12:02:04	1.781
+++ LVM2/WHATS_NEW	2008/01/29 23:45:47	1.782
@@ -1,5 +1,6 @@
 Version 2.02.33 -
 ===================================
+  Rely upon internally-cached PV labels while corresponding VG lock is held.
 
 Version 2.02.32 - 29th January 2008
 ===================================
--- LVM2/lib/cache/lvmcache.c	2007/11/05 17:12:50	1.33
+++ LVM2/lib/cache/lvmcache.c	2008/01/29 23:45:47	1.34
@@ -49,6 +49,41 @@
 	return 1;
 }
 
+static void _update_cache_info_lock_state(struct lvmcache_info *info, int locked)
+{
+	int was_locked = (info->status & CACHE_LOCKED) ? 1 : 0;
+
+	/*
+	 * Cache becomes invalid whenever lock state changes
+	 */
+	if (was_locked != locked)
+		info->status |= CACHE_INVALID;
+
+	if (locked)
+		info->status |= CACHE_LOCKED;
+	else
+		info->status &= ~CACHE_LOCKED;
+}
+
+static void _update_cache_vginfo_lock_state(struct lvmcache_vginfo *vginfo,
+					    int locked)
+{
+	struct lvmcache_info *info;
+
+	list_iterate_items(info, &vginfo->infos)
+		_update_cache_info_lock_state(info, locked);
+}
+
+static void _update_cache_lock_state(const char *vgname, int locked)
+{
+	struct lvmcache_vginfo *vginfo;
+
+	if (!(vginfo = vginfo_from_vgname(vgname, NULL)))
+		return;
+
+	_update_cache_vginfo_lock_state(vginfo, locked);
+}
+
 void lvmcache_lock_vgname(const char *vgname, int read_only __attribute((unused)))
 {
 	if (!_lock_hash && !lvmcache_init()) {
@@ -59,6 +94,8 @@
 	if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
 		log_error("Cache locking failure for %s", vgname);
 
+	_update_cache_lock_state(vgname, 1);
+
 	_vgs_locked++;
 }
 
@@ -72,7 +109,8 @@
 
 void lvmcache_unlock_vgname(const char *vgname)
 {
-	/* FIXME: Clear all CACHE_LOCKED flags in this vg */
+	_update_cache_lock_state(vgname, 0);
+
 	dm_hash_remove(_lock_hash, vgname);
 
 	/* FIXME Do this per-VG */
@@ -182,7 +220,22 @@
 	return vgname;
 }
 
-struct lvmcache_info *info_from_pvid(const char *pvid)
+static int _info_is_valid(struct lvmcache_info *info)
+{
+	if (info->status & CACHE_INVALID)
+		return 0;
+
+	if (!(info->status & CACHE_LOCKED))
+		return 0;
+
+	return 1;
+}
+
+/*
+ * If valid_only is set, data will only be returned if the cached data is
+ * known still to be valid.
+ */
+struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only)
 {
 	struct lvmcache_info *info;
 	char id[ID_LEN + 1] __attribute((aligned(8)));
@@ -196,6 +249,9 @@
 	if (!(info = dm_hash_lookup(_pvid_hash, id)))
 		return NULL;
 
+	if (valid_only && !_info_is_valid(info))
+		return NULL;
+
 	return info;
 }
 
@@ -344,7 +400,7 @@
 	struct lvmcache_info *info;
 
 	/* Already cached ? */
-	if ((info = info_from_pvid((char *) pvid))) {
+	if ((info = info_from_pvid((char *) pvid, 0))) {
 		if (label_read(info->dev, &label, UINT64_C(0))) {
 			info = (struct lvmcache_info *) label->info;
 			if (id_equal(pvid, (struct id *) &info->dev->pvid))
@@ -355,7 +411,7 @@
 	lvmcache_label_scan(cmd, 0);
 
 	/* Try again */
-	if ((info = info_from_pvid((char *) pvid))) {
+	if ((info = info_from_pvid((char *) pvid, 0))) {
 		if (label_read(info->dev, &label, UINT64_C(0))) {
 			info = (struct lvmcache_info *) label->info;
 			if (id_equal(pvid, (struct id *) &info->dev->pvid))
@@ -369,7 +425,7 @@
 	lvmcache_label_scan(cmd, 2);
 
 	/* Try again */
-	if ((info = info_from_pvid((char *) pvid))) {
+	if ((info = info_from_pvid((char *) pvid, 0))) {
 		if (label_read(info->dev, &label, UINT64_C(0))) {
 			info = (struct lvmcache_info *) label->info;
 			if (id_equal(pvid, (struct id *) &info->dev->pvid))
@@ -645,6 +701,8 @@
 	info->vginfo = vginfo;
 	list_add(&vginfo->infos, &info->list);
 
+	_update_cache_vginfo_lock_state(vginfo, vgname_is_locked(vgname));
+
 	/* FIXME Check consistency of list! */
 	vginfo->fmt = info->fmt;
 
@@ -716,7 +774,7 @@
 	list_iterate_items(pvl, &vg->pvs) {
 		strncpy(pvid_s, (char *) &pvl->pv->id, sizeof(pvid_s) - 1);
 		/* FIXME Could pvl->pv->dev->pvid ever be different? */
-		if ((info = info_from_pvid(pvid_s)) &&
+		if ((info = info_from_pvid(pvid_s, 0)) &&
 		    !lvmcache_update_vgname_and_id(info, vg->name,
 						   (char *) &vg->id,
 						   vg->status, NULL))
@@ -743,8 +801,8 @@
 	strncpy(pvid_s, pvid, sizeof(pvid_s));
 	pvid_s[sizeof(pvid_s) - 1] = '\0';
 
-	if (!(existing = info_from_pvid(pvid_s)) &&
-	    !(existing = info_from_pvid(dev->pvid))) {
+	if (!(existing = info_from_pvid(pvid_s, 0)) &&
+	    !(existing = info_from_pvid(dev->pvid, 0))) {
 		if (!(label = label_create(labeller))) {
 			stack;
 			return NULL;
--- LVM2/lib/cache/lvmcache.h	2007/08/20 20:55:24	1.15
+++ LVM2/lib/cache/lvmcache.h	2008/01/29 23:45:47	1.16
@@ -86,7 +86,7 @@
 struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
 					   const char *vgid);
 struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
-struct lvmcache_info *info_from_pvid(const char *pvid);
+struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
 const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
 struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid);
 int vgs_locked(void);
--- LVM2/lib/device/dev-io.c	2007/09/07 11:24:19	1.59
+++ LVM2/lib/device/dev-io.c	2008/01/29 23:45:47	1.60
@@ -523,7 +523,7 @@
 	/* Close unless device is known to belong to a locked VG */
 	if (immediate ||
 	    (dev->open_count < 1 && 
-	     (!(info = info_from_pvid(dev->pvid)) ||
+	     (!(info = info_from_pvid(dev->pvid, 0)) ||
 	      !info->vginfo ||
 	      !vgname_is_locked(info->vginfo->vgname))))
 		_close(dev);
--- LVM2/lib/format_text/archiver.c	2007/10/12 14:29:32	1.10
+++ LVM2/lib/format_text/archiver.c	2008/01/29 23:45:47	1.11
@@ -305,7 +305,7 @@
 	/* Add any metadata areas on the PVs */
 	list_iterate_items(pvl, &vg->pvs) {
 		pv = pvl->pv;
-		if (!(info = info_from_pvid(pv->dev->pvid))) {
+		if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
 			log_error("PV %s missing from cache",
 				  pv_dev_name(pv));
 			return 0;
--- LVM2/lib/format_text/format-text.c	2007/11/05 17:17:55	1.85
+++ LVM2/lib/format_text/format-text.c	2008/01/29 23:45:47	1.86
@@ -391,7 +391,7 @@
 	}
 
       error:
-	if ((info = info_from_pvid(dev_area->dev->pvid)))
+	if ((info = info_from_pvid(dev_area->dev->pvid, 0)))
 		lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN, 0, NULL);
 
 	return NULL;
@@ -1610,7 +1610,7 @@
 	/* If new vg, add any further mdas on this PV to the fid's mda list */
 	if (vg) {
 		/* Iterate through all mdas on this PV */
-		if ((info = info_from_pvid(pv->dev->pvid))) {
+		if ((info = info_from_pvid(pv->dev->pvid, 0))) {
 			pvmdas = &info->mdas;
 			list_iterate_items(mda, pvmdas) {
 				mda_count++;
--- LVM2/lib/label/label.c	2007/08/20 20:55:26	1.38
+++ LVM2/lib/label/label.c	2008/01/29 23:45:48	1.39
@@ -179,7 +179,7 @@
 
       out:
 	if (!found) {
-		if ((info = info_from_pvid(dev->pvid)))
+		if ((info = info_from_pvid(dev->pvid, 0)))
 			lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
 						      0, NULL);
 		log_very_verbose("%s: No label detected", dev_name(dev));
@@ -260,7 +260,6 @@
 	return r;
 }
 
-/* FIXME Avoid repeated re-reading if cache lock held */
 int label_read(struct device *dev, struct label **result,
 		uint64_t scan_sector)
 {
@@ -270,10 +269,16 @@
 	struct lvmcache_info *info;
 	int r = 0;
 
+	if ((info = info_from_pvid(dev->pvid, 1))) {
+		log_debug("Using cached label for %s", dev_name(dev));
+		*result = info->label;
+		return 1;
+	}
+
 	if (!dev_open(dev)) {
 		stack;
 
-		if ((info = info_from_pvid(dev->pvid)))
+		if ((info = info_from_pvid(dev->pvid, 0)))
 			lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
 						      0, NULL);
 
@@ -353,7 +358,7 @@
 	int r = 0;
 
 	if (!dev_open(dev)) {
-		if ((info = info_from_pvid(dev->pvid)))
+		if ((info = info_from_pvid(dev->pvid, 0)))
 			lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
 						      0, NULL);
 
--- LVM2/lib/report/report.c	2008/01/16 19:00:59	1.72
+++ LVM2/lib/report/report.c	2008/01/29 23:45:48	1.73
@@ -840,7 +840,7 @@
 	uint32_t count;
 	const char *pvid = (const char *)(&((struct id *) data)->uuid);
 
-	info = info_from_pvid(pvid);
+	info = info_from_pvid(pvid, 0);
 	count = info ? list_size(&info->mdas) : 0;
 
 	return _uint32_disp(rh, mem, field, &count, private);
@@ -867,7 +867,7 @@
 	const char *pvid = (const char *)(&((struct id *) data)->uuid);
 	struct metadata_area *mda;
 
-	info = info_from_pvid(pvid);
+	info = info_from_pvid(pvid, 0);
 
 	list_iterate_items(mda, &info->mdas) {
 		if (!mda->ops->mda_free_sectors)


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2006-04-13 21:08 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2006-04-13 21:08 UTC (permalink / raw)
  To: lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/metadata   : metadata.c 
	tools          : toollib.c vgrename.c 

Log message:
	vgrename accepts vgid and exported VG.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.362&r2=1.363
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2006-04-13 17:32 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2006-04-13 17:32 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-13 17:32:24

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format_text: format-text.c format-text.h import-export.h 
	                 import.c import_vsn1.c text_label.c 
	lib/label      : label.c 
	lib/log        : log.c log.h 

Log message:
	When choosing between identically-named VGs, also consider creation_host.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.360&r2=1.361
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2006-04-12 21:23 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2006-04-12 21:23 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-12 21:23:04

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format1    : disk-rep.h format1.c import-export.c 
	lib/format_pool: format_pool.c import_export.c 
	lib/format_text: archive.c archiver.c format-text.c 
	                 import_vsn1.c 
	lib/label      : label.c 
	lib/metadata   : metadata.c metadata.h 
	tools          : lvconvert.c lvcreate.c lvrename.c lvresize.c 
	                 pvchange.c pvmove.c pvresize.c reporter.c 
	                 toollib.c vgexport.c vgextend.c vgimport.c 
	                 vgmerge.c vgreduce.c vgrename.c vgsplit.c 

Log message:
	Fix vgexport/vgimport to set/reset PV exported flag so pv_attr is correct.
	Add vgid to struct physical_volume and pass with vg_name to some functions.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.359&r2=1.360
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.h.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/import_export.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.139&r2=1.140
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvrename.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgexport.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgimport.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2006-04-12 17:54 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2006-04-12 17:54 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-12 17:54:11

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format1    : disk-rep.c 
	lib/format_pool: disk_rep.c 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c 

Log message:
	If two or more VGs are found with the same name, use one that is not exported.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.358&r2=1.359
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/disk_rep.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2006-04-11 17:42 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2006-04-11 17:42 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-11 17:42:15

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format1    : disk-rep.c format1.c lvm1-label.c 
	lib/format_pool: disk_rep.c 
	lib/format_text: format-text.c format-text.h import-export.h 
	                 import.c import_vsn1.c text_label.c 
	lib/label      : label.c 

Log message:
	When scanning, also record whether or not VG is exported.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.357&r2=1.358
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/lvm1-label.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/disk_rep.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
@ 2006-04-11 13:56 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2006-04-11 13:56 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-11 13:55:59

Modified files:
	.              : WHATS_NEW 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/format_text: format-text.c format-text.h import-export.h 
	                 import.c import_vsn1.c text_label.c 
	lib/label      : label.c 

Log message:
	Whenever vgname is captured, also capture vgid.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.356&r2=1.357
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28


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

end of thread, other threads:[~2011-08-11 17:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-11 17:24 LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2011-06-01 19:29 agk
2011-03-30 13:14 zkabelac
2011-01-10 13:15 zkabelac
2011-01-10 13:13 zkabelac
2010-12-10 22:40 agk
2010-03-17  2:11 agk
2010-03-16 17:30 agk
2010-03-16 16:57 agk
2010-02-03 14:08 prajnoha
2009-09-02 21:34 wysochanski
2008-04-14 19:24 agk
2008-04-08 12:49 agk
2008-04-01 22:40 agk
2008-02-06 15:47 agk
2008-01-29 23:45 agk
2006-04-13 21:08 agk
2006-04-13 17:32 agk
2006-04-12 21:23 agk
2006-04-12 17:54 agk
2006-04-11 17:42 agk
2006-04-11 13:56 agk

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