public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools toollib.c
@ 2010-12-01 10:36 zkabelac
  0 siblings, 0 replies; 20+ messages in thread
From: zkabelac @ 2010-12-01 10:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	tools          : toollib.c 

Log message:
	Optimize second call to strchr with same parameters
	
	Small optimalization - reusing already known strchr result.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.214&r2=1.215

--- LVM2/tools/toollib.c	2010/11/23 20:39:14	1.214
+++ LVM2/tools/toollib.c	2010/12/01 10:36:25	1.215
@@ -214,6 +214,7 @@
 
 		for (; opt < argc; opt++) {
 			const char *lv_name = argv[opt];
+			const char *tmp_lv_name;
 			char *vgname_def;
 			unsigned dev_dir_found = 0;
 
@@ -246,9 +247,9 @@
 				continue;
 			}
 			lv_name = vgname;
-			if (strchr(vgname, '/')) {
+			if ((tmp_lv_name = strchr(vgname, '/'))) {
 				/* Must be an LV */
-				lv_name = strchr(vgname, '/');
+				lv_name = tmp_lv_name;
 				while (*lv_name == '/')
 					lv_name++;
 				if (!(vgname = extract_vgname(cmd, vgname))) {


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2012-03-04 15:58 zkabelac
  0 siblings, 0 replies; 20+ messages in thread
From: zkabelac @ 2012-03-04 15:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-04 15:58:32

Modified files:
	tools          : toollib.c 

Log message:
	Add FIXMEs
	
	Processing loop needs some thinking

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.245&r2=1.246

--- LVM2/tools/toollib.c	2012/03/01 21:14:43	1.245
+++ LVM2/tools/toollib.c	2012/03/04 15:58:31	1.246
@@ -119,6 +119,10 @@
 		process_all = 1;
 	}
 
+	/*
+	 * FIXME: In case of remove it goes through deleted entries,
+	 * but it works since entries are allocated from vg mem pool.
+	 */
 	dm_list_iterate_items(lvl, &vg->lvs) {
 		if (lvl->lv->status & SNAPSHOT)
 			continue;
@@ -182,6 +186,10 @@
 	}
 
 	if (lvargs_supplied && lvargs_matched != dm_list_size(arg_lvnames)) {
+		/*
+		 * FIXME: lvm supports removal of LV with all its dependencies
+		 * this leads to miscalculation that depends on the order of args.
+		 */
 		log_error("One or more specified logical volume(s) not found.");
 		if (ret_max < ECMD_FAILED)
 			ret_max = ECMD_FAILED;


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2010-12-20 14:05 zkabelac
  0 siblings, 0 replies; 20+ messages in thread
From: zkabelac @ 2010-12-20 14:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-20 14:05:32

Modified files:
	tools          : toollib.c 

Log message:
	Remove unused variable dev_dir_provided

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.217&r2=1.218

--- LVM2/tools/toollib.c	2010/12/08 20:50:51	1.217
+++ LVM2/tools/toollib.c	2010/12/20 14:05:31	1.218
@@ -842,7 +842,6 @@
 	const char *vg_name = lv_name;
 	char *st;
 	char *dev_dir = cmd->dev_dir;
-	int dev_dir_provided = 0;
 
 	/* Path supplied? */
 	if (vg_name && strchr(vg_name, '/')) {
@@ -854,7 +853,6 @@
 		}
 		if (!strncmp(vg_name, dev_dir, strlen(dev_dir))) {
 			vg_name += strlen(dev_dir);
-			dev_dir_provided = 1;
 			while (*vg_name == '/')
 				vg_name++;
 		}


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2010-12-01 12:22 zkabelac
  0 siblings, 0 replies; 20+ messages in thread
From: zkabelac @ 2010-12-01 12:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-01 12:22:49

Modified files:
	tools          : toollib.c 

Log message:
	Test lv_name is not NULL
	
	Patch adds extra check for lv_name not being NULL.
	Test avoids unneeded strlen call for this case.
	Otherwise there is no functional change as test would fail on
	size_t comparation even for NULL lv_name (thus there is no risk
	of NULL dereference when taking 'true' if branch.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.215&r2=1.216

--- LVM2/tools/toollib.c	2010/12/01 10:36:25	1.215
+++ LVM2/tools/toollib.c	2010/12/01 12:22:49	1.216
@@ -331,7 +331,7 @@
 				tags_arg = NULL;
 				dm_list_init(&lvnames);
 				break;
-			} else if (!strncmp(vg_name, vgname, strlen(vgname)) &&
+			} else if (!strncmp(vg_name, vgname, strlen(vgname)) && lv_name &&
 				   strlen(vgname) == (size_t) (lv_name - vg_name)) {
 				if (!str_list_add(cmd->mem, &lvnames,
 						  dm_pool_strdup(cmd->mem,


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2010-10-25 12:08 zkabelac
  0 siblings, 0 replies; 20+ messages in thread
From: zkabelac @ 2010-10-25 12:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-25 12:08:16

Modified files:
	tools          : toollib.c 

Log message:
	Reuse result of previous strchr
	
	Reported by clang as: Argument with 'nonnull' attribute passed null
	
	Reuse the result of the last strchr() call - make sure, 'st' point is not
	null for the next strchr() call.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.209&r2=1.210

--- LVM2/tools/toollib.c	2010/09/23 12:02:34	1.209
+++ LVM2/tools/toollib.c	2010/10/25 12:08:15	1.210
@@ -869,7 +869,7 @@
 			while (*st == '/')
 				st++;
 
-		if (!strchr(vg_name, '/') || strchr(st, '/')) {
+		if (!st || strchr(st, '/')) {
 			log_error("\"%s\": Invalid path for Logical Volume",
 				  lv_name);
 			return 0;


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2010-04-28 12:23 zkabelac
  0 siblings, 0 replies; 20+ messages in thread
From: zkabelac @ 2010-04-28 12:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-04-28 12:23:12

Modified files:
	tools          : toollib.c 

Log message:
	Small indent change

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.195&r2=1.196

--- LVM2/tools/toollib.c	2010/04/23 14:16:33	1.195
+++ LVM2/tools/toollib.c	2010/04/28 12:23:11	1.196
@@ -316,7 +316,7 @@
 				   strlen(vgname) == (size_t) (lv_name - vg_name)) {
 				if (!str_list_add(cmd->mem, &lvnames,
 						  dm_pool_strdup(cmd->mem,
-							      lv_name + 1))) {
+								 lv_name + 1))) {
 					log_error("strlist allocation failed");
 					unlock_and_release_vg(cmd, vg, vgname);
 					return ECMD_FAILED;


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-07-15 12:23 wysochanski
  0 siblings, 0 replies; 20+ messages in thread
From: wysochanski @ 2009-07-15 12:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-15 12:22:59

Modified files:
	tools          : toollib.c 

Log message:
	Fix memory leak in process_each_pv path.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164

--- LVM2/tools/toollib.c	2009/07/15 12:15:36	1.163
+++ LVM2/tools/toollib.c	2009/07/15 12:22:59	1.164
@@ -723,6 +723,7 @@
 				vg = vg_read(cmd, sll->str, NULL, flags);
 				if (vg_read_error(vg)) {
 					ret_max = ECMD_FAILED;
+					vg_release(vg);
 					continue;
 				}
 


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-07-15 12:15 wysochanski
  0 siblings, 0 replies; 20+ messages in thread
From: wysochanski @ 2009-07-15 12:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-15 12:15:36

Modified files:
	tools          : toollib.c 

Log message:
	Fix memory leak in _process_one_vg error path.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.162&r2=1.163

--- LVM2/tools/toollib.c	2009/07/15 05:50:22	1.162
+++ LVM2/tools/toollib.c	2009/07/15 12:15:36	1.163
@@ -432,8 +432,10 @@
 
 	vg = vg_read(cmd, vg_name, vgid, flags);
 	if (vg_read_error(vg) == FAILED_ALLOCATION ||
-	    vg_read_error(vg) == FAILED_NOTFOUND)
+	    vg_read_error(vg) == FAILED_NOTFOUND) {
+		vg_release(vg);
 		return ECMD_FAILED;
+	}
 
 	if (!dm_list_empty(tags)) {
 		/* Only process if a tag matches or it's on arg_vgnames */


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-07-15  5:23 wysochanski
  0 siblings, 0 replies; 20+ messages in thread
From: wysochanski @ 2009-07-15  5:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-15 05:23:20

Modified files:
	tools          : toollib.c 

Log message:
	Check for certain vg_read errors in _process_one_vg iterator.
	
	In _process_one_vg, we should never proceed if the VG read fails with certain
	conditions.  If we cannot allocate or construct the volume_group structure,
	we should not proceed - this is true regardless of the tool calling the
	iterator.  In other cases, when the volume group structure is constructed but
	there is some error (PVs missing, metadata corrupted, etc), some tools may
	want to process the VG while others may not.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.160&r2=1.161

--- LVM2/tools/toollib.c	2009/07/07 01:18:35	1.160
+++ LVM2/tools/toollib.c	2009/07/15 05:23:19	1.161
@@ -431,6 +431,9 @@
 	log_verbose("Finding volume group \"%s\"", vg_name);
 
 	vg = vg_read(cmd, vg_name, vgid, flags);
+	if (vg_read_error(vg) == FAILED_ALLOCATION ||
+	    vg_read_error(vg) == FAILED_NOTFOUND)
+		return ECMD_FAILED;
 
 	if (!dm_list_empty(tags)) {
 		/* Only process if a tag matches or it's on arg_vgnames */


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-06-10 11:15 mbroz
  0 siblings, 0 replies; 20+ messages in thread
From: mbroz @ 2009-06-10 11:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-10 11:15:29

Modified files:
	tools          : toollib.c 

Log message:
	Unlock VG in recover_vg if metadata read failed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.157&r2=1.158

--- LVM2/tools/toollib.c	2009/06/10 10:15:28	1.157
+++ LVM2/tools/toollib.c	2009/06/10 11:15:29	1.158
@@ -497,10 +497,8 @@
 			unlock_and_release_vg(cmd, vg, vg_name);
 			dev_close_all();
 			log_error("Volume group %s inconsistent", vg_name);
-			if (!(vg = recover_vg(cmd, vg_name, LCK_VG_WRITE))) {
-				unlock_vg(cmd, vg_name);
+			if (!(vg = recover_vg(cmd, vg_name, LCK_VG_WRITE)))
 				return ECMD_FAILED;
-			}
 			consistent = 1;
 			break;
 		}
@@ -1209,6 +1207,7 @@
 				uint32_t lock_type)
 {
 	int consistent = 1;
+	struct volume_group *vg;
 
 	/* Don't attempt automatic recovery without proper locking */
 	if (lockingfailed())
@@ -1223,7 +1222,10 @@
 		return NULL;
 	}
 
-	return vg_read_internal(cmd, vgname, NULL, &consistent);
+	if (!(vg = vg_read_internal(cmd, vgname, NULL, &consistent)))
+		unlock_vg(cmd, vgname);
+
+	return vg;
 }
 
 int apply_lvname_restrictions(const char *name)


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-06-10 10:15 mbroz
  0 siblings, 0 replies; 20+ messages in thread
From: mbroz @ 2009-06-10 10:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-10 10:15:29

Modified files:
	tools          : toollib.c 

Log message:
	Unlock vg when requested automatic update failed.
	
	(fixes previous commit)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.156&r2=1.157

--- LVM2/tools/toollib.c	2009/06/05 20:00:52	1.156
+++ LVM2/tools/toollib.c	2009/06/10 10:15:28	1.157
@@ -497,8 +497,10 @@
 			unlock_and_release_vg(cmd, vg, vg_name);
 			dev_close_all();
 			log_error("Volume group %s inconsistent", vg_name);
-			if (!(vg = recover_vg(cmd, vg_name, LCK_VG_WRITE)))
+			if (!(vg = recover_vg(cmd, vg_name, LCK_VG_WRITE))) {
+				unlock_vg(cmd, vg_name);
 				return ECMD_FAILED;
+			}
 			consistent = 1;
 			break;
 		}


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-04-23 16:45 mornfall
  0 siblings, 0 replies; 20+ messages in thread
From: mornfall @ 2009-04-23 16:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-04-23 16:45:31

Modified files:
	tools          : toollib.c 

Log message:
	Refuse adding missing PVs in create_pv_list in toollib when allocatable_only is
	requested.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.150&r2=1.151

--- LVM2/tools/toollib.c	2009/04/21 12:59:19	1.150
+++ LVM2/tools/toollib.c	2009/04/23 16:45:30	1.151
@@ -1047,6 +1047,11 @@
 		return 1;
 	}
 
+	if (allocatable_only && (pvl->pv->status & MISSING_PV)) {
+		log_error("Physical volume %s is missing", pvname);
+		return 1;
+	}
+
 	if (allocatable_only &&
 	    (pvl->pv->pe_count == pvl->pv->pe_alloc_count)) {
 		log_err("No free extents on physical volume \"%s\"", pvname);


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2009-04-07 10:22 mbroz
  0 siblings, 0 replies; 20+ messages in thread
From: mbroz @ 2009-04-07 10:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-07 10:22:15

Modified files:
	tools          : toollib.c 

Log message:
	Use pv from newly read_vg to avoid possible use of not initialized memory.
	
	If the vg in process_each_segment_in_pv is NULL, the pv struct
	can be incomplete (for example lv_segs are not copied in get_pvs()
	call).
	
	We need use the new pv from just read-in volume group.
	
	(The same code is in pvdisplay already.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.144&r2=1.145

--- LVM2/tools/toollib.c	2009/02/25 23:29:07	1.144
+++ LVM2/tools/toollib.c	2009/04/07 10:22:14	1.145
@@ -364,6 +364,7 @@
 						      void *handle))
 {
 	struct pv_segment *pvseg;
+	struct pv_list *pvl;
 	const char *vg_name = NULL;
 	int ret_max = ECMD_PROCESSED;
 	int ret;
@@ -376,6 +377,18 @@
 			log_error("Skipping volume group %s", vg_name);
 			return ECMD_FAILED;
 		}
+
+		/*
+		 * Replace possibly incomplete PV structure with new one
+		 * allocated in vg_read_internal() path.
+		 */
+		if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
+			 log_error("Unable to find %s in volume group %s",
+				   pv_dev_name(pv), vg_name);
+			return ECMD_FAILED;
+		}
+
+		pv = pvl->pv;
 	}
 
 	dm_list_iterate_items(pvseg, &pv->segments) {


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2008-06-11 15:02 meyering
  0 siblings, 0 replies; 20+ messages in thread
From: meyering @ 2008-06-11 15:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	meyering@sourceware.org	2008-06-11 15:02:52

Modified files:
	tools          : toollib.c 

Log message:
	break (rather than return) so we have only one point of return
	
	* tools/toollib.c (process_each_segment_in_lv): Upon sigint_caught,
	break rather than returning ret_max.  No semantic change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136

--- LVM2/tools/toollib.c	2008/06/10 20:07:04	1.135
+++ LVM2/tools/toollib.c	2008/06/11 15:02:52	1.136
@@ -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.
  *
@@ -404,7 +404,7 @@
 		if (ret > ret_max)
 			ret_max = ret;
 		if (sigint_caught())
-			return ret_max;
+			break;
 	}
 
 	return ret_max;


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2007-11-12 14:36 agk
  0 siblings, 0 replies; 20+ messages in thread
From: agk @ 2007-11-12 14:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-11-12 14:36:57

Modified files:
	tools          : toollib.c 

Log message:
	Remove new mirror logs when creation fails.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111

--- LVM2/tools/toollib.c	2007/11/02 20:40:05	1.110
+++ LVM2/tools/toollib.c	2007/11/12 14:36:57	1.111
@@ -1339,56 +1339,46 @@
 	size_t len;
 	struct str_list *sl;
 
+	if (!activation() && in_sync) {
+		log_error("Aborting. Unable to create in-sync mirror log "
+			  "while activation is disabled.");
+		return NULL;
+	}
+
 	len = strlen(lv_name) + 32;
 	if (!(log_name = alloca(len)) ||
 	    !(generate_log_name_format(vg, lv_name, log_name, len))) {
-		log_error("log_name allocation failed. "
-			  "Remove new LV and retry.");
+		log_error("log_name allocation failed.");
 		return NULL;
 	}
 
 	if (!(log_lv = lv_create_empty(log_name, NULL,
 				       VISIBLE_LV | LVM_READ | LVM_WRITE,
-				       alloc, 0, vg))) {
-		stack;
-		return NULL;
-	}
+				       alloc, 0, vg)))
+		return_NULL;
 
