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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-03-10 03:03:04

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

Log message:
	Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1939&r2=1.1940
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105

--- LVM2/WHATS_NEW	2011/03/09 12:44:42	1.1939
+++ LVM2/WHATS_NEW	2011/03/10 03:03:03	1.1940
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name.
   Use empty string instead of /dev// for LV path when there's no VG.
   Don't allocate unused VG mempool in _pvsegs_sub_single.
   Remove uninitialised byte from end of local clvmd messages.
--- LVM2/lib/cache/lvmcache.c	2011/02/21 12:07:03	1.104
+++ LVM2/lib/cache/lvmcache.c	2011/03/10 03:03:04	1.105
@@ -845,7 +845,7 @@
 			vginfo2->next = vginfo->next;
 			break;
 		}
- 	while ((vginfo2 = primary_vginfo->next));
+ 	while ((vginfo2 = vginfo2->next));
 
 	if (vginfo->vgname)
 		dm_free(vginfo->vgname);


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c
@ 2011-03-29 21:34 zkabelac
  0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-03-29 21:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-29 21:34:18

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

Log message:
	Fix access to released memory
	
	Invalid primary_vginfo was supposed to move all its lvmcache_infos to
	orphan_vginfo - however it has called _drop_vginfo() inside the loop
	that released primary_vginfo itself - thus made the loop using released
	memory.
	
	Use _vginfo_detach_info() instead and call _drop_vginfo after
	th loop is finished.
	
	Valgrind trace it should fix:
	
	Invalid read of size 8
	at 0x41E960: _lvmcache_update_vgname (lvmcache.c:1229)
	by 0x41EF86: lvmcache_update_vgname_and_id (lvmcache.c:1360)
	by 0x441393: _text_read (text_label.c:329)
	by 0x442221: label_read (label.c:289)
	by 0x41CF92: lvmcache_label_scan (lvmcache.c:635)
	by 0x45B303: _vg_read_by_vgid (metadata.c:3342)
	by 0x45B4A6: lv_from_lvid (metadata.c:3381)
	by 0x41B555: lv_activation_filter (activate.c:1346)
	by 0x415868: do_activate_lv (lvm-functions.c:343)
	by 0x415E8C: do_lock_lv (lvm-functions.c:532)
	by 0x40FD5F: do_command (clvmd-command.c:120)
	by 0x413D7B: process_local_command (clvmd.c:1686)
	Address 0x63eba10 is 16 bytes inside a block of size 160 free'd
	at 0x4C2756E: free (vg_replace_malloc.c:366)
	by 0x41DE70: _free_vginfo (lvmcache.c:980)
	by 0x41DEDA: _drop_vginfo (lvmcache.c:998)
	by 0x41E854: _lvmcache_update_vgname (lvmcache.c:1238)
	by 0x41EF86: lvmcache_update_vgname_and_id (lvmcache.c:1360)
	by 0x441393: _text_read (text_label.c:329)
	by 0x442221: label_read (label.c:289)
	by 0x41CF92: lvmcache_label_scan (lvmcache.c:635)
	by 0x45B303: _vg_read_by_vgid (metadata.c:3342)
	by 0x45B4A6: lv_from_lvid (metadata.c:3381)
	by 0x41B555: lv_activation_filter (activate.c:1346)
	by 0x415868: do_activate_lv (lvm-functions.c:343)
	
	problematic line:
	dm_list_iterate_items_safe(info2, info3, &primary_vginfo->infos)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1960&r2=1.1961
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108

--- LVM2/WHATS_NEW	2011/03/29 21:05:39	1.1960
+++ LVM2/WHATS_NEW	2011/03/29 21:34:18	1.1961
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fix lvmcache_info transfer to orphan_vginfo in _lvmcache_update_vgname().
   Fix -Wold-style-definition gcc warnings.
   Fixes for lvconvert (including --repair) of temporary mirror stacks.
   Mitigate annoying error warning from device is usable check if run as non-root.
