public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW doc/example.conf lib/activate ...
@ 2009-08-04 15:36 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2009-08-04 15:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-08-04 15:36:15

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/activate   : dev_manager.c 
	lib/commands   : toolcontext.c toolcontext.h 
	lib/config     : defaults.h 
	tools          : lvmcmdline.c 

Log message:
	Add activation/udev_sync to lvm.conf.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1229&r2=1.1230
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.157&r2=1.158
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105

--- LVM2/WHATS_NEW	2009/08/03 18:09:25	1.1229
+++ LVM2/WHATS_NEW	2009/08/04 15:36:13	1.1230
@@ -1,5 +1,6 @@
 Version 2.02.51 - 
 ================================
+  Add activation/udev_sync to lvm.conf.
   Only change LV symlinks on ACTIVATE not PRELOAD.
   Make lvconvert honour log mirror options combined with downconversion.
   Allow LV suspend while --ignorelockingfailure is in force.
--- LVM2/doc/example.conf	2009/08/01 17:08:44	1.44
+++ LVM2/doc/example.conf	2009/08/04 15:36:14	1.45
@@ -301,6 +301,16 @@
 }
 
 activation {
+    # Set to 0 to disable udev syncronisation (if compiled into the binaries).
+    # Processes will not wait for notification from udev.
+    # They will continue irrespective of any possible udev processing
+    # in the background.  You should only use this if udev is not running
+    # or has rules that ignore the devices LVM2 creates.
+    # The command line argument --nodevsync takes precedence over this setting.
+    # If set to 1 when udev is not running, and there are LVM2 processes
+    # waiting for udev, run 'dmsetup udevcomplete' manually to wake them up.
+    udev_sync = 1
+
     # How to fill in missing stripes if activating an incomplete volume.
     # Using "error" will make inaccessible parts of the device return
     # I/O errors on access.  You can instead use a device path, in which 
--- LVM2/lib/activate/dev_manager.c	2009/08/03 18:09:26	1.157
+++ LVM2/lib/activate/dev_manager.c	2009/08/04 15:36:14	1.158
@@ -455,6 +455,8 @@
 
 	dm->target_state = NULL;
 
+	dm_udev_set_sync_support(cmd->current_settings.udev_sync);
+
 	return dm;
 
       bad:
--- LVM2/lib/commands/toolcontext.c	2009/07/21 20:00:04	1.83
+++ LVM2/lib/commands/toolcontext.c	2009/08/04 15:36:14	1.84
@@ -265,6 +265,10 @@
 		return 0;
 	}
 
+	cmd->default_settings.udev_sync = find_config_tree_int(cmd,
+								"activation/udev_sync",
+								DEFAULT_UDEV_SYNC);
+
 	cmd->stripe_filler = find_config_tree_str(cmd,
 						  "activation/missing_stripe_filler",
 						  DEFAULT_STRIPE_FILLER);
--- LVM2/lib/commands/toolcontext.h	2009/07/13 19:49:49	1.32
+++ LVM2/lib/commands/toolcontext.h	2009/08/04 15:36:14	1.33
@@ -34,6 +34,7 @@
 	int archive;		/* should we archive ? */
 	int backup;		/* should we backup ? */
 	int read_ahead;		/* DM_READ_AHEAD_NONE or _AUTO */
+	int udev_sync;
 	int cache_vgmetadata;
 	const char *msg_prefix;
 	struct format_type *fmt;
--- LVM2/lib/config/defaults.h	2009/08/01 17:08:44	1.49
+++ LVM2/lib/config/defaults.h	2009/08/04 15:36:14	1.50
@@ -68,6 +68,7 @@
 #define DEFAULT_PVMETADATACOPIES 1
 #define DEFAULT_LABELSECTOR UINT64_C(1)
 #define DEFAULT_READ_AHEAD "auto"
+#define DEFAULT_UDEV_SYNC 0
 #define DEFAULT_EXTENT_SIZE 4096	/* In KB */
 #define DEFAULT_MAX_PV 0
 #define DEFAULT_MAX_LV 0
--- LVM2/tools/lvmcmdline.c	2009/07/27 21:01:58	1.104
+++ LVM2/tools/lvmcmdline.c	2009/08/04 15:36:15	1.105
@@ -830,6 +830,9 @@
 	} else
 		init_trust_cache(0);
 
+	if (arg_count(cmd, noudevsync_ARG))
+		cmd->current_settings.udev_sync = 0;
+
 	/* Handle synonyms */
 	if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
 	    !_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||


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

* LVM2 ./WHATS_NEW doc/example.conf lib/activate ...
@ 2010-03-05 14:48 zkabelac
  0 siblings, 0 replies; 5+ messages in thread
From: zkabelac @ 2010-03-05 14:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-03-05 14:48:34

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/activate   : activate.c 
	lib/config     : defaults.h 
	lib/locking    : locking.c 
	lib/mm         : memlock.c memlock.h 
	tools          : lvmcmdlib.c 

Log message:
	mlockall() -> mlock()
	
	This patch adds a new implementation of locking function instead
	of mlockall() that may lock way too much memory (>100MB).
	New function instead uses mlock() system call and selectively locks
	memory areas from /proc/self/maps trying to avoid locking areas
	unused during lock-ed state.
	
	Patch also adds struct cmd_context to all memlock() calls to have
	access to configuration.
	
	For backward compatibility functionality of mlockall()
	is preserved with "activation/use_mlockall" flag.
	
	As a simple check, locking and unlocking counts the amount of memory
	and compares whether values are matching.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1454&r2=1.1455
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.54&r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdlib.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12

--- LVM2/WHATS_NEW	2010/03/04 12:12:34	1.1454
+++ LVM2/WHATS_NEW	2010/03/05 14:48:33	1.1455
@@ -1,5 +1,6 @@
 Version 2.02.62 -
 ====================================
+  Reimplement mlockall() with mlock() to reduce mmaped memory size.
   Define and use internal makefile variable UDEV_LIBS.
   Define and use internal makefile variable DL_LIBS.
   Update check for selinux libraries and link them only when needed.
--- LVM2/doc/example.conf	2010/01/07 19:54:21	1.54
+++ LVM2/doc/example.conf	2010/03/05 14:48:33	1.55
@@ -413,6 +413,21 @@
 
     mirror_log_fault_policy = "allocate"
     mirror_image_fault_policy = "remove"
+
+    # While activating devices, I/O to devices being (re)configured is
+    # suspended, and as a precaution against deadlocks, LVM2 needs to pin
+    # any memory it is using so it is not paged out.  Groups of pages that
+    # are known not to be accessed during activation need not be pinned
+    # into memory.  Each string listed in this setting is compared against
+    # each line in /proc/self/maps, and the pages corresponding to any
+    # lines that match are not pinned.  On some systems locale-archive was
+    # found to make up over 80% of the memory used by the process.
+    # mlock_filter = [ "locale/locale-archive", "gconv/gconv-modules.cache" ]
+
+    # Set to 1 to revert to the default behaviour prior to version 2.02.62
+    # which used mlockall() to pin the whole process's memory while activating
+    # devices.
+    # use_mlockall = 0
 }
 
 
