public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/format_text/archiver.c li ...
@ 2010-04-14 13:09 prajnoha
  0 siblings, 0 replies; 2+ messages in thread
From: prajnoha @ 2010-04-14 13:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-04-14 13:09:17

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

Log message:
	Do not reset position in metadata ring buffer on vgrename and vgcfgrestore.
	
	We should write metadata into next position in the ring buffer while calling
	vgrename and vgcfgrestore. At this code level (_vg_write_raw), we were not able
	to determine if this is a rename or not. If yes, then accompanying VG structure
	passed here has a new name set, not the old one.
	
	When looking for a location where to put metadata next, we were given a NULL
	value because of failed VG name comparison (in _find_vg_rlocn) between the
	name in existing metadata and metadata we're just about to write.
	
	This resets the position in the ring buffer, overwriting any existing metadata
	(and also incorrectly updates the cache to "orphan" afterwards).
	
	This patch just adds old_name item in struct volume_group that we can check and use
	if necessary and detect renames at lower layers as well.
	
	The same applies for vgcfgrestore, but here we're using a special value of
	old_name, an empty string, to disable the check with existing metadata totally.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1519&r2=1.1520
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.336&r2=1.337

--- LVM2/WHATS_NEW	2010/04/14 13:03:06	1.1519
+++ LVM2/WHATS_NEW	2010/04/14 13:09:16	1.1520
@@ -1,5 +1,6 @@
 Version 2.02.63 -  
 ================================
+  Do not reset position in metadata ring buffer on vgrename and vgcfgrestore.
   Allow VGs with active LVs to be renamed.
   Use UUIDs instead of names while processing event handlers.
   Only pass visible LVs to tools in cmdline VG name/tag expansions without -a.
--- LVM2/lib/format_text/archiver.c	2009/09/14 19:44:16	1.29
+++ LVM2/lib/format_text/archiver.c	2010/04/14 13:09:16	1.30
@@ -306,6 +306,12 @@
 		return 0;
 	}
 
+	/*
+	 * Setting vg->old_name to a blank value will explicitly
+	 * disable any attempt to check VG name in existing metadata.
+	*/
+	vg->old_name = dm_pool_strdup(vg->vgmem, "");
+
 	/* Add any metadata areas on the PVs */
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		pv = pvl->pv;
--- LVM2/lib/format_text/format-text.c	2010/03/16 17:30:01	1.120
+++ LVM2/lib/format_text/format-text.c	2010/04/14 13:09:16	1.121
@@ -380,6 +380,17 @@
 	} else
 		*precommitted = 0;
 
+	/* Do not check non-existent metadata. */
+	if (!rlocn->offset && !rlocn->size)
+		return NULL;
+
+	/*
+	 * Don't try to check existing metadata
+	 * if given vgname is an empty string.
+	 */
+	if (!*vgname)
+		return rlocn;
+
 	/* FIXME Loop through rlocns two-at-a-time.  List null-terminated. */
 	/* FIXME Ignore if checksum incorrect!!! */
 	if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
@@ -387,9 +398,11 @@
 		goto_bad;
 
 	if (!strncmp(vgnamebuf, vgname, len = strlen(vgname)) &&
-	    (isspace(vgnamebuf[len]) || vgnamebuf[len] == '{')) {
+	    (isspace(vgnamebuf[len]) || vgnamebuf[len] == '{'))
 		return rlocn;
-	}
+	else
+		log_debug("Volume group name found in metadata does "
+			  "not match expected name %s.", vgname);
 
       bad:
 	if ((info = info_from_pvid(dev_area->dev->pvid, 0)))
@@ -542,7 +555,8 @@
 	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
 		goto_out;
 
-	rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit);
+	rlocn = _find_vg_rlocn(&mdac->area, mdah,
+			vg->old_name ? vg->old_name : vg->name, &noprecommit);
 	mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah);
 
 	if (!fidtc->raw_metadata_buf &&
@@ -647,7 +661,9 @@
 	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
 		goto_out;
 
-	if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit))) {
+	if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah,
+				     vg->old_name ? vg->old_name : vg->name,
+				     &noprecommit))) {
 		mdah->raw_locns[0].offset = 0;
 		mdah->raw_locns[0].size = 0;
 		mdah->raw_locns[0].checksum = 0;
--- LVM2/lib/metadata/metadata-exported.h	2010/04/13 17:26:36	1.141
+++ LVM2/lib/metadata/metadata-exported.h	2010/04/14 13:09:17	1.142
@@ -227,6 +227,7 @@
 
 	struct id id;
 	char *name;
+	char *old_name;		/* Set during vgrename and vgcfgrestore */
 	char *system_id;
 
 	uint32_t extent_size;
--- LVM2/lib/metadata/metadata.c	2010/04/13 17:26:36	1.336
+++ LVM2/lib/metadata/metadata.c	2010/04/14 13:09:17	1.337
@@ -457,6 +457,8 @@
 	struct dm_pool *mem = vg->vgmem;
 	struct pv_list *pvl;
 
+	vg->old_name = vg->name;
+
 	if (!(vg->name = dm_pool_strdup(mem, new_name))) {
 		log_error("vg->name allocation failed for '%s'", new_name);
 		return 0;
@@ -2428,11 +2430,15 @@
 		}
 	}
 