--- LVM2/lib/cache/lvmcache.c	2011/03/13 23:01:08	1.107
+++ LVM2/lib/cache/lvmcache.c	2011/03/29 21:34:18	1.108
@@ -1107,17 +1107,17 @@
 		 * Otherwise we risk bogus warnings of duplicate VGs.
 		 */
 		while ((primary_vginfo = vginfo_from_vgname(vgname, NULL)) &&
-		       _scanning_in_progress && _vginfo_is_invalid(primary_vginfo))
+		       _scanning_in_progress && _vginfo_is_invalid(primary_vginfo)) {
+			orphan_vginfo = vginfo_from_vgname(primary_vginfo->fmt->orphan_vg_name, NULL);
+			if (!orphan_vginfo) {
+				log_error(INTERNAL_ERROR "Orphan vginfo %s lost from cache.",
+					  primary_vginfo->fmt->orphan_vg_name);
+				dm_free(vginfo->vgname);
+				dm_free(vginfo);
+				return 0;
+			}
 			dm_list_iterate_items_safe(info2, info3, &primary_vginfo->infos) {
-				orphan_vginfo = vginfo_from_vgname(primary_vginfo->fmt->orphan_vg_name, NULL);
-				if (!orphan_vginfo) {
-					log_error(INTERNAL_ERROR "Orphan vginfo %s lost from cache.",
-						  primary_vginfo->fmt->orphan_vg_name);
-					dm_free(vginfo->vgname);
-					dm_free(vginfo);
-					return 0;
-				}
-				_drop_vginfo(info2, primary_vginfo);	
+				_vginfo_detach_info(info2);
 				_vginfo_attach_info(orphan_vginfo, info2);
 				if (info2->mdas.n)
 					sprintf(mdabuf, " with %u mdas",
@@ -1129,6 +1129,10 @@
 					  vgname, orphan_vginfo->vgid[0] ? " (" : "",
 					  orphan_vginfo->vgid[0] ? orphan_vginfo->vgid : "",
 					  orphan_vginfo->vgid[0] ? ")" : "", mdabuf);
+			}
+
+			if (!_drop_vginfo(NULL, primary_vginfo))
+				return_0;
 		}
 
 		if (!_insert_vginfo(vginfo, vgid, vgstatus, creation_host,


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-01 10:39:29

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

Log message:
	Check result of vginfo_from_vgname
	
	Check for some potential internal error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1820&r2=1.1821
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98

--- LVM2/WHATS_NEW	2010/12/01 10:33:55	1.1820
+++ LVM2/WHATS_NEW	2010/12/01 10:39:28	1.1821
@@ -1,5 +1,6 @@
 Version 2.02.78 - 
 ====================================
+  Add test for existance of orphan vginfo in _lvmcache_update_vgname().
   Do a full rescan if some device is missing in read_pvs_in_vg().
   Avoid misleading warnings in vgextend --restoremissing in certain cases.
   Add error path stack traces for _process_mapper_dir(), _create_and_load_v4().
--- LVM2/lib/cache/lvmcache.c	2010/10/25 13:33:42	1.97
+++ LVM2/lib/cache/lvmcache.c	2010/12/01 10:39:29	1.98
@@ -1083,6 +1083,13 @@
 		       _scanning_in_progress && _vginfo_is_invalid(primary_vginfo))
 			dm_list_iterate_items_safe(info2, info3, &primary_vginfo->infos) {
 				orphan_vginfo = vginfo_from_vgname(primary_vginfo->fmt->orphan_vg_name, NULL);
+				if (!orphan_vginfo) {
+					log_error(INTERNAL_ERROR "Orphan vginfo %s lost from cache.",
+						  primary_vginfo->fmt->orphan_vg_name);
+					dm_free(vginfo->vgname);
+					dm_free(vginfo);
+					return 0;
+				}
 				_drop_vginfo(info2, primary_vginfo);	
 				_vginfo_attach_info(orphan_vginfo, info2);
 				if (info2->mdas.n)


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-03-31 17:20:44

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

Log message:
	Remove vg_validate call when parsing cached metadata.
	
	vg_validate call is an adept to optimisation, it is very
	ineeficient and slow.
	
	Anyway, we should call it only before writing data to disk.
	
	The call in lvmcache was just temporary validation,
	we realy do not need to revalidate cached metadata
	every time.
	(Actually, I added that there just to prove that cache works
	properly and forgot to remove it.)
	
	Patch removes it from lvmcache completely, this can hit only
	internal bug in export function (and this bug must
	be detected in any vg_write call anyway before).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1493&r2=1.1494
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83

--- LVM2/WHATS_NEW	2010/03/31 17:20:02	1.1493
+++ LVM2/WHATS_NEW	2010/03/31 17:20:44	1.1494
@@ -1,5 +1,6 @@
 Version 2.02.63 -  
 ================================
+  Remove vg_validate call when parsing cached metadata.
   Use hash table of LVs to speed up parsing of text metadata with many LVs.
   Fix two messages, add a whitespace and parentheses
   When dmeventd is not forking because of -d flag, don't kill the parent process
--- LVM2/lib/cache/lvmcache.c	2010/03/17 02:11:18	1.82
+++ LVM2/lib/cache/lvmcache.c	2010/03/31 17:20:44	1.83
@@ -610,8 +610,7 @@
 						      vgid, NULL)))
 		return_NULL;
 