--- LVM2/lib/activate/activate.c	2010/02/24 20:01:41	1.166
+++ LVM2/lib/activate/activate.c	2010/03/05 14:48:34	1.167
@@ -849,7 +849,7 @@
 		if (!error_if_not_suspended) {
 			r = 1;
 			if (info.suspended)
-				memlock_inc();
+				memlock_inc(cmd);
 		}
 		goto out;
 	}
@@ -868,13 +868,13 @@
 		/* FIXME Consider aborting here */
 		stack;
 
-	memlock_inc();
+	memlock_inc(cmd);
 
 	if (lv_is_origin(lv_pre) || lv_is_cow(lv_pre))
 		lockfs = 1;
 
 	if (!_lv_suspend_lv(lv, lockfs, flush_required)) {
-		memlock_dec();
+		memlock_dec(cmd);
 		fs_unlock();
 		goto out;
 	}
@@ -930,7 +930,7 @@
 	if (!_lv_activate_lv(lv))
 		goto_out;
 
-	memlock_dec();
+	memlock_dec(cmd);
 	fs_unlock();
 
 	if (!monitor_dev_for_events(cmd, lv, 1))
@@ -1019,9 +1019,9 @@
 	if (!monitor_dev_for_events(cmd, lv, 0))
 		stack;
 
-	memlock_inc();
+	memlock_inc(cmd);
 	r = _lv_deactivate(lv);
-	memlock_dec();
+	memlock_dec(cmd);
 	fs_unlock();
 
 	if (!lv_info(cmd, lv, &info, 1, 0) || info.exists)
@@ -1112,10 +1112,10 @@
 	if (exclusive)
 		lv->status |= ACTIVATE_EXCL;
 
-	memlock_inc();
+	memlock_inc(cmd);
 	if (!(r = _lv_activate_lv(lv)))
 		stack;
-	memlock_dec();
+	memlock_dec(cmd);
 	fs_unlock();
 
 	if (r && !monitor_dev_for_events(cmd, lv, 1))
--- LVM2/lib/config/defaults.h	2010/01/07 19:54:22	1.58
+++ LVM2/lib/config/defaults.h	2010/03/05 14:48:34	1.59
@@ -43,6 +43,7 @@
 #define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
 #define DEFAULT_WAIT_FOR_LOCKS 1
 #define DEFAULT_PRIORITISE_WRITE_LOCKS 1
+#define DEFAULT_USE_MLOCKALL 0
 
 #define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
--- LVM2/lib/locking/locking.c	2010/02/15 16:46:56	1.74
+++ LVM2/lib/locking/locking.c	2010/03/05 14:48:34	1.75
@@ -161,22 +161,22 @@
 	_signals_blocked = 0;
 }
 
-static void _lock_memory(lv_operation_t lv_op)
+static void _lock_memory(struct cmd_context *cmd, lv_operation_t lv_op)
 {
 	if (!(_locking.flags & LCK_PRE_MEMLOCK))
 		return;
 
 	if (lv_op == LV_SUSPEND)
-		memlock_inc();
+		memlock_inc(cmd);
 }
 
-static void _unlock_memory(lv_operation_t lv_op)
+static void _unlock_memory(struct cmd_context *cmd, lv_operation_t lv_op)
 {
 	if (!(_locking.flags & LCK_PRE_MEMLOCK))
 		return;
 
 	if (lv_op == LV_RESUME)
-		memlock_dec();
+		memlock_dec(cmd);
 }
 
 void reset_locking(void)
@@ -363,7 +363,7 @@
 	int ret = 0;
 
 	_block_signals(flags);
-	_lock_memory(lv_op);
+	_lock_memory(cmd, lv_op);
 
 	assert(resource);
 
@@ -390,7 +390,7 @@
 		_update_vg_lock_count(resource, flags);
 	}
 
-	_unlock_memory(lv_op);
+	_unlock_memory(cmd, lv_op);
 	_unblock_signals();
 
 	return ret;
--- LVM2/lib/mm/memlock.c	2009/12/16 19:22:12	1.15
+++ LVM2/lib/mm/memlock.c	2010/03/05 14:48:34	1.16
@@ -28,11 +28,11 @@
 
 #ifndef DEVMAPPER_SUPPORT
 
-void memlock_inc(void)
+void memlock_inc(struct cmd_context *cmd)
 {
 	return;
 }
-void memlock_dec(void)
+void memlock_dec(struct cmd_context *cmd)
 {
 	return;
 }
@@ -57,6 +57,30 @@
 static int _priority;
 static int _default_priority;
 
+/* list of maps, that are unconditionaly ignored */
+static const char * const _ignore_maps[] = {
+    "[vsyscall]"
+};
+
+/* default blacklist for maps */
+static const char * const _blacklist_maps[] = {
+    "locale/locale-archive",
+    "gconv/gconv-modules.cache",
+    "/libreadline.so.",	/* not using readline during mlock */
+    "/libncurses.so.",	/* not using readline during mlock */
+    "/libdl-",		/* not using dlopen,dlsym during mlock */
+    /* "/libdevmapper-event.so" */
+};
+
+typedef enum { LVM_MLOCK, LVM_MUNLOCK } lvmlock_t;
+
+struct maps_stats {
+	size_t r_size;
+	size_t w_size;
+	size_t x_size;
+};
+static struct maps_stats ms; /* statistic for maps locking */
+
 static void _touch_memory(void *mem, size_t size)
 {
 	size_t pagesize = lvm_getpagesize();
@@ -90,17 +114,147 @@
 	free(_malloc_mem);
 }
 