-	if (!lv_add_log_segment(ah, log_lv)) {
-		stack;
-		goto error;
-	}
+	if (!lv_add_log_segment(ah, log_lv))
+		return_NULL;
 
 	/* Temporary tag mirror log */
 	list_iterate_items(sl, tags)
 		if (!str_list_add(cmd->mem, &log_lv->tags, sl->str)) {
 			log_error("Aborting. Unable to tag mirror log.");
-			goto error;
+			return NULL;
 		}
 
 	/* store mirror log on disk(s) */
-	if (!vg_write(vg)) {
-		stack;
-		goto error;
-	}
+	if (!vg_write(vg))
+		return_NULL;
 
 	backup(vg);
 
-	if (!vg_commit(vg)) {
-		stack;
-		goto error;
-	}
-
-	if (!activation() && in_sync) {
-		log_error("Aborting. Unable to create in-sync mirror log "
-			  "while activation is disabled.");
-		goto error;
-	}
+	if (!vg_commit(vg))
+		return_NULL;
 
 	if (!activate_lv(cmd, log_lv)) {
-		log_error("Aborting. Failed to activate mirror log. "
-			  "Remove new LVs and retry.");
-		goto error;
+		log_error("Aborting. Failed to activate mirror log.");
+		goto revert_new_lv;
 	}
 
 	list_iterate_items(sl, tags)