-	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid)) ||
-	    !vg_validate(vg)) {
+	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid))) {
 		_free_cached_vgmetadata(vginfo);
 		vg_release(vg);
 		return_NULL;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-10-22 17:33:09

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

Log message:
	Remember to clear 'global lock held during cache refresh' state after use.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1299&r2=1.1300
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70

--- LVM2/WHATS_NEW	2009/10/22 13:00:07	1.1299
+++ LVM2/WHATS_NEW	2009/10/22 17:33:09	1.1300
@@ -1,5 +1,6 @@
 Version 2.02.54 -
 =====================================
+  Remember to clear 'global lock held during cache refresh' state after use.
   Use udev flags support in LVM.
   Delay announcing mirror monitoring to syslog until initialisation succeeded.
   Handle metadata with unknown segment types more gracefully.
--- LVM2/lib/cache/lvmcache.c	2009/09/15 13:49:11	1.69
+++ LVM2/lib/cache/lvmcache.c	2009/10/22 17:33:09	1.70
@@ -52,8 +52,15 @@
 	if (!(_lock_hash = dm_hash_create(128)))
 		return 0;
 
-	if (_vg_global_lock_held)
+	/*
+	 * Reinitialising the cache clears the internal record of
+	 * which locks are held.  The global lock can be held during
+	 * this operation so its state must be restored afterwards.
+	 */
+	if (_vg_global_lock_held) {
 		lvmcache_lock_vgname(VG_GLOBAL, 0);
+		_vg_global_lock_held = 0;
+	}
 
 	return 1;
 }


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c
@ 2009-02-17 18:56 agk
  0 siblings, 0 replies; 11+ messages in thread
From: agk @ 2009-02-17 18:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-02-17 18:56:41

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

Log message:
	Index cached vgmetadata by vgid not vgname to cope with duplicate vgnames.  (dwyso)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1043&r2=1.1044
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64

--- LVM2/WHATS_NEW	2009/02/12 20:42:07	1.1043
+++ LVM2/WHATS_NEW	2009/02/17 18:56:41	1.1044
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Index cached vgmetadata by vgid not vgname to cope with duplicate vgnames.
   No longer require kernel and metadata major numbers to match.
   Add a fully-functional get_cluster_name() to clvmd corosync interface.
   Remove duplicate cpg_initialize from clvmd startup.
--- LVM2/lib/cache/lvmcache.c	2008/11/28 15:51:40	1.63
+++ LVM2/lib/cache/lvmcache.c	2009/02/17 18:56:41	1.64
@@ -71,11 +71,20 @@
 	log_debug("Metadata cache: VG %s wiped.", vginfo->vgname);
 }
 