-/* Stop memory getting swapped out */
-static void _lock_mem(void)
+/*
+ * mlock/munlock memory areas from /proc/self/maps
+ * format described in kernel/Documentation/filesystem/proc.txt
+ */
+static int _maps_line(struct cmd_context *cmd, lvmlock_t lock,
+		      const char* line, struct maps_stats* ms)
 {
+	const struct config_node *cn;
+	struct config_value *cv;
+	long from, to;
+	int pos, i;
+	char fr, fw, fx, fp;
+	size_t sz;
+
+	if (sscanf(line, "%lx-%lx %c%c%c%c%n",
+		   &from, &to, &fr, &fw, &fx, &fp, &pos) != 6) {
+		log_error("Failed to parse maps line: %s", line);
+		return 0;
+	}
+
+	/* skip  ---p,  select with r,w,x */
+	if (fr != 'r' && fw != 'w' && fx != 'x')
+		return 1;
+
+	/* always ignored areas */
+	for (i = 0; i < sizeof(_ignore_maps) / sizeof(_ignore_maps[0]); ++i)
+		if (strstr(line + pos, _ignore_maps[i]))
+			return 1;
+
+	sz = to - from;
+	log_debug("%s %10ldKiB %12lx - %12lx %c%c%c%c %s",
+		  (lock == LVM_MLOCK) ? "Mlock" : "Munlock",
+		  ((long)sz + 1023) / 1024, from, to, fr, fw, fx, fp, line + pos);
+
+	if (!(cn = find_config_tree_node(cmd, "activation/mlock_filter"))) {
+		/* If no blacklist configured, use an internal set */
+		for (i = 0; i < sizeof(_blacklist_maps) / sizeof(_blacklist_maps[0]); ++i)
+			if (strstr(line + pos, _blacklist_maps[i])) {
+				log_debug("Filtered by string '%s' (%s)",
+					  _blacklist_maps[i], line);
+				return 1;
+			}
+	} else {
+		for (cv = cn->v; cv; cv = cv->next) {
+			if ((cv->type != CFG_STRING) || !cv->v.str[0]) {
+				log_error("Ignoring invalid string in config file "
+					  "activation/mlock_filter");
+				continue;
+			}
+			if (strstr(line + pos, cv->v.str)) {
+				log_debug("Filtered by string '%s' (%s)",
+					  cv->v.str, line);
+				return 1;
+			}
+		}
+	}
+
+	if (fr == 'r')
+		ms->r_size += sz;
+	if (fw == 'w')
+		ms->w_size += sz;
+	if (fx == 'x')
+		ms->x_size += sz;
+
+	if (lock == LVM_MLOCK) {
+		if (mlock((const void*)from, sz) < 0) {
+			log_sys_error("mlock", line);
+			return 0;
+		}
+	} else {
+		if (munlock((const void*)from, sz) < 0) {
+			log_sys_error("munlock", line);
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
+static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, struct maps_stats* ms)
+{
+	static const char selfmaps[] = "/self/maps";
+	char *procselfmaps = alloca(strlen(cmd->proc_dir) + sizeof(selfmaps));
+	FILE *fh;
+	char *line = NULL;
+	size_t len;
+	ssize_t r;
+	int ret = 0;
+
+	if (find_config_tree_bool(cmd, "activation/use_mlockall",
+				  DEFAULT_USE_MLOCKALL)) {
 #ifdef MCL_CURRENT
-	if (mlockall(MCL_CURRENT | MCL_FUTURE))
-		log_sys_error("mlockall", "");
-	else
-		log_very_verbose("Locking memory");
+		if (lock == LVM_MLOCK) {
+			if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
+				log_sys_error("mlockall", "");
+				return 0;
+			}
+		} else {
+			if (munlockall()) {
+				log_sys_error("munlockall", "");
+				return 0;
+			}
+		}
+		return 1;
+#else
+		return 0;
 #endif
+	}
+
+	strcpy(procselfmaps, cmd->proc_dir);
+	strcat(procselfmaps, selfmaps);
+
+	if ((fh = fopen(procselfmaps, "r")) == NULL) {
+		log_sys_error("fopen", procselfmaps);
+		return 0;
+	}
+
+	while ((r = getline(&line, &len, fh)) != -1) {
+		line[r > 0 ? r - 1 : 0] = '\0'; /* remove \n */
+		if (!(ret = _maps_line(cmd, lock, line, ms)))
+			break;
+	}
+
+	free(line);
+	fclose(fh);
+
+	log_debug("Mapped sizes:  r=%ld,  w=%ld,  x=%ld",
+		  (long)ms->r_size,  (long)ms->w_size, (long)ms->x_size);
+
+	return ret;
+}
+
+/* Stop memory getting swapped out */
+static void _lock_mem(struct cmd_context *cmd)
+{
 	_allocate_memory();
 
+	memset(&ms, 0, sizeof(ms));
+	if (_memlock_maps(cmd, LVM_MLOCK, &ms))
+		log_very_verbose("Locking memory");
+
 	errno = 0;
 	if (((_priority = getpriority(PRIO_PROCESS, 0)) == -1) && errno)
 		log_sys_error("getpriority", "");
@@ -110,43 +264,47 @@
 				  _default_priority, strerror(errno));
 }
 
-static void _unlock_mem(void)
+static void _unlock_mem(struct cmd_context *cmd)
 {
-#ifdef MCL_CURRENT
-	if (munlockall())
-		log_sys_error("munlockall", "");
-	else
+	struct maps_stats ums = { 0 };
+
+	if (_memlock_maps(cmd, LVM_MUNLOCK, &ums))
 		log_very_verbose("Unlocking memory");
-#endif
+
+	if (memcmp(&ms, &ums, sizeof(ms)))
+		log_error(INTERNAL_ERROR "Maps size mismatch (%ld,%ld,%ld) != (%ld,%ld,%ld)",
+			  (long)ms.r_size,  (long)ms.w_size, (long)ms.x_size,
+			  (long)ums.r_size, (long)ums.w_size, (long)ums.x_size);
+
 	_release_memory();
 	if (setpriority(PRIO_PROCESS, 0, _priority))
 		log_error("setpriority %u failed: %s", _priority,
 			  strerror(errno));
 }
 