-	/*
-	 * Instruct remote nodes to upgrade cached metadata.
-	 */
-	if (cache_updated)
+	if (cache_updated) {
+		/* Instruct remote nodes to upgrade cached metadata. */
 		remote_commit_cached_metadata(vg);
+		/*
+		 * We need to clear old_name after a successful commit.
+		 * The volume_group structure could be reused later.
+		 */
+		vg->old_name = NULL;
+	}
 
 	/* If update failed, remove any cached precommitted metadata. */
 	if (!cache_updated && !drop_cached_metadata(vg))


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

* LVM2 ./WHATS_NEW lib/format_text/archiver.c li ...
@ 2009-04-02 21:34 taka
  0 siblings, 0 replies; 2+ messages in thread
From: taka @ 2009-04-02 21:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	taka@sourceware.org	2009-04-02 21:34:41

Modified files:
	.              : WHATS_NEW 
	lib/format_text: archiver.c import_vsn1.c 
	lib/snapshot   : snapshot.c 

Log message:
	Save and restore the previous logging level when log level is changed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1075&r2=1.1076
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36

--- LVM2/WHATS_NEW	2009/04/02 20:46:11	1.1075
+++ LVM2/WHATS_NEW	2009/04/02 21:34:41	1.1076
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Save and restore the previous logging level when log level is changed.
   Fix error message when archive initialization fails.
   Make sure clvmd-corosync releases the lockspace when it exits.
   Fix segfault for vgcfgrestore on VG with missing PVs.
--- LVM2/lib/format_text/archiver.c	2009/03/24 13:16:35	1.21
+++ LVM2/lib/format_text/archiver.c	2009/04/02 21:34:41	1.22
@@ -397,6 +397,7 @@
 {
 	char path[PATH_MAX];
 	struct volume_group *vg_backup;
+	int old_suppress;
 
 	if (vg->status & EXPORTED_VG)
 		return;
@@ -407,15 +408,15 @@
 		return;
 	}
 
-	log_suppress(1);
+	old_suppress = log_suppress(1);
 	/* Up-to-date backup exists? */
 	if ((vg_backup = backup_read_vg(vg->cmd, vg->name, path)) &&
 	    (vg->seqno == vg_backup->seqno) &&
 	    (id_equal(&vg->id, &vg_backup->id))) {
-		log_suppress(0);
+		log_suppress(old_suppress);
 		return;
 	}
-	log_suppress(0);
+	log_suppress(old_suppress);
 
 	if (vg_backup)
 		archive(vg_backup);
--- LVM2/lib/format_text/import_vsn1.c	2009/03/09 15:42:12	1.56
+++ LVM2/lib/format_text/import_vsn1.c	2009/04/02 21:34:41	1.57
@@ -816,10 +816,11 @@
 {
 	const char *d;
 	unsigned int u = 0u;
+	int old_suppress;
 
-	log_suppress(1);
+	old_suppress = log_suppress(1);
 	d = find_config_str(cft->root, "description", "");
-	log_suppress(0);
+	log_suppress(old_suppress);
 	*desc = dm_pool_strdup(mem, d);
 
 	get_config_uint32(cft->root, "creation_time", &u);
--- LVM2/lib/snapshot/snapshot.c	2009/02/28 20:04:25	1.35
+++ LVM2/lib/snapshot/snapshot.c	2009/04/02 21:34:41	1.36
@@ -37,6 +37,7 @@
 	uint32_t chunk_size;
 	const char *org_name, *cow_name;
 	struct logical_volume *org, *cow;
+	int old_suppress;
 
 	seg->lv->status |= SNAPSHOT;
 
@@ -45,21 +46,21 @@
 		return 0;
 	}
 
-	log_suppress(1);
+	old_suppress = log_suppress(1);
 
 	if (!(cow_name = find_config_str(sn, "cow_store", NULL))) {
-		log_suppress(0);
+		log_suppress(old_suppress);
 		log_error("Snapshot cow storage not specified.");
 		return 0;
 	}
 
 	if (!(org_name = find_config_str(sn, "origin", NULL))) {
-		log_suppress(0);
+		log_suppress(old_suppress);
 		log_error("Snapshot origin not specified.");
 		return 0;
 	}
 
-	log_suppress(0);
+	log_suppress(old_suppress);
 
 	if (!(cow = find_lv(seg->lv->vg, cow_name))) {
 		log_error("Unknown logical volume specified for "


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

end of thread, other threads:[~2010-04-14 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-14 13:09 LVM2 ./WHATS_NEW lib/format_text/archiver.c li prajnoha
  -- strict thread matches above, loose matches on Subject: below --
2009-04-02 21:34 taka

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