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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-10 14:40:33

Modified files:
	lib/metadata   : metadata.c 
	.              : WHATS_NEW 

Log message:
	Refactor code for _lv_postoder
	
	Add _lv_postorder_vg() - for calling _lv_postorder() for every LV from VG.
	We use this in 2 places -  vg_mark_partial_lvs() and vg_validate()
	so make it as a one function.
	
	Benefit here is - to use only one cleanup code and avoid
	potentially duplicate scans of same LVs.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.439&r2=1.440
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1942&r2=1.1943

--- LVM2/lib/metadata/metadata.c	2011/03/10 13:12:00	1.439
+++ LVM2/lib/metadata/metadata.c	2011/03/10 14:40:32	1.440
@@ -2039,6 +2039,29 @@
 	return r;
 }
 
+/*
+ * Calls _lv_postorder() on each LV from VG. Avoids duplicate transitivity visits.
+ * Clears with _lv_postorder_cleanup() when all LVs were visited by postorder.
+ */
+static int _lv_postorder_vg(struct volume_group *vg,
+			    int (*fn)(struct logical_volume *lv, void *data),
+			    void *data)
+{
+	struct lv_list *lvl;
+	int r = 1;
+
+	dm_list_iterate_items(lvl, &vg->lvs)
+		if (!_lv_postorder_visit(lvl->lv, fn, data)) {
+			stack;
+			r = 0;
+		}
+
+	dm_list_iterate_items(lvl, &vg->lvs)
+		_lv_postorder_cleanup(lvl->lv, 0);
+
+	return r;
+}
+
 struct _lv_mark_if_partial_baton {
 	int partial;
 };
@@ -2076,11 +2099,6 @@
 	return 1;
 }
 
-static int _lv_mark_if_partial(struct logical_volume *lv)
-{
-	return _lv_postorder(lv, _lv_mark_if_partial_single, NULL);
-}
-
 /*
  * Mark LVs with missing PVs using PARTIAL_LV status flag. The flag is
  * propagated transitively, so LVs referencing other LVs are marked
@@ -2088,14 +2106,9 @@
  */
 int vg_mark_partial_lvs(struct volume_group *vg)
 {
-	struct logical_volume *lv;
-	struct lv_list *lvl;
+	if (!_lv_postorder_vg(vg, _lv_mark_if_partial_single, NULL))
+		return_0;
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		lv = lvl->lv;
-		if (!_lv_mark_if_partial(lv))
-			return_0;
-	}
 	return 1;
 }
 
@@ -2378,9 +2391,9 @@
 	dm_hash_destroy(lvname_hash);
 	dm_hash_destroy(lvid_hash);
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
-		if (!_lv_postorder(lvl->lv, _lv_validate_references_single, NULL))
-			r = 0;
+	if (!_lv_postorder_vg(vg, _lv_validate_references_single, NULL)) {
+		stack;
+		r = 0;
 	}
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
--- LVM2/WHATS_NEW	2011/03/10 13:11:59	1.1942
+++ LVM2/WHATS_NEW	2011/03/10 14:40:33	1.1943
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Add _lv_postorder_vg() to improve efficiency for all LVs in VG.
   Use hash tables to speedup string search in validate_vg().
   Refactor allocation of VG structure, add alloc_vg().
   Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name.


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

* LVM2 lib/metadata/metadata.c ./WHATS_NEW
@ 2011-03-14 17:01 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2011-03-14 17:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-14 17:00:58

Modified files:
	lib/metadata   : metadata.c 
	.              : WHATS_NEW 

Log message:
	Add missing \0 for grown debug object
	
	Attach \0 for proper char* display - otherwise somewhat random message could
	be displayed in debug more and read of unpredictable read of uninitilized
	memory values could happen.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.449&r2=1.450
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1955&r2=1.1956

--- LVM2/lib/metadata/metadata.c	2011/03/13 23:05:49	1.449
+++ LVM2/lib/metadata/metadata.c	2011/03/14 17:00:57	1.450
@@ -1066,6 +1066,12 @@
 		}
 	}
 
+	if (!dm_pool_grow_object(mem, "\0", 1)) {
+		log_error("Failed to finish list of random bits.");
+		dm_pool_free(mem, bs);
+		return NULL;
+	}
+
 	log_debug("Selected %" PRIu32 " random bits from %" PRIu32 ": %s", num_set_bits, num_bits, (char *) dm_pool_end_object(mem));
 
 	return bs;