-static void _lock_mem_if_needed(void) {
+static void _lock_mem_if_needed(struct cmd_context *cmd) {
 	if ((_memlock_count + _memlock_count_daemon) == 1)
-		_lock_mem();
+		_lock_mem(cmd);
 }
 
-static void _unlock_mem_if_possible(void) {
+static void _unlock_mem_if_possible(struct cmd_context *cmd) {
 	if ((_memlock_count + _memlock_count_daemon) == 0)
-		_unlock_mem();
+		_unlock_mem(cmd);
 }
 
-void memlock_inc(void)
+void memlock_inc(struct cmd_context *cmd)
 {
 	++_memlock_count;
-	_lock_mem_if_needed();
+	_lock_mem_if_needed(cmd);
 	log_debug("memlock_count inc to %d", _memlock_count);
 }
 
-void memlock_dec(void)
+void memlock_dec(struct cmd_context *cmd)
 {
 	if (!_memlock_count)
 		log_error(INTERNAL_ERROR "_memlock_count has dropped below 0.");
 	--_memlock_count;
-	_unlock_mem_if_possible();
+	_unlock_mem_if_possible(cmd);
 	log_debug("memlock_count dec to %d", _memlock_count);
 }
 
@@ -157,19 +315,19 @@
  * of memlock or memlock_daemon is in effect.
  */
 
-void memlock_inc_daemon(void)
+void memlock_inc_daemon(struct cmd_context *cmd)
 {
 	++_memlock_count_daemon;
-	_lock_mem_if_needed();
+	_lock_mem_if_needed(cmd);
 	log_debug("memlock_count_daemon inc to %d", _memlock_count_daemon);
 }
 
-void memlock_dec_daemon(void)
+void memlock_dec_daemon(struct cmd_context *cmd)
 {
 	if (!_memlock_count_daemon)
 		log_error(INTERNAL_ERROR "_memlock_count_daemon has dropped below 0.");
 	--_memlock_count_daemon;
-	_unlock_mem_if_possible();
+	_unlock_mem_if_possible(cmd);
 	log_debug("memlock_count_daemon dec to %d", _memlock_count_daemon);
 }
 
--- LVM2/lib/mm/memlock.h	2009/11/19 01:11:57	1.5
+++ LVM2/lib/mm/memlock.h	2010/03/05 14:48:34	1.6
@@ -18,10 +18,10 @@
 
 struct cmd_context;
 
-void memlock_inc(void);
-void memlock_dec(void);
-void memlock_inc_daemon(void);
-void memlock_dec_daemon(void);
+void memlock_inc(struct cmd_context *cmd);
+void memlock_dec(struct cmd_context *cmd);
+void memlock_inc_daemon(struct cmd_context *cmd);
+void memlock_dec_daemon(struct cmd_context *cmd);
 int memlock(void);
 void memlock_init(struct cmd_context *cmd);
 
--- LVM2/tools/lvmcmdlib.c	2009/12/11 13:16:39	1.11
+++ LVM2/tools/lvmcmdlib.c	2010/03/05 14:48:34	1.12
@@ -82,9 +82,9 @@
 	/* FIXME Temporary - move to libdevmapper */
 	ret = ECMD_PROCESSED;
 	if (!strcmp(cmdline, "_memlock_inc"))
-		memlock_inc_daemon();
+		memlock_inc_daemon(cmd);
 	else if (!strcmp(cmdline, "_memlock_dec"))
-		memlock_dec_daemon();
+		memlock_dec_daemon(cmd);
 	else
 		ret = lvm_run_command(cmd, argc, argv);
 


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

* LVM2 ./WHATS_NEW doc/example.conf lib/activate ...
@ 2007-04-26 16:45 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-04-26 16:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-04-26 17:45:00

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/activate   : dev_manager.c 
	lib/commands   : toolcontext.c 
	lib/device     : dev-cache.c dev-cache.h 
	lib/filters    : filter-persistent.c filter-regex.c 
	                 filter-sysfs.c 
	lib/format1    : disk-rep.c format1.c import-extents.c 
	lib/format_text: import_vsn1.c 
	lib/log        : log.h 
	lib/metadata   : metadata.c 
	lib/misc       : lvm-file.c 
	lib/regex      : matcher.c 
	tools          : lvmcmdline.c 

Log message:
	Add devices/preferred_names config regex list for displayed device names.
	Free a temporary dir string in fcntl_lock_file() after use.
	Fix a dm_pool_destroy() in matcher_create().
	Introduce goto_bad macro.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.606&r2=1.607
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-regex.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-sysfs.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-extents.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/regex/matcher.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42

--- LVM2/WHATS_NEW	2007/04/26 16:40:45	1.606
+++ LVM2/WHATS_NEW	2007/04/26 16:44:57	1.607
@@ -1,15 +1,20 @@
 Version 2.02.25 -
 =================================
-  Fix warnings on x86_64 involving ptrdiff_t in log_error messages
-  Update pvck to include text metadata area and record detection
-  Add support functions for analysis of config sections
-  Update pvck to read labels on disk, with --labelsector parameter
-  Add count_chars and count_chars_len functions
-  Add /sys/block listings to lvm_dump.sh
-  Make lvm_dump.sh list /dev recursively
+  Add devices/preferred_names config regex list for displayed device names.
+  Free a temporary dir string in fcntl_lock_file() after use.
+  Fix a dm_pool_destroy() in matcher_create().
+  Introduce goto_bad macro.
+  Fix warnings on x86_64 involving ptrdiff_t in log_error messages.
+  Update pvck to include text metadata area and record detection.
+  Add support functions for token counting in config file extracts.
+  Update pvck to read labels on disk, with --labelsector parameter.
+  Add count_chars and count_chars_len functions.
+  Add /sys/block listings to lvm_dump.sh.
+  Make lvm_dump.sh list /dev recursively.
   Fix thread race in clvmd.
   Add scan_sector param to label_read and _find_labeller.
-  Make clvmd cope with quorum devices on RHEL5
+  Make clvmd cope with quorum devices.
+  Add extra internal error checking to clvmd.
   Add dev_read_circular.
   Add pvck command stub.
   Update lists of attribute characters in man pages.
@@ -17,7 +22,6 @@
   Fix creation and conversion of mirrors with tags.
   Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
   Split metadata areas in vgsplit properly.
-  Add extra internal error checking to clvmd
 
 Version 2.02.24 - 19th March 2007
 =================================
--- LVM2/doc/example.conf	2007/02/28 18:27:12	1.30
+++ LVM2/doc/example.conf	2007/04/26 16:44:57	1.31
@@ -19,6 +19,14 @@
     # to use with LVM2.
     scan = [ "/dev" ]
 
+    # If several entries in the scanned directories correspond to the
+    # same block device and the tools need to display a name for device,
+    # all the pathnames are matched against each item in the following
+    # list of regular expressions in turn and the first match is used.
+    preferred_names = [ ]
+
+    # preferred_names = [ "^/dev/mpath/", "^/dev/[hs]d" ]
+
     # A filter that tells LVM2 to only use a restricted set of devices.
     # The filter consists of an array of regular expressions.  These
     # expressions can be delimited by a character of your choice, and
--- LVM2/lib/activate/dev_manager.c	2007/03/08 19:58:04	1.121
+++ LVM2/lib/activate/dev_manager.c	2007/04/26 16:44:58	1.122
@@ -435,10 +435,8 @@
 		return NULL;
 	}
 
-	if (!(dm = dm_pool_alloc(mem, sizeof(*dm)))) {
-		stack;
-		goto bad;
-	}
+	if (!(dm = dm_pool_alloc(mem, sizeof(*dm))))
+		goto_bad;
 
 	dm->cmd = cmd;
 	dm->mem = mem;
@@ -450,10 +448,8 @@
 	}
 	dm->stripe_filler = stripe_filler;
 
-	if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name))) {
-		stack;
-		goto bad;
-	}
+	if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name)))
+		goto_bad;
 
 	dm->target_state = NULL;
 
--- LVM2/lib/commands/toolcontext.c	2007/02/28 18:27:12	1.49
+++ LVM2/lib/commands/toolcontext.c	2007/04/26 16:44:58	1.50
@@ -465,10 +465,8 @@
 	const struct config_node *cn;
 	struct config_value *cv;
 
-	if (!dev_cache_init()) {
-		stack;
-		return 0;
-	}
+	if (!dev_cache_init(cmd))
+		return_0;
 
 	if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
 		if (!dev_cache_add_dir("/dev")) {
--- LVM2/lib/device/dev-cache.c	2006/08/01 14:56:32	1.45
+++ LVM2/lib/device/dev-cache.c	2007/04/26 16:44:58	1.46
@@ -19,6 +19,8 @@
 #include "btree.h"
 #include "filter.h"
 #include "filter-persistent.h"
+#include "matcher.h"
+#include "toolcontext.h"
 
 #include <unistd.h>
 #include <sys/param.h>
@@ -38,6 +40,7 @@
 	struct dm_pool *mem;
 	struct dm_hash_table *names;
 	struct btree *devices;
+	struct matcher *preferred_names_matcher;
 
 	int has_scanned;
 	struct list dirs;
@@ -129,15 +132,49 @@
 	return dev;
 }
 