-static void _store_metadata(struct lvmcache_vginfo *vginfo,
-			    struct volume_group *vg, unsigned precommitted)
+/*
+ * Cache VG metadata against the vginfo with matching vgid.
+ */
+static void _store_metadata(struct volume_group *vg, unsigned precommitted)
 {
+	char uuid[64] __attribute((aligned(8)));
+	struct lvmcache_vginfo *vginfo;
 	int size;
 
+	if (!(vginfo = vginfo_from_vgid((const char *)&vg->id))) {
+		stack;
+		return;
+	}
+
 	if (vginfo->vgmetadata)
 		_free_cached_vgmetadata(vginfo);
 
@@ -86,8 +95,14 @@
 
 	vginfo->precommitted = precommitted;
 
-	log_debug("Metadata cache: VG %s stored (%d bytes%s).", vginfo->vgname,
-		  size, precommitted ? ", precommitted" : "");
+	if (!id_write_format((const struct id *)vginfo->vgid, uuid, sizeof(uuid))) {
+		stack;
+		return;
+	}
+
+	log_debug("Metadata cache: VG %s (%s) stored (%d bytes%s).",
+		  vginfo->vgname, uuid, size,
+		  precommitted ? ", precommitted" : "");
 }
 
 static void _update_cache_info_lock_state(struct lvmcache_info *info,
@@ -1051,7 +1066,6 @@
 {
 	struct pv_list *pvl;
 	struct lvmcache_info *info;
-	struct lvmcache_vginfo *vginfo;
 	char pvid_s[ID_LEN + 1] __attribute((aligned(8)));
 
 	pvid_s[sizeof(pvid_s) - 1] = '\0';
@@ -1067,9 +1081,8 @@
 	}
 
 	/* store text representation of vg to cache */
-	if (vg->cmd->current_settings.cache_vgmetadata &&
-	    (vginfo = vginfo_from_vgname(vg->name, NULL)))
-		_store_metadata(vginfo, vg, precommitted);
+	if (vg->cmd->current_settings.cache_vgmetadata)
+		_store_metadata(vg, precommitted);
 
 	return 1;
 }


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c
@ 2008-11-27 18:13 agk
  0 siblings, 0 replies; 11+ messages in thread
From: agk @ 2008-11-27 18:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-11-27 18:13:51

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

Log message:
	Don't skip updating pvid hash when lvmcache_info struct got swapped.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1000&r2=1.1001
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62

--- LVM2/WHATS_NEW	2008/11/24 13:33:16	1.1000
+++ LVM2/WHATS_NEW	2008/11/27 18:13:50	1.1001
@@ -1,5 +1,6 @@
 Version 2.02.44 - 
 ====================================
+  Don't skip updating pvid hash when lvmcache_info struct got swapped.
   Add tinfo to termcap search path for pld-linux.
   Fix startup race in clvmd.
   Generate Red Hat clvmd startup script at configuration time with correct paths.
