public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2012-03-01  9:54 zkabelac
  0 siblings, 0 replies; 23+ messages in thread
From: zkabelac @ 2012-03-01  9:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-01 09:54:24

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Check for allocation error
	
	return ENOMEM when malloc fails.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2327&r2=1.2328
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131

--- LVM2/WHATS_NEW	2012/02/29 22:08:57	1.2327
+++ LVM2/WHATS_NEW	2012/03/01 09:54:23	1.2328
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Check for allocation failure in hold_lock() in clvmd.
   Use set_lv() (wipe initial 4KiB) for non zeroed thin volume.
   Allow cluster mirrors to handle the absence of the checkpoint lib (libSaCkpt).
   Revert free of allocated segtype in init segment error path (2.02.89).
--- LVM2/daemons/clvmd/lvm-functions.c	2012/02/23 22:50:50	1.130
+++ LVM2/daemons/clvmd/lvm-functions.c	2012/03/01 09:54:24	1.131
@@ -167,11 +167,15 @@
 	return lvi;
 }
 
-static void insert_info(const char *resource, struct lv_info *lvi)
+static int insert_info(const char *resource, struct lv_info *lvi)
 {
+	int ret;
+
 	pthread_mutex_lock(&lv_hash_lock);
-	dm_hash_insert(lv_hash, resource, lvi);
+	ret = dm_hash_insert(lv_hash, resource, lvi);
 	pthread_mutex_unlock(&lv_hash_lock);
+
+	return ret;
 }
 
 static void remove_info(const char *resource)
@@ -277,8 +281,10 @@
 		errno = saved_errno;
 	} else {
 		lvi = malloc(sizeof(struct lv_info));
-		if (!lvi)
+		if (!lvi) {
+			errno = ENOMEM;
 			return -1;
+		}
 
 		lvi->lock_mode = mode;
 		status = sync_lock(resource, mode, flags & ~LCKF_CONVERT, &lvi->lock_id);
@@ -288,7 +294,10 @@
 			DEBUGLOG("hold_lock. lock at %d failed: %s\n", mode,
 				 strerror(errno));
 		} else
-			insert_info(resource, lvi);
+			if (!insert_info(resource, lvi)) {
+				errno = ENOMEM;
+				return -1;
+			}
 
 		errno = saved_errno;
 	}


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2012-02-23 22:50 zkabelac
  0 siblings, 0 replies; 23+ messages in thread
From: zkabelac @ 2012-02-23 22:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-23 22:50:50

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Limit sscanf params with size
	
	Make sure parsed string fits given char buffer.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2308&r2=1.2309
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.129&r2=1.130

--- LVM2/WHATS_NEW	2012/02/23 22:41:57	1.2308
+++ LVM2/WHATS_NEW	2012/02/23 22:50:50	1.2309
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Limit sscanf parameters with buffer size in clvmd get_initial_state().
   Use const lv pointer for lv_is_active...() functions. 
   Use same signed numbers in _mirrored_transient_status().
   Integrate client-side lvmetad into build.