+void dev_set_preferred_name(struct str_list *sl, struct device *dev)
+{
+	/*
+	 * Don't interfere with ordering specified in config file.
+	 */
+	if (_cache.preferred_names_matcher)
+		return;
+
+	log_debug("%s: New preferred name", sl->str);
+	list_del(&sl->list);
+	list_add_h(&dev->aliases, &sl->list);
+}
+
 /* Return 1 if we prefer path1 else return 0 */
 static int _compare_paths(const char *path0, const char *path1)
 {
 	int slash0 = 0, slash1 = 0;
+	int m0, m1;
 	const char *p;
 	char p0[PATH_MAX], p1[PATH_MAX];
 	char *s0, *s1;
 	struct stat stat0, stat1;
 
+	if (_cache.preferred_names_matcher) {
+		m0 = matcher_run(_cache.preferred_names_matcher, path0);
+		m1 = matcher_run(_cache.preferred_names_matcher, path1);
+
+		if (m0 != m1) {
+			if (m0 < 0)
+				return 1;
+			if (m1 < 0)
+				return 0;
+			if (m0 < m1)
+				return 1;
+			if (m1 < m0)
+				return 0;
+		}
+	}
+
+	/*
+	 * Built-in rules.
+	 */
+
 	/* Return the path with fewer slashes */
 	for (p = path0; p++; p = (const char *) strchr(p, '/'))
 		slash0++;
@@ -441,7 +478,65 @@
 		_full_scan(1);
 }
 
-int dev_cache_init(void)
+static int _init_preferred_names(struct cmd_context *cmd)
+{
+	const struct config_node *cn;
+	struct config_value *v;
+	struct dm_pool *scratch = NULL;
+	char **regex;
+	unsigned count = 0;
+	int i, r = 0;
+
+	_cache.preferred_names_matcher = NULL;
+
+	if (!(cn = find_config_tree_node(cmd, "devices/preferred_names")) ||
+	    cn->v->type == CFG_EMPTY_ARRAY) {
+		log_very_verbose("devices/preferred_names not found in config file: "
+				 "using built-in preferences");
+		return 1;
+	}
+
+	for (v = cn->v; v; v = v->next) {
+		if (v->type != CFG_STRING) {
+			log_error("preferred_names patterns must be enclosed in quotes");
+			return 0;
+		}       
+
+		count++;
+	}
+
+	if (!(scratch = dm_pool_create("preferred device name matcher", 1024)))
+		return_0;
+
+	if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count))) {
+		log_error("Failed to allocate preferred device name "
+			  "pattern list.");
+		goto out;
+	}
+
+	for (v = cn->v, i = count - 1; v; v = v->next, i--) {
+		if (!(regex[i] = dm_pool_strdup(scratch, v->v.str))) {
+			log_error("Failed to allocate a preferred device name "
+				  "pattern.");
+			goto out;
+		}
+	}
+
+	if (!(_cache.preferred_names_matcher =
+		matcher_create(_cache.mem,(const char **) regex, count))) {
+		log_error("Preferred device name pattern matcher creation failed.");
+		goto out;
+	}
+
+	r = 1;
+
+out:
+	dm_pool_destroy(scratch);
+
+	return r;
+}
+
+int dev_cache_init(struct cmd_context *cmd)
 {
 	_cache.names = NULL;
 	_cache.has_scanned = 0;
@@ -466,6 +561,9 @@
 	list_init(&_cache.dirs);
 	list_init(&_cache.files);
 
+	if (!_init_preferred_names(cmd))
+		goto_bad;
+
 	return 1;
 
       bad:
@@ -489,6 +587,9 @@
 	if (_cache.names)
 		_check_for_open_devices();
 
+	if (_cache.preferred_names_matcher)
+		_cache.preferred_names_matcher = NULL;
+
 	if (_cache.mem) {
 		dm_pool_destroy(_cache.mem);
 		_cache.mem = NULL;
--- LVM2/lib/device/dev-cache.h	2005/10/16 23:03:57	1.9
+++ LVM2/lib/device/dev-cache.h	2007/04/26 16:44:58	1.10
@@ -30,7 +30,8 @@
 /*
  * The global device cache.
  */
-int dev_cache_init(void);
+struct cmd_context;
+int dev_cache_init(struct cmd_context *cmd);
 void dev_cache_exit(void);
 
 /* Trigger(1) or avoid(0) a scan */
@@ -41,6 +42,8 @@
 int dev_cache_add_loopfile(const char *path);
 struct device *dev_cache_get(const char *name, struct dev_filter *f);
 
+void dev_set_preferred_name(struct str_list *sl, struct device *dev);
+
 /*
  * Object for iterating through the cache.
  */
--- LVM2/lib/filters/filter-persistent.c	2007/01/25 14:37:47	1.29
+++ LVM2/lib/filters/filter-persistent.c	2007/04/26 16:44:58	1.30
@@ -301,10 +301,9 @@
 	}
 	memset(pf, 0, sizeof(*pf));
 
-	if (!(pf->file = dm_malloc(strlen(file) + 1))) {
-		stack;
-		goto bad;
-	}
+	if (!(pf->file = dm_malloc(strlen(file) + 1)))
+		goto_bad;
+
 	strcpy(pf->file, file);
 	pf->real = real;
 
@@ -313,10 +312,8 @@
 		goto bad;
 	}
 
-	if (!(f = dm_malloc(sizeof(*f)))) {
-		stack;
-		goto bad;
-	}
+	if (!(f = dm_malloc(sizeof(*f))))
+		goto_bad;
 
 	f->passes_filter = _lookup_p;
 	f->destroy = _persistent_destroy;
--- LVM2/lib/filters/filter-regex.c	2006/04/19 15:33:06	1.20
+++ LVM2/lib/filters/filter-regex.c	2007/04/26 16:44:58	1.21
@@ -98,18 +98,15 @@
 	unsigned count = 0;
 	int i, r = 0;
 
-	if (!(scratch = dm_pool_create("filter matcher", 1024))) {
-		stack;
-		return 0;
-	}
+	if (!(scratch = dm_pool_create("filter matcher", 1024)))
+		return_0;
 
 	/*
 	 * count how many patterns we have.
 	 */
 	for (v = val; v; v = v->next) {
-
 		if (v->type != CFG_STRING) {
-			log_info("filter patterns must be enclosed in quotes");
+			log_error("filter patterns must be enclosed in quotes");
 			goto out;
 		}
 
@@ -119,10 +116,8 @@
 	/*
 	 * allocate space for them
 	 */
-	if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count))) {
-		stack;
-		goto out;
-	}
+	if (!(regex = dm_pool_alloc(scratch, sizeof(*regex) * count)))
+		goto_out;
 
 	/*
 	 * create the accept/reject bitset
@@ -136,7 +131,7 @@
 	 */
 	for (v = val, i = count - 1; v; v = v->next, i--)
 		if (!_extract_pattern(scratch, v->v.str, regex, rf->accept, i)) {
-			log_info("invalid filter pattern");
+			log_error("invalid filter pattern");
 			goto out;
 		}
 
@@ -164,13 +159,8 @@
 
 		if (m >= 0) {
 			if (dm_bit(rf->accept, m)) {
-
-				if (!first) {
-					log_debug("%s: New preferred name",
-						  sl->str);
-					list_del(&sl->list);
-					list_add_h(&dev->aliases, &sl->list);
-				}
+				if (!first)
+					dev_set_preferred_name(sl, dev);
 
 				return 1;
 			}
@@ -208,22 +198,16 @@
 		return NULL;
 	}
 