@@ -1398,27 +1388,35 @@
 
 	if (activation() && !set_lv(cmd, log_lv, log_lv->size,
 				    in_sync ? -1 : 0)) {
-		log_error("Aborting. Failed to wipe mirror log. "
-			  "Remove new LV and retry.");
-		goto error;
+		log_error("Aborting. Failed to wipe mirror log.");
+		goto deactivate_and_revert_new_lv;
 	}
 
 	if (activation() && !_write_log_header(cmd, log_lv)) {
-		log_error("Aborting. Failed to write mirror log header. "
-			  "Remove new LV and retry.");
-		goto error;
+		log_error("Aborting. Failed to write mirror log header.");
+		goto deactivate_and_revert_new_lv;
 	}
 
 	if (!deactivate_lv(cmd, log_lv)) {
 		log_error("Aborting. Failed to deactivate mirror log. "
-			  "Remove new LV and retry.");
-		goto error;
+			  "Manual intervention required.");
+		return NULL;
 	}
 
 	log_lv->status &= ~VISIBLE_LV;
 
 	return log_lv;
-error:
-	/* FIXME Attempt to clean up. */
+
+deactivate_and_revert_new_lv:
+	if (!deactivate_lv(cmd, log_lv)) {
+		log_error("Unable to deactivate mirror log LV. "
+			  "Manual intervention required.");
+		return NULL;
+	}
+
+revert_new_lv:
+	if (!lv_remove(log_lv) || !vg_write(vg) || backup(vg), !vg_commit(vg))
+		log_error("Manual intervention may be required to remove "
+			  "abandoned log LV before retrying.");
 	return NULL;
 }


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2006-11-03 21:23 agk
  0 siblings, 0 replies; 20+ messages in thread