--- LVM2/lib/cache/lvmcache.c	2008/11/03 22:14:27	1.61
+++ LVM2/lib/cache/lvmcache.c	2008/11/27 18:13:51	1.62
@@ -707,7 +707,11 @@
 
 static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid)
 {
-	if (!strcmp(info->dev->pvid, pvid))
+	/*
+	 * Nothing to do if already stored with same pvid.
+	 */
+	if (((dm_hash_lookup(_pvid_hash, pvid)) == info) &&
+	    !strcmp(info->dev->pvid, pvid))
 		return 1;
 	if (*info->dev->pvid) {
 		dm_hash_remove(_pvid_hash, info->dev->pvid);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-06-11 11:02:05

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

Log message:
	Fix tracking of validity of PVs with no mdas in lvmcache.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.896&r2=1.897
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58

--- LVM2/WHATS_NEW	2008/06/10 20:07:04	1.896
+++ LVM2/WHATS_NEW	2008/06/11 11:02:05	1.897
@@ -1,5 +1,6 @@
 Version 2.02.38 - 
 =================================
+  Fix tracking of validity of PVs with no mdas in lvmcache.
   Fix return values for reporting commands when run with no PVs, LVs, or VGs.
   Add omitted unlock_vg() call when sigint_caught() during vg processing.
   Fix wrong free_count on imported vg from pool device
--- LVM2/lib/cache/lvmcache.c	2008/06/09 16:22:33	1.57
+++ LVM2/lib/cache/lvmcache.c	2008/06/11 11:02:05	1.58
@@ -1015,6 +1015,15 @@
 		vgid = vgname;
 	}
 
+	/* If PV without mdas is already in a real VG, don't make it orphan */
+	if (is_orphan_vg(vgname) && info->vginfo && !list_size(&info->mdas) &&
+	    !is_orphan_vg(info->vginfo->vgname) && memlock())
+		return 1;
+
+	/* If moving PV from orphan to real VG, always mark it valid */
+	if (!is_orphan_vg(vgname))
+		info->status &= ~CACHE_INVALID;
+
 	if (!_lvmcache_update_vgname(info, vgname, vgid, vgstatus,
 				     creation_host, info->fmt) ||
 	    !_lvmcache_update_vgid(info, info->vginfo, vgid) ||


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-06-09 16:22:33

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

Log message:
	Fix segfault after _free_vginfo by remembering to remove vginfo from list.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.892&r2=1.893
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57

--- LVM2/WHATS_NEW	2008/06/08 14:18:44	1.892
+++ LVM2/WHATS_NEW	2008/06/09 16:22:32	1.893
@@ -1,5 +1,6 @@
 Version 2.02.38 - 
 =================================
+  Fix segfault after _free_vginfo by remembering to remove vginfo from list.
   Tweak detection of invalid fid after changes to PVs in VG in _vg_read.
   Revert assuming precommitted metadata is live when activating (unnecessary).
   Drop cached metadata for disappearing VG in vgmerge.
--- LVM2/lib/cache/lvmcache.c	2008/06/06 12:43:40	1.56
+++ LVM2/lib/cache/lvmcache.c	2008/06/09 16:22:33	1.57
@@ -631,11 +631,14 @@
 
 static int _free_vginfo(struct lvmcache_vginfo *vginfo)
 {
+	struct lvmcache_vginfo *primary_vginfo, *vginfo2;
 	int r = 1;
 
 	_free_cached_vgmetadata(vginfo);
 
-	if (vginfo_from_vgname(vginfo->vgname, NULL) == vginfo) {
+	vginfo2 = primary_vginfo = vginfo_from_vgname(vginfo->vgname, NULL);
+
+	if (vginfo == primary_vginfo) {
 		dm_hash_remove(_vgname_hash, vginfo->vgname);
 		if (vginfo->next && !dm_hash_insert(_vgname_hash, vginfo->vgname,
 						    vginfo->next)) {
@@ -643,7 +646,12 @@
 				  vginfo->vgname);
 			r = 0;
 		}
-	}
+	} else do
+		if (vginfo2->next == vginfo) {
+			vginfo2->next = vginfo->next;
+			break;
+		}
+ 	while ((vginfo2 = primary_vginfo->next));
 
 	if (vginfo->vgname)
 		dm_free(vginfo->vgname);


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

* LVM2 ./WHATS_NEW lib/cache/lvmcache.c
@ 2008-05-08 18:28 agk
  0 siblings, 0 replies; 11+ messages in thread
From: agk @ 2008-05-08 18:28 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-05-08 18:28:27

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

Log message:
	When asked to drop cached committed VG metadata, invalidate cached PV labels.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.868&r2=1.869
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48

--- LVM2/WHATS_NEW	2008/05/08 18:06:58	1.868
+++ LVM2/WHATS_NEW	2008/05/08 18:28:27	1.869
@@ -5,6 +5,7 @@
 
 Version 2.02.37 - 
 =================================
+  When asked to drop cached committed VG metadata, invalidate cached PV labels.
   Drop metadata cache before writing precommitted metadata instead of after.
   Don't touch /dev in vgrename if activation is disabled.
 
--- LVM2/lib/cache/lvmcache.c	2008/04/24 02:22:06	1.47
+++ LVM2/lib/cache/lvmcache.c	2008/05/08 18:28:27	1.48
@@ -22,6 +22,9 @@
 #include "filter.h"
 #include "memlock.h"
 #include "str_list.h"
+#include "format-text.h"
+#include "format_pool.h"
+#include "format1.h"
 
 static struct dm_hash_table *_pvid_hash = NULL;
 static struct dm_hash_table *_vgid_hash = NULL;
@@ -130,16 +133,39 @@
 	_update_cache_vginfo_lock_state(vginfo, locked);
 }
 
-void lvmcache_drop_metadata(const char *vgname)
+static void _drop_metadata(const char *vgname)
 {
 	struct lvmcache_vginfo *vginfo;
+	struct lvmcache_info *info;
 
 	if (!(vginfo = vginfo_from_vgname(vgname, NULL)))
 		return;
 
+	/*
+	 * Invalidate cached PV labels.
+	 * If cached precommitted metadata exists that means we
+	 * already invalidated the PV labels (before caching it)
+	 * and we must not do it again.
+	 */
+
+	if (!vginfo->precommitted)
+		list_iterate_items(info, &vginfo->infos)
+			info->status |= CACHE_INVALID;
+
 	_free_cached_vgmetadata(vginfo);
 }
 
+void lvmcache_drop_metadata(const char *vgname)
+{
+	/* For VG_ORPHANS, we need to invalidate all labels on orphan PVs. */
+	if (strcmp(vgname, VG_ORPHANS)) {
+		_drop_metadata(FMT_TEXT_ORPHAN_VG_NAME);
+		_drop_metadata(FMT_LVM1_ORPHAN_VG_NAME);
+		_drop_metadata(FMT_POOL_ORPHAN_VG_NAME);
+	} else
+		_drop_metadata(vgname);
+}
+
 void lvmcache_lock_vgname(const char *vgname, int read_only __attribute((unused)))
 {
 	if (!_lock_hash && !lvmcache_init()) {


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-06-14 20:11:23

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

Log message:
	Fix PV tools to include orphaned PVs in default output again.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.402&r2=1.403
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27

--- LVM2/WHATS_NEW	2006/06/12 17:34:20	1.402
+++ LVM2/WHATS_NEW	2006/06/14 20:11:22	1.403
@@ -1,5 +1,7 @@
 Version 2.02.07 - 
 =================================
+  Fix PV tools to include orphaned PVs in default output again.
+  Fixed unaligned access when using clvm.
   Fix an extra dev_close in a label_read error path.
   Append patches to commit emails.
   Fix target_register_events args.
@@ -13,7 +15,6 @@
   Add 'Completed' debug message.
   Don't attempt library exit after reloading config files.
   Always compile with libdevmapper, even if device-mapper is disabled.
-  Fixed unaligned access when using clvm.
 
 Version 2.02.06 - 12th May 2006
 ===============================
--- LVM2/lib/cache/lvmcache.c	2006/05/11 17:58:58	1.26
+++ LVM2/lib/cache/lvmcache.c	2006/06/14 20:11:22	1.27
@@ -169,14 +169,18 @@
 const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid)
 {
 	struct lvmcache_vginfo *vginfo;
+	const char *vgname = NULL;
 
-	if ((vginfo = vginfo_from_vgid(vgid))) {
-		if (mem)
-			return dm_pool_strdup(mem, vginfo->vgname);
-		return vginfo->vgname;
-	}
+	if (!*vgid)
+		vgname = ORPHAN;
 
-	return NULL;
+	if ((vginfo = vginfo_from_vgid(vgid)))
+		vgname = vginfo->vgname;
+
+	if (mem && vgname)
+		return dm_pool_strdup(mem, vgname);
+
+	return vgname;
 }
 
 struct lvmcache_info *info_from_pvid(const char *pvid)


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

end of thread, other threads:[~2011-03-29 21:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-10  3:03 LVM2 ./WHATS_NEW lib/cache/lvmcache.c agk
  -- strict thread matches above, loose matches on Subject: below --
2011-03-29 21:34 zkabelac
2010-12-01 10:39 zkabelac
2010-03-31 17:20 mbroz
2009-10-22 17:33 agk
2009-02-17 18:56 agk
2008-11-27 18:13 agk
2008-06-11 11:02 agk
2008-06-09 16:22 agk
2008-05-08 18:28 agk
2006-06-14 20:11 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).