--- LVM2/daemons/clvmd/lvm-functions.c	2012/01/20 00:27:19	1.129
+++ LVM2/daemons/clvmd/lvm-functions.c	2012/02/23 22:50:50	1.130
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -729,7 +729,7 @@
 	}
 
 	while (fgets(line, sizeof(line), lvs)) {
-	        if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) {
+	        if (sscanf(line, "%64s %64s %25s %25s\n", vg, lv, flags, vg_flags) == 4) {
 
 			/* States: s:suspended a:active S:dropped snapshot I:invalid snapshot */
 		        if (strlen(vg) == 38 &&                         /* is is a valid UUID ? */


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2011-08-10 11:00 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2011-08-10 11:00 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-08-10 11:00:32

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Initialise clvmd locks before lvm context to avoid open descriptor leaks.
	
	(At least /dev/mapper/control is open after lvm context init.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2054&r2=1.2055
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121

--- LVM2/WHATS_NEW	2011/08/09 18:11:00	1.2054
+++ LVM2/WHATS_NEW	2011/08/10 11:00:32	1.2055
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  Initialise clvmd locks before lvm context to avoid open descriptor leaks.
   Remove obsoleted GULM clvmd cluster locking support.
   Suppress low-level locking errors and warnings while using --sysinit.
   Remove unused inconsistent_seqno variable in _vg_read().
--- LVM2/daemons/clvmd/lvm-functions.c	2011/08/09 18:11:00	1.120
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/08/10 11:00:32	1.121
@@ -721,7 +721,7 @@
  * but this may not be the case...
  * I suppose this also comes in handy if clvmd crashes, not that it would!
  */
-static void *get_initial_state(char **argv)
+static int get_initial_state(char **argv)
 {
 	int lock_mode;
 	char lv[64], vg[64], flags[25], vg_flags[25];
@@ -733,7 +733,7 @@
 	     "r");
 
 	if (!lvs)
-		return NULL;
+		return 1;
 
 	while (fgets(line, sizeof(line), lvs)) {
 	        if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) {
@@ -773,7 +773,7 @@
 	}
 	if (fclose(lvs))
 		DEBUGLOG("lvs fclose failed: %s\n", strerror(errno));
-	return NULL;
+	return 0;
 }
 
 static void lvm2_log_fn(int level, const char *file, int line, int dm_errno,
@@ -886,6 +886,10 @@
 	init_syslog(LOG_DAEMON);
 	openlog("clvmd", LOG_PID, LOG_DAEMON);
 
+	/* Initialise already held locks */
+	if (get_initial_state(argv))
+		log_error("Cannot load initial lock states.");
+
 	if (!(cmd = create_toolcontext(1, NULL, 0))) {
 		log_error("Failed to allocate command context");
 		return 0;
@@ -902,8 +906,6 @@
 	check_config();
 	init_ignore_suspended_devices(1);
 
-	get_initial_state(argv);
-
 	/* Trap log messages so we can pass them back to the user */
 	init_log_fn(lvm2_log_fn);
 	memlock_inc_daemon(cmd);


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2011-03-02 23:38 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2011-03-02 23:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-03-02 23:38:22

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Fix syslog initialisation in clvmd to respect lvm.conf setting.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1933&r2=1.1934
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114

--- LVM2/WHATS_NEW	2011/03/02 20:00:09	1.1933
+++ LVM2/WHATS_NEW	2011/03/02 23:38:22	1.1934
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fix syslog initialisation in clvmd to respect lvm.conf setting.
   Fix possible overflow in maximum stripe size and physical extent size.
   Add test for failed allocation from dm_task_set_uuid() in dmeventd.
   Improve pvremove error message when PV belongs to a VG.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/02/18 14:16:11	1.113
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/03/02 23:38:22	1.114
@@ -915,6 +915,10 @@
 /* Called to initialise the LVM context of the daemon */
 int init_clvm(int using_gulm, char **argv)
 {
+	/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
+	init_syslog(LOG_DAEMON);
+	openlog("clvmd", LOG_PID, LOG_DAEMON);
+
 	if (!(cmd = create_toolcontext(1, NULL))) {
 		log_error("Failed to allocate command context");
 		return 0;
@@ -925,9 +929,6 @@
 		return 0;
 	}
 
-	/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
-	init_syslog(LOG_DAEMON);
-	openlog("clvmd", LOG_PID, LOG_DAEMON);
 	cmd->cmd_line = "clvmd";
 
 	/* Check lvm.conf is setup for cluster-LVM */


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2010-07-01 21:23 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2010-07-01 21:23 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-07-01 21:23:48

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Remove superfluous suspended device counter from clvmd.
	
	Moreover, in current mirror handling, when it calls activate
	on removed but suspended detached log this counter drops below zero
	and confuses debug log.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1646&r2=1.1647
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96

--- LVM2/WHATS_NEW	2010/07/01 11:04:58	1.1646
+++ LVM2/WHATS_NEW	2010/07/01 21:23:47	1.1647
@@ -1,5 +1,6 @@
 Version 2.02.70 - 
 ================================
+  Remove superfluous suspended device counter from clvmd.
   Fix lvm shell crash when input is entirely whitespace.
   Update partial mode warning message.
   Preserve memlock balance in clvmd when activation triggers a resume.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/06/30 21:40:27	1.95
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/07/01 21:23:48	1.96
@@ -38,7 +38,6 @@
 static pthread_mutex_t lv_hash_lock;
 static pthread_mutex_t lvm_lock;
 static char last_error[1024];
-static int suspended = 0;
 
 struct lv_info {
 	int lock_id;
@@ -498,15 +497,11 @@
 
 	case LCK_LV_SUSPEND:
 		status = do_suspend_lv(resource, lock_flags);
-		if (!status)
-			suspended++;
 		break;
 
 	case LCK_UNLOCK:
 	case LCK_LV_RESUME:	/* if active */
 		status = do_resume_lv(resource, lock_flags);
-		if (!status)
-			suspended--;
 		break;
 
 	case LCK_LV_ACTIVATE:
@@ -844,7 +839,7 @@
 	struct volume_group * vg;
 	int consistent = 0;
 
-	DEBUGLOG("Triggering backup of VG metadata for %s. suspended=%d\n", vgname, suspended);
+	DEBUGLOG("Triggering backup of VG metadata for %s.\n", vgname);
 
 	pthread_mutex_lock(&lvm_lock);
 


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2010-03-24 22:25 snitzer
  0 siblings, 0 replies; 23+ messages in thread
From: snitzer @ 2010-03-24 22:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-03-24 22:25:11

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Revert having clvmd consult the lvm.conf "activation/monitoring".
	Correctly implementing the intent of this change requires more
	analysis.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1476&r2=1.1477
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86

--- LVM2/WHATS_NEW	2010/03/23 22:30:18	1.1476
+++ LVM2/WHATS_NEW	2010/03/24 22:25:11	1.1477
@@ -1,7 +1,6 @@
 Version 2.02.63 - 
 ================================
   Add "monitoring" option to "activation" section of lvm.conf.
-  Have clvmd consult the lvm.conf "activation/monitoring".
   Add --monitor and --ignoremonitoring support to lvcreate.
   Allow dynamic extension of array of areas selected as allocation candidates.
   Export and use only valid cookie value in test suite.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/03/23 22:30:19	1.85
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/03/24 22:25:11	1.86
@@ -542,12 +542,8 @@
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(0);
 
-	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE)) {
-		int dmeventd_mode =
-			find_config_tree_bool(cmd, "activation/monitoring",
-					      DEFAULT_DMEVENTD_MONITOR);
-		init_dmeventd_monitor(dmeventd_mode);
-	}
+	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
+		init_dmeventd_monitor(DEFAULT_DMEVENTD_MONITOR);
 
 	cmd->partial_activation = 0;
 


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2010-01-26  8:00 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2010-01-26  8:00 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-26 08:00:03

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Unlock shared lock if activation calls failed.
	
	Clvmd should unlock new lock if activation in device-mapper fails.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1408&r2=1.1409
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84

--- LVM2/WHATS_NEW	2010/01/26 07:58:23	1.1408
+++ LVM2/WHATS_NEW	2010/01/26 08:00:02	1.1409
@@ -1,5 +1,6 @@
 Version 2.02.60 - 23rd January 2010
 ===================================
+  Unlock shared lock in clvmd if activation calls failed.
   Fix return code of info call for query by uuid.
   Extend cmirrord man page.
   Sleep before first progress check if pvmove/lvconvert interval has prefix '+'.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/01/19 13:25:00	1.83
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/01/26 08:00:03	1.84
@@ -373,17 +373,22 @@
 
 	/* If it's suspended then resume it */
 	if (!lv_info_by_lvid(cmd, resource, &lvi, 0, 0))
-		return EIO;
+		goto error;
 
 	if (lvi.suspended)
 		if (!lv_resume(cmd, resource))
-			return EIO;
+			goto error;
 
 	/* Now activate it */
 	if (!lv_activate(cmd, resource, exclusive))
-		return EIO;
+		goto error;
 
 	return 0;
+
+error:
+	if (oldmode == -1 || oldmode != mode)
+		(void)hold_unlock(resource);
+	return EIO;
 }
 
 /* Resume the LV if it was active */


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-12-09 19:01 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2009-12-09 19:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 19:01:28

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Add memlock information to do_lock_lv debug output.
	
	This helps a lot to detect that something strange happened.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1347&r2=1.1348
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77

--- LVM2/WHATS_NEW	2009/12/09 19:00:16	1.1347
+++ LVM2/WHATS_NEW	2009/12/09 19:01:27	1.1348
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Add memlock information to do_lock_lv debug output.
   Never use distributed lock for LV in non-clustered VG.
   Allow implicit lock conversion in pre/post callbacks on local node.
   Allow implicit convert to the same cluster lock mode.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 19:00:16	1.76
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 19:01:28	1.77
@@ -477,8 +477,8 @@
 {
 	int status = 0;
 
-	DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s\n",
-		 resource, decode_locking_cmd(command), decode_flags(lock_flags));
+	DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s, memlock = %d\n",
+		 resource, decode_locking_cmd(command), decode_flags(lock_flags), memlock());
 
 	if (!cmd->config_valid || config_files_changed(cmd)) {
 		/* Reinitialise various settings inc. logging, filters */
@@ -541,7 +541,7 @@
 	dm_pool_empty(cmd->mem);
 	pthread_mutex_unlock(&lvm_lock);
 
-	DEBUGLOG("Command return is %d\n", status);
+	DEBUGLOG("Command return is %d, memlock is %d\n", status, memlock());
 	return status;
 }
 


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-12-09 19:00 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2009-12-09 19:00 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 19:00:16

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Never ever use distributed lock for LV in non-clustered VG.
	
	The LV locks make sense only for clustered LVs.
	
	Properly check cluster flag and never issue cluster lock here.
	
	There are several places in code, where it is already checked, this
	patch add this check to all needed calls.
	
	In previous code the lock behaviour was inconsistent,
	for example, the pre/post callback can take lock even for local volume,
	but deactivate call do not released this lock and it remains held forever.
	
	The local LV lock request now just let run the underlying activation code
	on local node, the same process like in local locking.
	
	(Again, this is important for new mirror repair calls, here for local
	mirrors but with cluster locking enabled.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1346&r2=1.1347
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76

--- LVM2/WHATS_NEW	2009/12/09 18:55:53	1.1346
+++ LVM2/WHATS_NEW	2009/12/09 19:00:16	1.1347
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Never use distributed lock for LV in non-clustered VG.
   Allow implicit lock conversion in pre/post callbacks on local node.
   Allow implicit convert to the same cluster lock mode.
   Replace magic masks in cluster locking code by defined masks.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 18:55:53	1.75
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 19:00:16	1.76
@@ -331,7 +331,8 @@
 
 	/* Is it already open ? */
 	oldmode = get_current_lock(resource);
-	if (oldmode == mode) {
+	if (oldmode == mode && (lock_flags & LCK_CLUSTER_VG)) {
+		DEBUGLOG("do_activate_lv, lock already held at %d\n", oldmode);
 		return 0;	/* Nothing to do */
 	}
 
@@ -384,13 +385,13 @@
 }
 
 /* Resume the LV if it was active */
-static int do_resume_lv(char *resource)
+static int do_resume_lv(char *resource, unsigned char lock_flags)
 {
 	int oldmode;
 
 	/* Is it open ? */
 	oldmode = get_current_lock(resource);
-	if (oldmode == -1) {
+	if (oldmode == -1 && (lock_flags & LCK_CLUSTER_VG)) {
 		DEBUGLOG("do_resume_lv, lock not already held\n");
 		return 0;	/* We don't need to do anything */
 	}
@@ -402,15 +403,15 @@
 }
 
 /* Suspend the device if active */
-static int do_suspend_lv(char *resource)
+static int do_suspend_lv(char *resource, unsigned char lock_flags)
 {
 	int oldmode;
 	struct lvinfo lvi;
 
 	/* Is it open ? */
 	oldmode = get_current_lock(resource);
-	if (oldmode == -1) {
-		DEBUGLOG("do_suspend_lv, lock held at %d\n", oldmode);
+	if (oldmode == -1 && (lock_flags & LCK_CLUSTER_VG)) {
+		DEBUGLOG("do_suspend_lv, lock not already held\n");
 		return 0; /* Not active, so it's OK */
 	}
 
@@ -502,14 +503,14 @@
 		break;
 
 	case LCK_LV_SUSPEND:
-		status = do_suspend_lv(resource);
+		status = do_suspend_lv(resource, lock_flags);
 		if (!status)
 			suspended++;
 		break;
 
 	case LCK_UNLOCK:
 	case LCK_LV_RESUME:	/* if active */
-		status = do_resume_lv(resource);
+		status = do_resume_lv(resource, lock_flags);
 		if (!status)
 			suspended--;
 		break;
@@ -552,7 +553,8 @@
 	   before suspending cluster-wide.
 	   LKF_CONVERT is used always, local node is going to modify metadata
 	 */
-	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND) {
+	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND &&
+	    (lock_flags & LCK_CLUSTER_VG)) {
 		DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n",
 			 resource, decode_locking_cmd(command), decode_flags(lock_flags));
 
@@ -569,7 +571,8 @@
 	int status;
 
 	/* Opposite of above, done on resume after a metadata update */
-	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME) {
+	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME &&
+	    (lock_flags & LCK_CLUSTER_VG)) {
 		int oldmode;
 
 		DEBUGLOG


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-12-09 18:55 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2009-12-09 18:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 18:55:53

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Allow implicit lock conversion for pre/post callbacks.
	
	This is unnoticed regression from commit 31672ff60e405795cad70d6d7888ac011f5373ce
	
	The pre/post callback need to convert lock always, local node
	is going to modify metadata in this case, it it fails conversion,
	the call is ignored.
	
	Also it fixes bug when the lock is not yet held, we cannot set LKF_CONVERT
	in this case, it will fail because this lock do not exist.
	
	Note that the automatic conversion is still disabled in activate
	call, so the original fix (reactivation of exlusive LV) should
	be still in place.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1345&r2=1.1346
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75

--- LVM2/WHATS_NEW	2009/12/09 18:45:12	1.1345
+++ LVM2/WHATS_NEW	2009/12/09 18:55:53	1.1346
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Allow implicit lock conversion in pre/post callbacks on local node.
   Allow implicit convert to the same cluster lock mode.
   Replace magic masks in cluster locking code by defined masks.
   Remove log volume from metadata if initial deactivation fails.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 18:45:13	1.74
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 18:55:53	1.75
@@ -274,7 +274,7 @@
 			return -1;
 
 		lvi->lock_mode = mode;
-		status = sync_lock(resource, mode, flags, &lvi->lock_id);
+		status = sync_lock(resource, mode, flags & ~LKF_CONVERT, &lvi->lock_id);
 		saved_errno = errno;
 		if (status) {
 			free(lvi);
@@ -348,7 +348,11 @@
 		mode = LKM_EXMODE;
 	}
 
-	/* Try to get the lock if it's a clustered volume group */
+	/*
+	 * Try to get the lock if it's a clustered volume group.
+	 * Use lock conversion only if requested, to prevent implicit conversion
+	 * of exclusive lock to shared one during activation.
+	 */
 	if (lock_flags & LCK_CLUSTER_VG) {
 		status = hold_lock(resource, mode, LKF_NOQUEUE | (lock_flags & LCK_CONVERT?LKF_CONVERT:0));
 		if (status) {
@@ -546,12 +550,13 @@
 	/* Nearly all the stuff happens cluster-wide. Apart from SUSPEND. Here we get the
 	   lock out on this node (because we are the node modifying the metadata)
 	   before suspending cluster-wide.
+	   LKF_CONVERT is used always, local node is going to modify metadata
 	 */
 	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND) {
 		DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n",
 			 resource, decode_locking_cmd(command), decode_flags(lock_flags));
 
-		if (hold_lock(resource, LKM_PWMODE, LKF_NOQUEUE| (lock_flags & LCK_CONVERT?LKF_CONVERT:0)))
+		if (hold_lock(resource, LKM_PWMODE, LKF_NOQUEUE | LKF_CONVERT))
 			return errno;
 	}
 	return 0;
@@ -583,7 +588,7 @@
 				return EIO;
 
 			if (lvi.exists) {
-				if (hold_lock(resource, LKM_CRMODE, lock_flags & LCK_CONVERT?LKF_CONVERT:0))
+				if (hold_lock(resource, LKM_CRMODE, LKF_CONVERT))
 					return errno;
 			} else {
 				if (hold_unlock(resource))


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-12-09 18:45 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2009-12-09 18:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 18:45:13

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Allow implicit "convert" to the same lock mode.
	
	(Code already not fail if unlocking not locked resource.)
	
	This is needed in pre/post lock_lv call, where we can
	request the same lock on local node becuase of suspend call.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1344&r2=1.1345
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74

--- LVM2/WHATS_NEW	2009/12/09 18:42:02	1.1344
+++ LVM2/WHATS_NEW	2009/12/09 18:45:12	1.1345
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Allow implicit convert to the same cluster lock mode.
   Replace magic masks in cluster locking code by defined masks.
   Remove log volume from metadata if initial deactivation fails.
   Give better error message for pvmove when all data is skipped.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 18:42:03	1.73
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 18:45:13	1.74
@@ -245,6 +245,11 @@
 
 	lvi = lookup_info(resource);
 
+	if (lvi && lvi->lock_mode == mode) {
+		DEBUGLOG("hold_lock, lock mode %d already held\n", mode);
+		return 0;
+	}
+
 	/* Only allow explicit conversions */
 	if (lvi && !(flags & LKF_CONVERT)) {
 		errno = EBUSY;


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-10-22 17:45 agk
  0 siblings, 0 replies; 23+ messages in thread
From: agk @ 2009-10-22 17:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Fix clvmd segfault when refresh_toolcontext fails.   (brassow, bz 506986)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1300&r2=1.1301
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70

--- LVM2/WHATS_NEW	2009/10/22 17:33:09	1.1300
+++ LVM2/WHATS_NEW	2009/10/22 17:45:23	1.1301
@@ -1,5 +1,6 @@
 Version 2.02.54 -
 =====================================
+  Fix clvmd segfault when refresh_toolcontext fails.
   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.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/10/01 14:14:17	1.69
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/10/22 17:45:24	1.70
@@ -601,20 +601,23 @@
 
 int do_refresh_cache()
 {
-	int ret;
 	DEBUGLOG("Refreshing context\n");
 	log_notice("Refreshing context");
 
 	pthread_mutex_lock(&lvm_lock);
 
-	ret = refresh_toolcontext(cmd);
+	if (!refresh_toolcontext(cmd)) {
+		pthread_mutex_unlock(&lvm_lock);
+		return -1;
+	}
+
 	init_full_scan_done(0);
 	lvmcache_label_scan(cmd, 2);
 	dm_pool_empty(cmd->mem);
 
 	pthread_mutex_unlock(&lvm_lock);
 
-	return ret==1?0:-1;
+	return 0;
 }
 
 


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-10-01 14:14 ccaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: ccaulfield @ 2009-10-01 14:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2009-10-01 14:14:18

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Stop clvmd from automatically doing lock conversions. Now, if a lock
	is granted at one mode and an attempt to convert it wthout the LCK_CONVERT
	flag set then it will return errno=EBUSY.
	
	This fixes a pretty bad bug in which an LV could be activated exclusively on
	one node and lvchange -ay on another would convert it to shared!
	
	It might break some things in other areas, but I doubt it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1285&r2=1.1286
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69

--- LVM2/WHATS_NEW	2009/10/01 00:35:29	1.1285
+++ LVM2/WHATS_NEW	2009/10/01 14:14:17	1.1286
@@ -1,5 +1,6 @@
 Version 2.02.54 -
 =====================================
+  Only do lock conversions in clvmd if we are explicitly asked for one.
   Introduce percent_range_t and centralise snapshot full/mirror in-sync checks.
   Factor out poll_mirror_progress and introduce progress_t.
   Distinguish between powers of 1000 and powers of 1024 in unit suffixes.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/08/05 14:18:35	1.68
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/10/01 14:14:17	1.69
@@ -143,10 +143,11 @@
 {
 	static char buf[128];
 
-	sprintf(buf, "0x%x (%s%s%s)", flags,
+	sprintf(buf, "0x%x (%s%s%s%s)", flags,
 		flags & LCK_PARTIAL_MODE	  ? "PARTIAL_MODE " : "",
 		flags & LCK_MIRROR_NOSYNC_MODE	  ? "MIRROR_NOSYNC " : "",
-		flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR " : "");
+		flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR " : "",
+		flags & LCK_CONVERT ? "CONVERT " : "");
 
 	return buf;
 }
@@ -239,13 +240,20 @@
 	int saved_errno;
 	struct lv_info *lvi;
 
-	flags &= LKF_NOQUEUE;	/* Only LKF_NOQUEUE is valid here */
+	/* Mask off invalid options */
+	flags &= LKF_NOQUEUE | LKF_CONVERT;
 
-	if ((lvi = lookup_info(resource))) {
+	lvi = lookup_info(resource);
+
+	/* Only allow explicit conversions */
+	if (lvi && !(flags & LKF_CONVERT)) {
+		errno = EBUSY;
+		return -1;
+	}
+	if (lvi) {
 		/* Already exists - convert it */
 		status =
-		    sync_lock(resource, mode, LKF_CONVERT | flags,
-			      &lvi->lock_id);
+		    sync_lock(resource, mode, flags, &lvi->lock_id);
 		saved_errno = errno;
 		if (!status)
 			lvi->lock_mode = mode;
@@ -337,7 +345,7 @@
 
 	/* Try to get the lock if it's a clustered volume group */
 	if (lock_flags & LCK_CLUSTER_VG) {
-		status = hold_lock(resource, mode, LKF_NOQUEUE);
+		status = hold_lock(resource, mode, LKF_NOQUEUE | (lock_flags & LCK_CONVERT?LKF_CONVERT:0));
 		if (status) {
 			/* Return an LVM-sensible error for this.
 			 * Forcing EIO makes the upper level return this text
@@ -538,7 +546,7 @@
 		DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n",
 			 resource, decode_locking_cmd(command), decode_flags(lock_flags));
 
-		if (hold_lock(resource, LKM_PWMODE, LKF_NOQUEUE))
+		if (hold_lock(resource, LKM_PWMODE, LKF_NOQUEUE| (lock_flags & LCK_CONVERT?LKF_CONVERT:0)))
 			return errno;
 	}
 	return 0;
@@ -570,7 +578,7 @@
 				return EIO;
 
 			if (lvi.exists) {
-				if (hold_lock(resource, LKM_CRMODE, 0))
+				if (hold_lock(resource, LKM_CRMODE, lock_flags & LCK_CONVERT?LKF_CONVERT:0))
 					return errno;
 			} else {
 				if (hold_unlock(resource))


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-08-05 14:18 ccaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: ccaulfield @ 2009-08-05 14:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2009-08-05 14:18:36

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Fix locking in clvmd
	
	The changes to remove LCK_NONBLOCK from the LVM locks broke clvmd because the
	code was clearly wrong but working anyway! The constant was being masked rather
	than the variable that was supposed to match against it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1231&r2=1.1232
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68

--- LVM2/WHATS_NEW	2009/08/04 15:55:43	1.1231
+++ LVM2/WHATS_NEW	2009/08/05 14:18:35	1.1232
@@ -1,5 +1,6 @@
 Version 2.02.51 - 
 ================================
+  Fix locking in clvmd (2.02.50).
   Add --noudevsync option for relevant LVM tools.
   Add activation/udev_sync to lvm.conf.
   Only change LV symlinks on ACTIVATE not PRELOAD.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/07/24 18:15:07	1.67
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/08/05 14:18:35	1.68
@@ -479,29 +479,29 @@
 
 	cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
 
-	switch (command) {
-	case LCK_LV_EXCLUSIVE & LCK_MASK:
+	switch (command & LCK_MASK) {
+	case LCK_LV_EXCLUSIVE:
 		status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
 		break;
 
-	case LCK_LV_SUSPEND & LCK_MASK:
+	case LCK_LV_SUSPEND:
 		status = do_suspend_lv(resource);
 		if (!status)
 			suspended++;
 		break;
 
 	case LCK_UNLOCK:
-	case LCK_LV_RESUME & LCK_MASK:	/* if active */
+	case LCK_LV_RESUME:	/* if active */
 		status = do_resume_lv(resource);
 		if (!status)
 			suspended--;
 		break;
 
-	case LCK_LV_ACTIVATE & LCK_MASK:
+	case LCK_LV_ACTIVATE:
 		status = do_activate_lv(resource, lock_flags, LKM_CRMODE);
 		break;
 
-	case LCK_LV_DEACTIVATE & LCK_MASK:
+	case LCK_LV_DEACTIVATE:
 		status = do_deactivate_lv(resource, lock_flags);
 		break;
 


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2009-03-05 16:25 mbroz
  0 siblings, 0 replies; 23+ messages in thread
From: mbroz @ 2009-03-05 16:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-03-05 16:25:36

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Fix possible increasing in memory allocation if refreshing_context
	(for example when CLVMD_CMD_LOCK_VG for is called during vgscan).
	
	If clvmd calls LV lock, it calls
	/* clean the pool for another command */
	dm_pool_empty(cmd->mem);
	to clean up memory pool after command.
	
	Unfortunately, do_refresh_cache() do not call this
	and because during it operation it allocates some memory,
	the pool increases.
	
	Also do_refresh_cache should use lvm_lock
	(it manipulates with lvm internal data).
	
	The same applies for lvm_backup command.
	
	Signed-off-by: Milan Broz <mbroz@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1061&r2=1.1062
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58

--- LVM2/WHATS_NEW	2009/03/03 18:25:05	1.1061
+++ LVM2/WHATS_NEW	2009/03/05 16:25:35	1.1062
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Flush memory pool and fix locking in clvmd refresh and backup command.
 
 Version 2.02.45 - 3rd March 2009
 ================================
--- LVM2/daemons/clvmd/lvm-functions.c	2009/02/22 21:14:38	1.57
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/03/05 16:25:36	1.58
@@ -406,16 +406,15 @@
 	DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s\n",
 		 resource, decode_locking_cmd(command), decode_flags(lock_flags));
 
-	pthread_mutex_lock(&lvm_lock);
 	if (!cmd->config_valid || config_files_changed(cmd)) {
 		/* Reinitialise various settings inc. logging, filters */
 		if (do_refresh_cache()) {
 			log_error("Updated config file invalid. Aborting.");
-			pthread_mutex_unlock(&lvm_lock);
 			return EINVAL;
 		}
 	}
 
+	pthread_mutex_lock(&lvm_lock);
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(1);
 
@@ -538,9 +537,14 @@
 	DEBUGLOG("Refreshing context\n");
 	log_notice("Refreshing context");
 
+	pthread_mutex_lock(&lvm_lock);
+
 	ret = refresh_toolcontext(cmd);
 	init_full_scan_done(0);
 	lvmcache_label_scan(cmd, 2);
+	dm_pool_empty(cmd->mem);
+
+	pthread_mutex_unlock(&lvm_lock);
 
 	return ret==1?0:-1;
 }
@@ -711,14 +715,18 @@
 
 	DEBUGLOG("Triggering backup of VG metadata for %s. suspended=%d\n", vgname, suspended);
 
+	pthread_mutex_lock(&lvm_lock);
+
 	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent);
-	if (vg) {
-		if (consistent)
-			check_current_backup(vg);
-	}
-	else {
+
+	if (vg && consistent)
+		check_current_backup(vg);
+	else
 		log_error("Error backing up metadata, can't find VG for group %s", vgname);
-	}
+
+	dm_pool_empty(cmd->mem);
+
+	pthread_mutex_unlock(&lvm_lock);
 }
 
 /* Called to initialise the LVM context of the daemon */


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2008-04-08 13:03 ccaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: ccaulfield @ 2008-04-08 13:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-04-08 13:03:13

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Add config file overrides to clvmd when it reads the LVs list so that
	config items 'command_names' and 'prefix' don't prevent it working.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.830&r2=1.831
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39

--- LVM2/WHATS_NEW	2008/04/08 12:49:20	1.830
+++ LVM2/WHATS_NEW	2008/04/08 13:03:13	1.831
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Addd config file overrides to clvmd when it reads the active LVs list
   Fix vgreduce to use vg_split_mdas to check sufficient mdas remain.
   Add (empty) orphan VGs to lvmcache during initialisation.
   Fix orphan VG name used for format_pool.
--- LVM2/daemons/clvmd/lvm-functions.c	2008/04/04 08:53:47	1.38
+++ LVM2/daemons/clvmd/lvm-functions.c	2008/04/08 13:03:13	1.39
@@ -470,7 +470,7 @@
 	char line[255];
 	FILE *vgs =
 	    popen
-	    ("lvm pvs --nolocking --noheadings -o vg_name", "r");
+	    ("lvm pvs  --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_name", "r");
 
 	sync_unlock("P_orphans", LCK_EXCL);
 
@@ -511,7 +511,7 @@
 	char line[255];
 	FILE *lvs =
 	    popen
-	    ("lvm lvs --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr",
+	    ("lvm lvs  --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr",
 	     "r");
 
 	if (!lvs)


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2008-04-04  8:53 ccaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: ccaulfield @ 2008-04-04  8:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-04-04 08:53:47

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	If lvm.conf was touched, clvmd attempted to update the toolcontext
	but only did half of the job. It now shares the do_refresh_cache()
	function that vgscan invokes.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.822&r2=1.823
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38

--- LVM2/WHATS_NEW	2008/04/03 18:56:39	1.822
+++ LVM2/WHATS_NEW	2008/04/04 08:53:46	1.823
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Make clvmd refresh the context correctly when lvm.conf is updated.
   Add some basic internal VG lock validation.
   Add per-command flags to control which commands use the VG metadata cache.
   Fix vgsplit locking of new VG (2.02.30).
--- LVM2/daemons/clvmd/lvm-functions.c	2007/12/05 13:17:18	1.37
+++ LVM2/daemons/clvmd/lvm-functions.c	2008/04/04 08:53:47	1.38
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-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.
  *
@@ -318,7 +318,7 @@
 	pthread_mutex_lock(&lvm_lock);
 	if (!cmd->config_valid || config_files_changed(cmd)) {
 		/* Reinitialise various settings inc. logging, filters */
-		if (!refresh_toolcontext(cmd)) {
+		if (do_refresh_cache()) {
 			log_error("Updated config file invalid. Aborting.");
 			pthread_mutex_unlock(&lvm_lock);
 			return EINVAL;
@@ -437,7 +437,7 @@
 	return 0;
 }
 
-/* Check if a VG is un use by LVM1 so we don't stomp on it */
+/* Check if a VG is in use by LVM1 so we don't stomp on it */
 int do_check_lvm1(const char *vgname)
 {
 	int status;


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2007-08-24  8:29 pcaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: pcaulfield @ 2007-08-24  8:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2007-08-24 08:29:40

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Fix clvmd logging so you can get lvm-level debugging out of it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.694&r2=1.695
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34

--- LVM2/WHATS_NEW	2007/08/23 15:02:26	1.694
+++ LVM2/WHATS_NEW	2007/08/24 08:29:39	1.695
@@ -1,5 +1,6 @@
 Version 2.02.28 -
 ================================
+  Fix clvmd logging so you can get lvm-level debugging out of it.
   Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R.
   Fix clvmd -R, so it fully refreshes the caches.
   Change lvconvert_mirrors to use mirror segtype not striped.
--- LVM2/daemons/clvmd/lvm-functions.c	2007/08/23 12:44:09	1.33
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/08/24 08:29:39	1.34
@@ -548,6 +548,15 @@
 static void lvm2_log_fn(int level, const char *file, int line,
 			const char *message)
 {
+
+	/* Send messages to the normal LVM2 logging system too,
+	   so we get debug output when it's asked for. 
+ 	   We need to NULL the function ptr otherwise it will just call
+	   back into here! */
+	init_log_fn(NULL);
+	print_log(level, file, line, "%s", message);
+	init_log_fn(lvm2_log_fn);
+
 	/*
 	 * Ignore non-error messages, but store the latest one for returning
 	 * to the user.
@@ -601,7 +610,10 @@
 
 	/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
 	init_syslog(LOG_DAEMON);
-	init_debug(_LOG_ERR);
+	openlog("clvmd", LOG_PID, LOG_DAEMON);
+	init_debug(cmd->current_settings.debug);
+	init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
+	set_activation(cmd->current_settings.activation);
 
 	/* Check lvm.conf is setup for cluster-LVM */
 	check_config();


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2007-08-23 12:19 pcaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: pcaulfield @ 2007-08-23 12:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2007-08-23 12:19:13

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Call init_full_scan_done() when refreshing the cache. This should fix clvmd -R.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.692&r2=1.693
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32

--- LVM2/WHATS_NEW	2007/08/22 20:03:44	1.692
+++ LVM2/WHATS_NEW	2007/08/23 12:19:12	1.693
@@ -1,5 +1,6 @@
 Version 2.02.28 -
 ================================
+  Fix clvmd -R, so it fully refreshes the caches.
   Change lvconvert_mirrors to use mirror segtype not striped.
   Fix lvconvert_mirrors detection of number of existing mirrors.
   Clean up numerous compiler warnings that crept in recently.
--- LVM2/daemons/clvmd/lvm-functions.c	2007/08/07 09:06:05	1.31
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/08/23 12:19:13	1.32
@@ -442,9 +442,14 @@
 
 int do_refresh_cache()
 {
+	int ret;
 	DEBUGLOG("Refreshing context\n");
 	log_notice("Refreshing context");
-	return refresh_toolcontext(cmd)==1?0:-1;
+
+	ret = refresh_toolcontext(cmd);
+	init_full_scan_done(0);
+
+	return ret==1?0:-1;
 }
 
 


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2007-04-24 15:13 pcaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: pcaulfield @ 2007-04-24 15:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2007-04-24 16:13:14

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Fix thread race in clvmd.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.599&r2=1.600
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29

--- LVM2/WHATS_NEW	2007/04/23 18:21:01	1.599
+++ LVM2/WHATS_NEW	2007/04/24 15:13:13	1.600
@@ -1,5 +1,6 @@
 Version 2.02.25 -
 =================================
+  Fix thread race in clvmd.
   Add scan_sector param to label_read and _find_labeller.
   Make clvmd cope with quorum devices on RHEL5
   Add dev_read_circular.
--- LVM2/daemons/clvmd/lvm-functions.c	2007/01/25 14:37:47	1.28
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/04/24 15:13:13	1.29
@@ -50,6 +50,7 @@
 static struct cmd_context *cmd = NULL;
 static struct dm_hash_table *lv_hash = NULL;
 static pthread_mutex_t lv_hash_lock;
+static pthread_mutex_t lvm_lock;
 static char last_error[1024];
 
 struct lv_info {
@@ -311,10 +312,12 @@
 	DEBUGLOG("do_lock_lv: resource '%s', cmd = 0x%x, flags = %x\n",
 		 resource, command, lock_flags);
 
+	pthread_mutex_lock(&lvm_lock);
 	if (!cmd->config_valid || config_files_changed(cmd)) {
 		/* Reinitialise various settings inc. logging, filters */
 		if (!refresh_toolcontext(cmd)) {
 			log_error("Updated config file invalid. Aborting.");
+			pthread_mutex_unlock(&lvm_lock);
 			return EINVAL;
 		}
 	}
@@ -367,6 +370,7 @@
 
 	/* clean the pool for another command */
 	dm_pool_empty(cmd->mem);
+	pthread_mutex_unlock(&lvm_lock);
 
 	DEBUGLOG("Command return is %d\n", status);
 	return status;
@@ -393,6 +397,8 @@
 int post_lock_lv(unsigned char command, unsigned char lock_flags,
 		 char *resource)
 {
+	int status;
+
 	/* Opposite of above, done on resume after a metadata update */
 	if (command == LCK_LV_RESUME) {
 		int oldmode;
@@ -406,7 +412,10 @@
 		if (oldmode == LKM_PWMODE) {
 			struct lvinfo lvi;
 
-			if (!lv_info_by_lvid(cmd, resource, &lvi, 0))
+			pthread_mutex_lock(&lvm_lock);
+			status = lv_info_by_lvid(cmd, resource, &lvi, 0);
+			pthread_mutex_unlock(&lvm_lock);
+			if (!status)
 				return EIO;
 
 			if (lvi.exists) {
@@ -533,7 +542,7 @@
 			const char *message)
 {
 	/*
-	 * Ignore non-error messages, but store the latest one for returning 
+	 * Ignore non-error messages, but store the latest one for returning
 	 * to the user.
 	 */
 	if (level != _LOG_ERR && level != _LOG_FATAL)
@@ -572,6 +581,7 @@
 	/* Create hash table for keeping LV locks & status */
 	lv_hash = dm_hash_create(100);
 	pthread_mutex_init(&lv_hash_lock, NULL);
+	pthread_mutex_init(&lvm_lock, NULL);
 }
 
 /* Called to initialise the LVM context of the daemon */


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2005-02-14  9:07 pcaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: pcaulfield @ 2005-02-14  9:07 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-02-14 09:07:15

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Make config check a little more tolerant of library names.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.184&r2=1.185
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2005-02-02 11:42 pcaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: pcaulfield @ 2005-02-02 11:42 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-02-02 11:42:29

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Make clvmd do a quick sanity check on the clustering bits of lvm.conf

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.176&r2=1.177
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6


^ permalink raw reply	[flat|nested] 23+ messages in thread
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c
@ 2004-10-04  9:23 pcaulfield
  0 siblings, 0 replies; 23+ messages in thread
From: pcaulfield @ 2004-10-04  9:23 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2004-10-04 09:23:52

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 

Log message:
	Check the UUID length when readingthe output of the "lvs" command at startup.
	This way we should not get quite so confused by any debugging output
	that may come our way.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4


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

end of thread, other threads:[~2012-03-01  9:54 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-01  9:54 LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-02-23 22:50 zkabelac
2011-08-10 11:00 mbroz
2011-03-02 23:38 mbroz
2010-07-01 21:23 mbroz
2010-03-24 22:25 snitzer
2010-01-26  8:00 mbroz
2009-12-09 19:01 mbroz
2009-12-09 19:00 mbroz
2009-12-09 18:55 mbroz
2009-12-09 18:45 mbroz
2009-10-22 17:45 agk
2009-10-01 14:14 ccaulfield
2009-08-05 14:18 ccaulfield
2009-03-05 16:25 mbroz
2008-04-08 13:03 ccaulfield
2008-04-04  8:53 ccaulfield
2007-08-24  8:29 pcaulfield
2007-08-23 12:19 pcaulfield
2007-04-24 15:13 pcaulfield
2005-02-14  9:07 pcaulfield
2005-02-02 11:42 pcaulfield
2004-10-04  9:23 pcaulfield

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