From: agk @ 2006-11-03 21:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	tools          : toollib.c 

Log message:
	fix shift

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95

--- LVM2/tools/toollib.c	2006/11/03 21:07:15	1.94
+++ LVM2/tools/toollib.c	2006/11/03 21:23:06	1.95
@@ -1223,7 +1223,8 @@
 		return 0;
 
 	dev_set(dev, UINT64_C(0),
-		sectors ? (size_t) sectors >> SECTOR_SHIFT : (size_t) 4096, value);
+		sectors ? (size_t) sectors << SECTOR_SHIFT : (size_t) 4096,
+		value);
 	dev_flush(dev);
 	dev_close_immediate(dev);
 


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2006-03-10 15:41 agk
  0 siblings, 0 replies; 20+ messages in thread
From: agk @ 2006-03-10 15:41 UTC (permalink / raw)
  To: lvm2-cvs

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

Modified files:
	tools          : toollib.c 

Log message:
	Remove an incorrect unlock_vg() from process_each_lv().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2005-01-19 17:31 agk
  0 siblings, 0 replies; 20+ messages in thread
From: agk @ 2005-01-19 17:31 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-01-19 17:31:52

Modified files:
	tools          : toollib.c 

Log message:
	Add some comments.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2005-01-19 17:31 agk
  0 siblings, 0 replies; 20+ messages in thread
