public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/metadata/metadata.c tools/toollib.c
@ 2009-10-06 16:00 wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2009-10-06 16:00 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-06 16:00:38

Modified files:
	lib/metadata   : metadata.c 
	tools          : toollib.c 

Log message:
	Cleanup comment and some whitespace.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.289&r2=1.290
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.174&r2=1.175

--- LVM2/lib/metadata/metadata.c	2009/10/05 20:03:25	1.289
+++ LVM2/lib/metadata/metadata.c	2009/10/06 16:00:38	1.290
@@ -67,7 +67,7 @@
 
 	if (data_alignment)
 		pv->pe_align = data_alignment;
-	else 
+	else
 		pv->pe_align = MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
 
 	if (!pv->dev)
@@ -1292,18 +1292,19 @@
 }
 
 /*
- * pvcreate_single() - initialize a device with PV label and metadata
+ * pvcreate_single() - initialize a device with PV label and metadata area
  *
  * Parameters:
  * - pv_name: device path to initialize
- * - handle: options to pass to pv_create; NULL indicates use defaults
+ * - pp: parameters to pass to pv_create; if NULL, use default values
  *
  * Returns:
  * NULL: error
  * struct physical_volume * (non-NULL): handle to physical volume created
  */
-struct physical_volume * pvcreate_single(struct cmd_context *cmd, const char *pv_name,
-		       struct pvcreate_params *pp)
+struct physical_volume * pvcreate_single(struct cmd_context *cmd,
+					 const char *pv_name,
+					 struct pvcreate_params *pp)
 {
 	void *pv;
 	struct device *dev;
--- LVM2/tools/toollib.c	2009/10/05 20:55:57	1.174
+++ LVM2/tools/toollib.c	2009/10/06 16:00:38	1.175
@@ -1021,7 +1021,7 @@
 			new_pvl = pvl2;
 			break;
 		}
-	
+
 	if (!new_pvl) {
 		if (!(new_pvl = dm_pool_alloc(mem, sizeof(*new_pvl)))) {
 			log_error("Unable to allocate physical volume list.");
@@ -1239,12 +1239,12 @@
 {
 	struct lv_list *lvl;
 	int r = 1;
-	
+
 	dm_list_iterate_items(lvl, &vg->lvs)
 		if (lv_is_visible(lvl->lv))
 			if (!lv_refresh(cmd, lvl->lv))
 				r = 0;
-	
+
 	return r;
 }
 


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

* LVM2 lib/metadata/metadata.c tools/toollib.c
@ 2010-03-18 17:29 wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2010-03-18 17:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-03-18 17:29:13

Modified files:
	lib/metadata   : metadata.c 
	tools          : toollib.c 

Log message:
	Avoid scanning all pvs in the system if operating on a device with mdas.
	
	When we pv_read() a device that has an orphan vgname, we might need to scan
	the system to be sure this is true.  However, if the PV has mdas, there's
	no way possible for it to have an orphan vgname unless it is a true orphan.
	Some areas of the code were optimized to take advantage of this fact, while
	others were not (we would still do the expensive scan if a device had mdas
	but had an orphan VG).
	
	This patch unifies the code so that every place we are operating on such
	a PV, we skip the expensive scan if there are mdas.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
	Acked-by: Petr Rockai <prockai@redhat.com>
	Acked-by: Alasdair G Kergon <agk@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.323&r2=1.324
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.187&r2=1.188

--- LVM2/lib/metadata/metadata.c	2010/03/17 14:44:18	1.323
+++ LVM2/lib/metadata/metadata.c	2010/03/18 17:29:12	1.324
@@ -1251,11 +1251,14 @@
 	struct device *dev;
 	uint64_t md_superblock, swap_signature;
 	int wipe_md, wipe_swap;
+	struct dm_list mdas;
+
+	dm_list_init(&mdas);
 
 	/* FIXME Check partition type is LVM unless --force is given */
 
 	/* Is there a pv here already? */
-	pv = pv_read(cmd, name, NULL, NULL, 0, 0);
+	pv = pv_read(cmd, name, &mdas, NULL, 0, 0);
 
 	/*
 	 * If a PV has no MDAs it may appear to be an orphan until the
@@ -1263,7 +1266,7 @@
 	 * this means checking every VG by scanning every PV on the
 	 * system.
 	 */
-	if (pv && is_orphan(pv)) {
+	if (pv && is_orphan(pv) && !dm_list_size(&mdas)) {
 		if (!scan_vgs_for_pvs(cmd))
 			return_0;
 		pv = pv_read(cmd, name, NULL, NULL, 0, 0);
@@ -1747,14 +1750,16 @@
 static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
 			 			const char *pv_name)
 {
+	struct dm_list mdas;
 	struct physical_volume *pv;
 
-	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
+	dm_list_init(&mdas);
+	if (!(pv = _pv_read(cmd, cmd->mem, pv_name, &mdas, NULL, 1, 0))) {
 		log_error("Physical volume %s not found", pv_name);
 		return NULL;
 	}
 
-	if (is_orphan_vg(pv->vg_name)) {
+	if (is_orphan_vg(pv->vg_name) && !dm_list_size(&mdas)) {
 		/* If a PV has no MDAs - need to search all VGs for it */
 		if (!scan_vgs_for_pvs(cmd))
 			return_NULL;
--- LVM2/tools/toollib.c	2010/03/16 16:57:05	1.187
+++ LVM2/tools/toollib.c	2010/03/18 17:29:12	1.188
@@ -642,6 +642,7 @@
 	struct str_list *sll;
 	char *tagname;
 	int scanned = 0;
+	struct dm_list mdas;
 
 	dm_list_init(&tags);
 
@@ -682,7 +683,9 @@
 				}
 				pv = pvl->pv;
 			} else {
-				if (!(pv = pv_read(cmd, argv[opt], NULL,
+
+				dm_list_init(&mdas);
+				if (!(pv = pv_read(cmd, argv[opt], &mdas,
 						   NULL, 1, scan_label_only))) {
 					log_error("Failed to read physical "
 						  "volume \"%s\"", argv[opt]);
@@ -697,7 +700,8 @@
 				 * means checking every VG by scanning every
 				 * PV on the system.
 				 */
-				if (!scanned && is_orphan(pv)) {
+				if (!scanned && is_orphan(pv) &&
+				    !dm_list_size(&mdas)) {
 					if (!scan_label_only &&
 					    !scan_vgs_for_pvs(cmd)) {
 						stack;


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

end of thread, other threads:[~2010-03-18 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-06 16:00 LVM2 lib/metadata/metadata.c tools/toollib.c wysochanski
2010-03-18 17: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).