public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW tools/vgcreate.c
@ 2009-12-03 19:20 mbroz
  0 siblings, 0 replies; 2+ messages in thread
From: mbroz @ 2009-12-03 19:20 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-03 19:20:49

Modified files:
	.              : WHATS_NEW 
	tools          : vgcreate.c 

Log message:
	Print error if VG already exist.
	
	This test have to be moved because of new vg read error handling.

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

--- LVM2/WHATS_NEW	2009/12/03 19:18:33	1.1338
+++ LVM2/WHATS_NEW	2009/12/03 19:20:48	1.1339
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Fix error message if VG already exist in vgcreate.
   Fix tools to use log_error when stopped by user.
   Fix lvcreate --readahead.
   Fix clvmd memory leak in lv_info_by_lvid.
--- LVM2/tools/vgcreate.c	2009/11/01 20:05:17	1.75
+++ LVM2/tools/vgcreate.c	2009/12/03 19:20:49	1.76
@@ -55,8 +55,13 @@
 
 	/* Create the new VG */
 	vg = vg_create(cmd, vp_new.vg_name);
-	if (vg_read_error(vg))
-		goto_bad;
+	if (vg_read_error(vg)) {
+		if (vg_read_error(vg) == FAILED_EXIST)
+			log_error("A volume group called %s already exists.", vp_new.vg_name);
+		else
+			log_error("Can't get lock for %s.", vp_new.vg_name);
+		goto bad;
+	}
 
 	if (!vg_set_extent_size(vg, vp_new.extent_size) ||
 	    !vg_set_max_lv(vg, vp_new.max_lv) ||


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

* LVM2 ./WHATS_NEW tools/vgcreate.c
@ 2008-12-01 20:14 wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2008-12-01 20:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-12-01 20:14:33

Modified files:
	.              : WHATS_NEW 
	tools          : vgcreate.c 

Log message:
	Fix vgcreate race which could allow two parallel vgcreates to succeed,
	with the second vgcreate overwriting the first.
	
	Obtain lock before calling vg_create(), which checks for existence of vgname
	and fails if it already exists.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1002&r2=1.1003
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58

--- LVM2/WHATS_NEW	2008/12/01 17:38:35	1.1002
+++ LVM2/WHATS_NEW	2008/12/01 20:14:33	1.1003
@@ -1,5 +1,6 @@
 Version 2.02.44 - 
 ====================================
+  Fix race in vgcreate that would result in second caller overwriting first.
   Fix uninitialised lv_count in vgdisplay -c.
   Don't skip updating pvid hash when lvmcache_info struct got swapped.
   Add tinfo to termcap search path for pld-linux.
--- LVM2/tools/vgcreate.c	2008/04/08 14:22:13	1.57
+++ LVM2/tools/vgcreate.c	2008/12/01 20:14:33	1.58
@@ -46,11 +46,22 @@
 	if (validate_vg_create_params(cmd, &vp_new))
 	    return EINVALID_CMD_LINE;
 
+	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+		log_error("Can't get lock for orphan PVs");
+		return ECMD_FAILED;
+	}
+
+	if (!lock_vol(cmd, vp_new.vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) {
+		log_error("Can't get lock for %s", vp_new.vg_name);
+		unlock_vg(cmd, VG_ORPHANS);
+		return ECMD_FAILED;
+	}
+
 	/* Create the new VG */
 	if (!(vg = vg_create(cmd, vp_new.vg_name, vp_new.extent_size,
 			     vp_new.max_pv, vp_new.max_lv, vp_new.alloc,
 			     argc - 1, argv + 1)))
-		return ECMD_FAILED;
+		goto bad;
 
 	if (vp_new.max_lv != vg->max_lv)
 		log_warn("WARNING: Setting maxlogicalvolumes to %d "
@@ -63,18 +74,18 @@
 	if (arg_count(cmd, addtag_ARG)) {
 		if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {
 			log_error("Failed to get tag");
-			return ECMD_FAILED;
+			goto bad;
 		}
 
 		if (!(vg->fid->fmt->features & FMT_TAGS)) {
 			log_error("Volume group format does not support tags");
-			return ECMD_FAILED;
+			goto bad;
 		}
 
 		if (!str_list_add(cmd->mem, &vg->tags, tag)) {
 			log_error("Failed to add tag %s to volume group %s",
 				  tag, vp_new.vg_name);
-			return ECMD_FAILED;
+			goto bad;
 		}
 	}
 
@@ -88,28 +99,13 @@
 			clustered_message = "Non-clustered ";
 	}
 
-	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
-		log_error("Can't get lock for orphan PVs");
-		return ECMD_FAILED;
-	}
-
-	if (!lock_vol(cmd, vp_new.vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) {
-		log_error("Can't get lock for %s", vp_new.vg_name);
-		unlock_vg(cmd, VG_ORPHANS);
-		return ECMD_FAILED;
-	}
-
 	if (!archive(vg)) {
-		unlock_vg(cmd, vp_new.vg_name);
-		unlock_vg(cmd, VG_ORPHANS);
-		return ECMD_FAILED;
+		goto bad;
 	}
 
 	/* Store VG on disk(s) */
 	if (!vg_write(vg) || !vg_commit(vg)) {
-		unlock_vg(cmd, vp_new.vg_name);
-		unlock_vg(cmd, VG_ORPHANS);
-		return ECMD_FAILED;
+		goto bad;
 	}
 
 	unlock_vg(cmd, vp_new.vg_name);
@@ -121,4 +117,9 @@
 		  clustered_message, *clustered_message ? 'v' : 'V', vg->name);
 
 	return ECMD_PROCESSED;
+
+bad:
+	unlock_vg(cmd, vp_new.vg_name);
+	unlock_vg(cmd, VG_ORPHANS);
+	return ECMD_FAILED;
 }


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

end of thread, other threads:[~2009-12-03 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-03 19:20 LVM2 ./WHATS_NEW tools/vgcreate.c mbroz
  -- strict thread matches above, loose matches on Subject: below --
2008-12-01 20:14 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).