From: agk @ 2005-01-19 17:31 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-01-19 17:30:54

Modified files:
	tools          : toollib.c 

Log message:
	move recover_vg

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62


^ permalink raw reply	[flat|nested] 20+ messages in thread
* LVM2/tools toollib.c
@ 2004-06-20 15:14 agk
  0 siblings, 0 replies; 20+ messages in thread
From: agk @ 2004-06-20 15:14 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2004-06-20 15:14:31

Modified files:
	tools          : toollib.c 

Log message:
	Remove pv segments line from backport.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60


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

end of thread, other threads:[~2012-03-04 15:58 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 10:36 LVM2/tools toollib.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-03-04 15:58 zkabelac
2010-12-20 14:05 zkabelac
2010-12-01 12:22 zkabelac
2010-10-25 12:08 zkabelac
2010-04-28 12:23 zkabelac
2009-07-15 12:23 wysochanski
2009-07-15 12:15 wysochanski
2009-07-15  5:23 wysochanski
2009-06-10 11:15 mbroz
2009-06-10 10:15 mbroz
2009-04-23 16:45 mornfall
2009-04-07 10:22 mbroz
2008-06-11 15:02 meyering
2007-11-12 14:36 agk
2006-11-03 21:23 agk
2006-03-10 15:41 agk
2005-01-19 17:31 agk
2005-01-19 17:31 agk
2004-06-20 15:14 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).