-	if (!(rf = dm_pool_alloc(mem, sizeof(*rf)))) {
-		stack;
-		goto bad;
-	}
+	if (!(rf = dm_pool_alloc(mem, sizeof(*rf))))
+		goto_bad;
 
 	rf->mem = mem;
 
-	if (!_build_matcher(rf, patterns)) {
-		stack;
-		goto bad;
-	}
+	if (!_build_matcher(rf, patterns))
+		goto_bad;
 
-	if (!(f = dm_pool_zalloc(mem, sizeof(*f)))) {
-		stack;
-		goto bad;
-	}
+	if (!(f = dm_pool_zalloc(mem, sizeof(*f))))
+		goto_bad;
 
 	f->passes_filter = _accept_p;
 	f->destroy = _regex_destroy;
--- LVM2/lib/filters/filter-sysfs.c	2007/01/25 14:37:47	1.14
+++ LVM2/lib/filters/filter-sysfs.c	2007/04/26 16:44:58	1.15
@@ -284,10 +284,8 @@
 		goto bad;
 	}
 
-	if (!(f = dm_pool_zalloc(mem, sizeof(*f)))) {
-		stack;
-		goto bad;
-	}
+	if (!(f = dm_pool_zalloc(mem, sizeof(*f))))
+		goto_bad;
 
 	f->passes_filter = _accept_p;
 	f->destroy = _destroy;
--- LVM2/lib/format1/disk-rep.c	2006/11/30 23:11:40	1.65
+++ LVM2/lib/format1/disk-rep.c	2007/04/26 16:44:58	1.66
@@ -357,10 +357,8 @@
 	list_init(&dl->uuids);
 	list_init(&dl->lvds);
 
-	if (!_read_pvd(dev, &dl->pvd)) {
-		stack;
-		goto bad;
-	}
+	if (!_read_pvd(dev, &dl->pvd))
+		goto_bad;
 
 	/*
 	 * is it an orphan ?
--- LVM2/lib/format1/format1.c	2006/10/19 12:53:46	1.99
+++ LVM2/lib/format1/format1.c	2007/04/26 16:44:58	1.100
@@ -131,10 +131,10 @@
 	int partial;
 
 	if (!vg)
-		goto bad;
+		goto_bad;
 
 	if (list_empty(pvs))
-		goto bad;
+		goto_bad;
 
 	memset(vg, 0, sizeof(*vg));
 
@@ -146,24 +146,24 @@
 	list_init(&vg->tags);
 
 	if (!_check_vgs(pvs, &partial))
-		goto bad;
+		goto_bad;
 
 	dl = list_item(pvs->n, struct disk_list);
 
 	if (!import_vg(mem, vg, dl, partial))
-		goto bad;
+		goto_bad;
 
 	if (!import_pvs(fid->fmt, mem, vg, pvs, &vg->pvs, &vg->pv_count))
-		goto bad;
+		goto_bad;
 
 	if (!import_lvs(mem, vg, pvs))
-		goto bad;
+		goto_bad;
 
 	if (!import_extents(fid->fmt->cmd, vg, pvs))
-		goto bad;
+		goto_bad;
 
 	if (!import_snapshots(mem, vg, pvs))
-		goto bad;
+		goto_bad;
 
 	return vg;
 
@@ -191,15 +191,11 @@
 	vg_name = strip_dir(vg_name, fid->fmt->cmd->dev_dir);
 
 	if (!read_pvs_in_vg
-	    (fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs)) {
-		stack;
-		goto bad;
-	}
+	    (fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs))
+		goto_bad;
 
-	if (!(vg = _build_vg(fid, &pvs))) {
-		stack;
-		goto bad;
-	}
+	if (!(vg = _build_vg(fid, &pvs)))
+		goto_bad;
 
       bad:
 	dm_pool_destroy(mem);
@@ -415,17 +411,14 @@
 		return 0;
 	}
 
-	if (!(dl = dm_pool_alloc(mem, sizeof(*dl)))) {
-		stack;
-		goto bad;
-	}
+	if (!(dl = dm_pool_alloc(mem, sizeof(*dl))))
+		goto_bad;
+
 	dl->mem = mem;
 	dl->dev = pv->dev;
 
-	if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv)) {
-		stack;
-		goto bad;
-	}
+	if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv))
+		goto_bad;
 
 	/* must be set to be able to zero gap after PV structure in
 	   dev_write in order to make other disk tools happy */
@@ -434,10 +427,8 @@
 	dl->pvd.pe_on_disk.base = LVM1_PE_ALIGN << SECTOR_SHIFT;
 
 	list_add(&pvs, &dl->list);
-	if (!write_disks(fmt, &pvs)) {
-		stack;
-		goto bad;
-	}
+	if (!write_disks(fmt, &pvs))
+		goto_bad;
 
 	dm_pool_destroy(mem);
 	return 1;
--- LVM2/lib/format1/import-extents.c	2007/03/15 13:38:28	1.32
+++ LVM2/lib/format1/import-extents.c	2007/04/26 16:44:58	1.33
@@ -59,22 +59,16 @@
 		if (ll->lv->status & SNAPSHOT)
 			continue;
 
-		if (!(lvm = dm_pool_alloc(mem, sizeof(*lvm)))) {
-			stack;
-			goto bad;
-		}
+		if (!(lvm = dm_pool_alloc(mem, sizeof(*lvm))))
+			goto_bad;
 
 		lvm->lv = ll->lv;
 		if (!(lvm->map = dm_pool_zalloc(mem, sizeof(*lvm->map)
-					     * ll->lv->le_count))) {
-			stack;
-			goto bad;
-		}
+					     * ll->lv->le_count)))
+			goto_bad;
 
-		if (!dm_hash_insert(maps, ll->lv->name, lvm)) {
-			stack;
-			goto bad;
-		}
+		if (!dm_hash_insert(maps, ll->lv->name, lvm))
+			goto_bad;
 	}
 
 	return maps;
--- LVM2/lib/format_text/import_vsn1.c	2006/11/30 23:11:41	1.38
+++ LVM2/lib/format_text/import_vsn1.c	2007/04/26 16:44:58	1.39
@@ -660,15 +660,11 @@
 	/* eg Set to instance of fmt1 here if reading a format1 backup? */
 	vg->fid = fid;
 
-	if (!(vg->name = dm_pool_strdup(mem, vgn->key))) {
-		stack;
-		goto bad;
-	}
+	if (!(vg->name = dm_pool_strdup(mem, vgn->key)))
+		goto_bad;
 
-	if (!(vg->system_id = dm_pool_zalloc(mem, NAME_LEN))) {
-		stack;
-		goto bad;
-	}
+	if (!(vg->system_id = dm_pool_zalloc(mem, NAME_LEN)))
+		goto_bad;
 
 	vgn = vgn->child;
 
--- LVM2/lib/log/log.h	2007/01/25 21:22:30	1.35
+++ LVM2/lib/log/log.h	2007/04/26 16:44:58	1.36
@@ -138,5 +138,6 @@
 #define return_0	do { stack; return 0; } while (0)
 #define return_NULL	do { stack; return NULL; } while (0)
 #define goto_out	do { stack; goto out; } while (0)