--- LVM2/WHATS_NEW	2011/03/13 23:18:30	1.1955
+++ LVM2/WHATS_NEW	2011/03/14 17:00:58	1.1956
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Add missing \0 for grown debug object in _bitset_with_random_bits().
   Fix allocation of system_id buffer in volume_group structure.
   Fix readlink usage inside get_primary_dev().
   Use format instance mempool where possible and adequate.


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

* LVM2 lib/metadata/metadata.c ./WHATS_NEW
@ 2009-05-30  1:54 agk
  0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2009-05-30  1:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-05-30 01:54:29

Modified files:
	lib/metadata   : metadata.c 
	.              : WHATS_NEW 

Log message:
	Remove verbose 'visited' messages.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.222&r2=1.223
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1134&r2=1.1135

--- LVM2/lib/metadata/metadata.c	2009/05/27 13:19:34	1.222
+++ LVM2/lib/metadata/metadata.c	2009/05/30 01:54:29	1.223
@@ -1330,10 +1330,9 @@
 	baton.fn = fn;
 	baton.data = data;
 	r = _lv_each_dependency(lv, _lv_postorder_level, &baton);
-	if (r) {
+	if (r)
 		r = fn(lv, data);
-		log_verbose("visited %s", lv->name);
-	}
+
 	return r;
 }
 
--- LVM2/WHATS_NEW	2009/05/30 00:09:27	1.1134
+++ LVM2/WHATS_NEW	2009/05/30 01:54:29	1.1135
@@ -1,5 +1,6 @@
 Version 2.02.48 - 
 ===============================
+  Remove verbose 'visited' messages.
   Handle multi-extent mirror log allocation when smallest PV has only 1 extent.
   Add LSB standard headers and functions (incl. reload) to clvmd initscript.
   When creating new LV, double-check that name is not already in use.


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

* LVM2 lib/metadata/metadata.c ./WHATS_NEW
@ 2008-06-08 14:18 agk
  0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2008-06-08 14:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-06-08 14:18:45

Modified files:
	lib/metadata   : metadata.c 
	.              : WHATS_NEW 

Log message:
	Tweak detection of invalid fid after changes to PVs in VG in _vg_read.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.891&r2=1.892

--- LVM2/lib/metadata/metadata.c	2008/06/06 19:28:34	1.180
+++ LVM2/lib/metadata/metadata.c	2008/06/08 14:18:44	1.181
@@ -1531,16 +1531,16 @@
 	if (use_precommitted && !(fmt->features & FMT_PRECOMMIT))
 		use_precommitted = 0;
 
-	/* Store pvids for later so we can check if any are missing */
-	if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
-		return_NULL;
-
 	/* create format instance with appropriate metadata area */
 	if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
 		log_error("Failed to create format instance");
 		return NULL;
 	}
 
+	/* Store pvids for later so we can check if any are missing */
+	if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
+		return_NULL;
+
 	/* Ensure contents of all metadata areas match - else do recovery */
 	list_iterate_items(mda, &fid->metadata_areas) {
 		if ((use_precommitted &&
--- LVM2/WHATS_NEW	2008/06/08 11:33:15	1.891
+++ LVM2/WHATS_NEW	2008/06/08 14:18:44	1.892
@@ -1,5 +1,6 @@
 Version 2.02.38 - 
 =================================
+  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.
   In script-processing mode, stop if any command fails.


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-06-06 09:48:04

Modified files:
	lib/metadata   : metadata.c 
	.              : WHATS_NEW 

Log message:
	Allow for vginfo changing during _vg_read.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.176&r2=1.177
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.884&r2=1.885

--- LVM2/lib/metadata/metadata.c	2008/06/03 17:56:54	1.176
+++ LVM2/lib/metadata/metadata.c	2008/06/06 09:48:04	1.177
@@ -1757,7 +1757,7 @@
 		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
-					  "inconsistent", vginfo->vgname);
+					  "inconsistent", vg->name);
 				if (!partial_mode())
 					return NULL;
 			}
--- LVM2/WHATS_NEW	2008/06/05 14:24:27	1.884
+++ LVM2/WHATS_NEW	2008/06/06 09:48:04	1.885
@@ -9,6 +9,7 @@
 
 Version 2.02.37 - 
 =================================