+#define goto_bad	do { stack; goto bad; } while (0)
 
 #endif
--- LVM2/lib/metadata/metadata.c	2007/04/25 21:10:55	1.107
+++ LVM2/lib/metadata/metadata.c	2007/04/26 16:44:59	1.108
@@ -280,10 +280,9 @@
 	vg->seqno = 0;
 
 	vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
-	if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN))) {
-		stack;
-		goto bad;
-	}
+	if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN)))
+		goto_bad;
+
 	*vg->system_id = '\0';
 
 	vg->extent_size = extent_size;
@@ -320,7 +319,7 @@
 
 	/* attach the pv's */
 	if (!vg_extend(vg->fid, vg, pv_count, pv_names))
-		goto bad;
+		goto_bad;
 
 	return vg;
 
@@ -561,10 +560,8 @@
 
 	pv->dev = dev;
 
-	if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN))) {
-		stack;
-		goto bad;
-	}
+	if (!(pv->vg_name = dm_pool_zalloc(mem, NAME_LEN)))
+		goto_bad;
 
 	pv->status = ALLOCATABLE_PV;
 
--- LVM2/lib/misc/lvm-file.c	2007/02/28 18:27:12	1.19
+++ LVM2/lib/misc/lvm-file.c	2007/04/26 16:44:59	1.20
@@ -273,8 +273,12 @@
 	if ((c = strrchr(dir, '/')))
 		*c = '\0';
 
-	if (!create_dir(dir))
+	if (!create_dir(dir)) {
+		dm_free(dir);
 		return -1;
+	}
+
+	dm_free(dir);
 
 	log_very_verbose("Locking %s (%s, %hd)", file,
 			 (lock_type == F_WRLCK) ? "F_WRLCK" : "F_RDLCK",
--- LVM2/lib/regex/matcher.c	2006/05/09 21:23:50	1.15
+++ LVM2/lib/regex/matcher.c	2007/04/26 16:44:59	1.16
@@ -273,15 +273,12 @@
 	struct dm_pool *scratch = dm_pool_create("regex matcher", 10 * 1024);
 	struct matcher *m;
 
-	if (!scratch) {
-		stack;
-		return NULL;
-	}
+	if (!scratch)
+		return_NULL;
 
 	if (!(m = dm_pool_alloc(mem, sizeof(*m)))) {
-		stack;
 		dm_pool_destroy(scratch);
-		return NULL;
+		return_NULL;
 	}
 
 	memset(m, 0, sizeof(*m));
@@ -292,10 +289,8 @@
 
 	ptr = all = dm_pool_alloc(scratch, len + 1);
 
-	if (!all) {
-		stack;
-		goto bad;
-	}
+	if (!all)
+		goto_bad;
 
 	for (i = 0; i < num; i++) {
 		ptr += sprintf(ptr, "(.*(%s)%c)", patterns[i], TARGET_TRANS);
@@ -314,10 +309,8 @@
 	m->num_nodes = _count_nodes(rx);
 	m->nodes = dm_pool_alloc(scratch, sizeof(*m->nodes) * m->num_nodes);
 
-	if (!m->nodes) {
-		stack;
-		goto bad;
-	}
+	if (!m->nodes)
+		goto_bad;
 
 	_fill_table(m, rx);
 	_create_bitsets(m);
@@ -330,7 +323,7 @@
 
       bad:
 	dm_pool_destroy(scratch);
-	dm_pool_destroy(mem);
+	dm_pool_free(mem, m);
 	return NULL;
 }
 
--- LVM2/tools/lvmcmdline.c	2007/02/14 16:51:48	1.41
+++ LVM2/tools/lvmcmdline.c	2007/04/26 16:44:59	1.42
@@ -827,30 +827,30 @@
 	 * description for backups.
 	 */
 	if (!dm_pool_begin_object(cmd->mem, 128))
-		goto bad;
+		goto_bad;
 
 	for (i = 0; i < argc; i++) {
 		space = strchr(argv[i], ' ') ? 1 : 0;
 
 		if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
-			goto bad;
+			goto_bad;
 
 		if (!dm_pool_grow_object(cmd->mem, argv[i], strlen(argv[i])))
-			goto bad;
+			goto_bad;
 
 		if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
-			goto bad;
+			goto_bad;
 
 		if (i < (argc - 1))
 			if (!dm_pool_grow_object(cmd->mem, " ", 1))
-				goto bad;
+				goto_bad;
 	}
 
 	/*
 	 * Terminate.
 	 */
 	if (!dm_pool_grow_object(cmd->mem, "\0", 1))
-		goto bad;
+		goto_bad;
 
 	return dm_pool_end_object(cmd->mem);
 


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

* LVM2 ./WHATS_NEW doc/example.conf lib/activate ...
@ 2007-01-25 21:22 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-01-25 21:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-01-25 21:22:30

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/activate   : activate.h dev_manager.c 
	lib/commands   : toolcontext.c 
	lib/config     : defaults.h 
	lib/filters    : filter.c 
	lib/log        : log.c log.h 

Log message:
	Add devices/ignore_suspended_devices to ignore suspended dm devices.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.558&r2=1.559
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.34&r2=1.35

--- LVM2/WHATS_NEW	2007/01/25 14:37:46	1.558
+++ LVM2/WHATS_NEW	2007/01/25 21:22:29	1.559
@@ -1,5 +1,6 @@
 Version 2.02.20 -
 ===================================
+  Add devices/ignore_suspended_devices to ignore suspended dm devices.
   Add some missing close() and fclose() return code checks.
   Fix exit statuses of reporting tools (2.02.19).
   Add init script for dmeventd monitoring.
--- LVM2/doc/example.conf	2006/09/02 01:18:17	1.27
+++ LVM2/doc/example.conf	2007/01/25 21:22:30	1.28
@@ -79,6 +79,12 @@
     # software RAID (md) devices by looking for md superblocks.
     # 1 enables; 0 disables.
     md_component_detection = 1
+
+    # If, while scanning the system for PVs, LVM2 encounters a device-mapper
+    # device that has its I/O suspended, it waits for it to become accessible.
+    # Set this to 1 to skip such devices.  This should only be needed
+    # in recovery situations.
+    ignore_suspended_devices = 0
 }
 
 # This section that allows you to configure the nature of the
--- LVM2/lib/activate/activate.h	2007/01/19 22:21:45	1.53
+++ LVM2/lib/activate/activate.h	2007/01/25 21:22:30	1.54
@@ -95,4 +95,9 @@
 int pv_uses_vg(struct physical_volume *pv,
 	       struct volume_group *vg);
 
+/*
+ * Returns 1 if mapped device is not suspended.
+ */
+int device_is_usable(dev_t dev);
+
 #endif
--- LVM2/lib/activate/dev_manager.c	2007/01/09 20:31:08	1.118
+++ LVM2/lib/activate/dev_manager.c	2007/01/25 21:22:30	1.119
@@ -25,6 +25,7 @@
 #include "targets.h"
 #include "config.h"
 #include "filter.h"
+#include "activate.h"
 
 #include <limits.h>
 #include <dirent.h>
@@ -154,6 +155,42 @@
 	return r;
 }
 
+int device_is_usable(dev_t dev)
+{
+	struct dm_task *dmt;
+	struct dm_info info;
+	int r = 0;
+
+	if (!(dmt = dm_task_create(DM_DEVICE_INFO))) {
+		log_error("Failed to allocate dm_task struct to check dev status");
+		return 0;
+	}
+
+	if (!dm_task_set_major(dmt, MAJOR(dev)) || !dm_task_set_minor(dmt, MINOR(dev)))
+		goto_out;
+
+	if (!dm_task_run(dmt)) {
+		log_error("Failed to get state of mapped device");
+		goto out;
+	}
+
+	if (!dm_task_get_info(dmt, &info))
+		goto_out;
+
+	if (!info.exists || info.suspended)
+		goto out;
+
+	/* FIXME Also check for mirror block_on_error and mpath no paths */
+
+	/* FIXME Also check dependencies? */
+
+	r = 1;
+
+      out:
+	dm_task_destroy(dmt);
+	return r;
+}
+
 static int _info(const char *name, const char *dlid, int mknodes,
 		 int with_open_count, struct dm_info *info,
 		 struct dm_pool *mem, char **uuid_out)
--- LVM2/lib/commands/toolcontext.c	2007/01/25 14:37:47	1.46
+++ LVM2/lib/commands/toolcontext.c	2007/01/25 21:22:30	1.47
@@ -592,6 +592,9 @@
 		return 0;
 	}
 
+	init_ignore_suspended_devices(find_config_tree_int(cmd,
+	    "devices/ignore_suspended_devices", DEFAULT_IGNORE_SUSPENDED_DEVICES));
+
 	dev_cache = find_config_tree_str(cmd, "devices/cache",
 				    cache_file);
 	if (!(f4 = persistent_filter_create(f3, dev_cache))) {
--- LVM2/lib/config/defaults.h	2006/09/02 01:18:17	1.29
+++ LVM2/lib/config/defaults.h	2007/01/25 21:22:30	1.30
@@ -30,6 +30,7 @@
 #define DEFAULT_PROC_DIR "/proc"
 #define DEFAULT_SYSFS_SCAN 1
 #define DEFAULT_MD_COMPONENT_DETECTION 1
+#define DEFAULT_IGNORE_SUSPENDED_DEVICES 1
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
 #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
--- LVM2/lib/filters/filter.c	2007/01/25 14:37:47	1.37
+++ LVM2/lib/filters/filter.c	2007/01/25 21:22:30	1.38
@@ -19,6 +19,7 @@
 #include "lvm-string.h"
 #include "config.h"
 #include "metadata.h"
+#include "activate.h"
 
 #include <dirent.h>
 #include <unistd.h>
@@ -37,6 +38,7 @@
 } device_info_t;
 
 static int _md_major = -1;
+static int _device_mapper_major = -1;
 
 int md_major(void)
 {
@@ -90,6 +92,13 @@
 		return 0;
 	}
 
+	/* Skip suspended devices */
+	if (MAJOR(dev->dev) == _device_mapper_major &&
+	    ignore_suspended_devices() && device_is_usable(dev->dev)) {
+		log_debug("%s: Skipping: Suspended dm device", name);
+		return 0;
+	}
+
 	/* Check it's accessible */
 	if (!dev_open_flags(dev, O_RDONLY, 0, 1)) {
 		log_debug("%s: Skipping: open failed", name);
@@ -182,10 +191,14 @@
 		if (!strncmp("md", line + i, 2) && isspace(*(line + i + 2)))
 			_md_major = line_maj;
 
+		/* Look for device-mapper device */
+		/* FIXME Cope with multiple majors */
+		if (!strncmp("device-mapper", line + i, 13) && isspace(*(line + i + 13)))
+			_device_mapper_major = line_maj;
+
 		/* Go through the valid device names and if there is a
 		   match store max number of partitions */
 		for (j = 0; device_info[j].name != NULL; j++) {
-
 			dev_len = strlen(device_info[j].name);
 			if (dev_len <= strlen(line + i) &&
 			    !strncmp(device_info[j].name, line + i, dev_len) &&
--- LVM2/lib/log/log.c	2007/01/25 14:37:48	1.37
+++ LVM2/lib/log/log.c	2007/01/25 21:22:30	1.38
@@ -49,6 +49,7 @@
 static int _already_logging = 0;
 static int _mirror_in_sync = 0;
 static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
+static int _ignore_suspended_devices = 0;
 
 static lvm2_log_fn_t _lvm2_log_fn = NULL;
 
@@ -195,6 +196,11 @@
 	_dmeventd_monitor = reg;
 }
 
+void init_ignore_suspended_devices(int ignore)
+{
+	_ignore_suspended_devices = ignore;
+}
+
 void init_cmd_name(int status)
 {
 	_log_cmd_name = status;
@@ -274,6 +280,11 @@
 	return _dmeventd_monitor;
 }
 
+int ignore_suspended_devices(void)
+{
+	return _ignore_suspended_devices;
+}
+
 void init_debug(int level)
 {
 	_debug_level = level;
--- LVM2/lib/log/log.h	2007/01/24 23:43:27	1.34
+++ LVM2/lib/log/log.h	2007/01/25 21:22:30	1.35
@@ -76,6 +76,7 @@
 void init_security_level(int level);
 void init_mirror_in_sync(int in_sync);
 void init_dmeventd_monitor(int reg);
+void init_ignore_suspended_devices(int ignore);
 
 void set_cmd_name(const char *cmd_name);
 
@@ -90,6 +91,7 @@
 int lockingfailed(void);
 int security_level(void);
 int mirror_in_sync(void);
+int ignore_suspended_devices(void);
 
 #define DMEVENTD_MONITOR_IGNORE -1
 int dmeventd_monitor_mode(void);


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

* LVM2 ./WHATS_NEW doc/example.conf lib/activate ...
@ 2006-05-11 17:58 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2006-05-11 17:58 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-05-11 17:58:58

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/activate   : activate.c activate.h dev_manager.c 
	                 dev_manager.h 
	lib/cache      : lvmcache.c 
	lib/device     : device.c 
	lib/error      : errseg.c 
	lib/format_text: export.c format-text.c format-text.h import.c 
	                 text_label.c 
	lib/locking    : file_locking.c locking.c 
	lib/metadata   : lv_manip.c metadata.c 
	lib/mirror     : mirrored.c 
	lib/report     : report.c 
	lib/snapshot   : snapshot.c 
	lib/striped    : striped.c 
	tools          : vgmerge.c 

Log message:
	Add mirror_library description to example.conf.
	More compile-time cleanup.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.378&r2=1.379
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/error/errseg.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.h.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/text_label.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/striped/striped.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32


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

end of thread, other threads:[~2010-03-05 14:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-04 15:36 LVM2 ./WHATS_NEW doc/example.conf lib/activate agk
  -- strict thread matches above, loose matches on Subject: below --
2010-03-05 14:48 zkabelac
2007-04-26 16:45 agk
2007-01-25 21:22 agk
2006-05-11 17:58 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).