+  Allow for vginfo changing during _vg_read.
   Decode numbers in clvmd debugging output.
   Add missing deactivation after activation failure in lvcreate -Zy.
   When activating, if precommitted metadata is still cached, assume it's live.


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

* LVM2 lib/metadata/metadata.c ./WHATS_NEW
@ 2007-06-11 18:29 wysochanski
  0 siblings, 0 replies; 6+ messages in thread
From: wysochanski @ 2007-06-11 18:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-06-11 18:29:30

Modified files:
	lib/metadata   : metadata.c 
	.              : WHATS_NEW 

Log message:
	Add wrappers to functions related to pv commands in preparation for exported LVM lib

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.625&r2=1.626

--- LVM2/lib/metadata/metadata.c	2007/06/06 19:40:27	1.109
+++ LVM2/lib/metadata/metadata.c	2007/06/11 18:29:30	1.110
@@ -28,6 +28,33 @@
 
 #include <sys/param.h>
 
+static struct physical_volume *_pv_read(struct cmd_context *cmd, 
+					const char *pv_name,
+					struct list *mdas, 
+					uint64_t *label_sector,
+					int warnings);
+
+static struct physical_volume *_pv_create(const struct format_type *fmt,
+				  struct device *dev,
+				  struct id *id, uint64_t size,
+				  uint64_t pe_start,
+				  uint32_t existing_extent_count,
+				  uint32_t existing_extent_size,
+				  int pvmetadatacopies,
+				  uint64_t pvmetadatasize, struct list *mdas);
+
+static int _pv_write(struct cmd_context *cmd __attribute((unused)), 
+		     struct physical_volume *pv,
+	     	     struct list *mdas, int64_t label_sector);
+
+static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
+			 			const char *pv_name);
+
+static struct pv_list *_find_pv_in_vg(struct volume_group *vg, const char *pv_name);
+
+static struct physical_volume *_find_pv_in_vg_by_uuid(struct volume_group *vg,
+						      struct id *id);
+
 unsigned long pe_align(void)
 {
 	return MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
@@ -50,7 +77,7 @@
 	}
 
 	list_init(&mdas);
-	if (!(pv = pv_read(fid->fmt->cmd, pv_name, &mdas, NULL, 1))) {
+	if (!(pv = _pv_read(fid->fmt->cmd, pv_name, &mdas, NULL, 1))) {
 		log_error("%s not identified as an existing physical volume",
 			  pv_name);
 		return 0;
@@ -103,7 +130,7 @@
 		return 0;
 	}
 
-	if (find_pv_in_vg(vg, pv_name)) {
+	if (_find_pv_in_vg(vg, pv_name)) {
 		log_error("Physical volume '%s' listed more than once.",
 			  pv_name);
 		return 0;
@@ -533,7 +560,7 @@
 	return 1;
 }
 
-/* Sizes in sectors */
+/* FIXME: liblvm todo - make into function that returns handle */
 struct physical_volume *pv_create(const struct format_type *fmt,
 				  struct device *dev,
 				  struct id *id, uint64_t size,
@@ -543,6 +570,23 @@
 				  int pvmetadatacopies,
 				  uint64_t pvmetadatasize, struct list *mdas)
 {
+	return _pv_create(fmt, dev, id, size, pe_start, 
+			  existing_extent_count,
+			  existing_extent_size,
+			  pvmetadatacopies,
+			  pvmetadatasize, mdas);
+}
+
+/* Sizes in sectors */
+static struct physical_volume *_pv_create(const struct format_type *fmt,
+				  struct device *dev,
+				  struct id *id, uint64_t size,
+				  uint64_t pe_start,
+				  uint32_t existing_extent_count,
+				  uint32_t existing_extent_size,
+				  int pvmetadatacopies,
+				  uint64_t pvmetadatasize, struct list *mdas)
+{
 	struct dm_pool *mem = fmt->cmd->mem;
 	struct physical_volume *pv = dm_pool_zalloc(mem, sizeof(*pv));
 
@@ -610,8 +654,14 @@
 	return NULL;
 }
 
+/* FIXME: liblvm todo - make into function that returns handle */
 struct pv_list *find_pv_in_vg(struct volume_group *vg, const char *pv_name)
 {
+	return _find_pv_in_vg(vg, pv_name);
+}
+
+static struct pv_list *_find_pv_in_vg(struct volume_group *vg, const char *pv_name)
+{
 	struct pv_list *pvl;
 
 	list_iterate_items(pvl, &vg->pvs)
@@ -632,9 +682,17 @@
 	return 0;
 }
 
+/* FIXME: liblvm todo - make into function that returns handle */
 struct physical_volume *find_pv_in_vg_by_uuid(struct volume_group *vg,
 					      struct id *id)
 {
+	return _find_pv_in_vg_by_uuid(vg, id);
+}
+
+
+static struct physical_volume *_find_pv_in_vg_by_uuid(struct volume_group *vg,
+						      struct id *id)
+{
 	struct pv_list *pvl;
 
 	list_iterate_items(pvl, &vg->pvs)
@@ -691,12 +749,20 @@
 	return NULL;
 }
 
+/* FIXME: liblvm todo - make into function that returns handle */
 struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
 					const char *pv_name)
 {
+	return _find_pv_by_name(cmd, pv_name);
+}
+
+
+static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
+			 			const char *pv_name)
+{
 	struct physical_volume *pv;
 
-	if (!(pv = pv_read(cmd, pv_name, NULL, NULL, 1))) {
+	if (!(pv = _pv_read(cmd, pv_name, NULL, NULL, 1))) {
 		log_error("Physical volume %s not found", pv_name);
 		return NULL;
 	}
@@ -980,7 +1046,7 @@
 	}
 
 	list_iterate_items(info, &vginfo->infos) {
-		if (!(pv = pv_read(cmd, dev_name(info->dev), NULL, NULL, 1))) {
+		if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1))) {
 			continue;
 		}
 		if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) {
@@ -1386,11 +1452,21 @@
 	return lvl->lv;
 }
 
-/* FIXME Use label functions instead of PV functions */
+/* FIXME: liblvm todo - make into function that returns handle */
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct list *mdas, uint64_t *label_sector,
 				int warnings)
 {
+	return _pv_read(cmd, pv_name, mdas, label_sector, warnings);
+}
+
+/* FIXME Use label functions instead of PV functions */
+static struct physical_volume *_pv_read(struct cmd_context *cmd, 
+					const char *pv_name,
+					struct list *mdas, 
+					uint64_t *label_sector,
+					int warnings)
+{
 	struct physical_volume *pv;
 	struct label *label;
 	struct lvmcache_info *info;
@@ -1510,9 +1586,18 @@
 	return results;
 }
 
-int pv_write(struct cmd_context *cmd __attribute((unused)), struct physical_volume *pv,
+/* FIXME: liblvm todo - make into function that takes handle */
+int pv_write(struct cmd_context *cmd __attribute((unused)),
+	     struct physical_volume *pv,
 	     struct list *mdas, int64_t label_sector)
 {
+	return _pv_write(cmd, pv, mdas, label_sector);
+}
+
+static int _pv_write(struct cmd_context *cmd __attribute((unused)), 
+		     struct physical_volume *pv,
+	     	     struct list *mdas, int64_t label_sector)
+{
 	if (!pv->fmt->ops->pv_write) {
 		log_error("Format does not support writing physical volumes");
 		return 0;
@@ -1544,7 +1629,7 @@
 		return 0;
 	}
 
-	if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
+	if (!_pv_write(cmd, pv, NULL, INT64_C(-1))) {
 		log_error("Failed to clear metadata from physical "
 			  "volume \"%s\" after removal from \"%s\"",
 			  dev_name(pv->dev), old_vg_name);
--- LVM2/WHATS_NEW	2007/06/08 22:38:48	1.625
+++ LVM2/WHATS_NEW	2007/06/11 18:29:30	1.626
@@ -1,5 +1,6 @@
 Version 2.02.26 -
 =================================
+  Add wrappers to some functions in preparation for external LVM library.
   Allow vgcfgrestore to list metadata backup files using -f
   Add vg_check_status to consolidate vg status checks and error messages.
   Add pvdisplay --maps implementation.


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

end of thread, other threads:[~2011-03-14 17:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-10 14:40 LVM2 lib/metadata/metadata.c ./WHATS_NEW zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2011-03-14 17:01 zkabelac
2009-05-30  1:54 agk
2008-06-08 14:18 agk
2008-06-06  9:48 agk
2007-06-11 18:29 wysochanski

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