public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2012-02-08 12:59 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2012-02-08 12:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-08 12:59:20

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Use dm_asprintf to simplify code

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.541&r2=1.542
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134

--- LVM2/WHATS_NEW_DM	2012/02/08 11:25:09	1.541
+++ LVM2/WHATS_NEW_DM	2012/02/08 12:59:19	1.542
@@ -1,5 +1,6 @@
 Version 1.02.70 - 
 ===================================
+  Simplify dm_task_set_geometry() and use dm_asprintf().
   Set all parameters to 0 for dm_get_next_target() for NULL return.
   Fix fd resource leak in error path for _udev_notify_sem_create().
   Leave space for '\0' for readline() call in _sysfs_get_kernel_name().
--- LVM2/libdm/ioctl/libdm-iface.c	2012/02/08 11:25:10	1.133
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/02/08 12:59:20	1.134
@@ -769,16 +769,11 @@
 	return 1;
 }
 
-int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start)
+int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads,
+			 const char *sectors, const char *start)
 {
-	size_t len = strlen(cylinders) + 1 + strlen(heads) + 1 + strlen(sectors) + 1 + strlen(start) + 1;
-
-	if (!(dmt->geometry = dm_malloc(len))) {
-		log_error("dm_task_set_geometry: dm_malloc failed");
-		return 0;
-	}
-
-	if (sprintf(dmt->geometry, "%s %s %s %s", cylinders, heads, sectors, start) < 0) {
+	if (dm_asprintf(&(dmt->geometry), "%s %s %s %s",
+			cylinders, heads, sectors, start) < 0) {
 		log_error("dm_task_set_geometry: sprintf failed");
 		return 0;
 	}


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2012-03-01 10:07 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2012-03-01 10:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-01 10:07:39

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Check for version string buffer
	
	Since lvm seems to call driver_version(NULL, 0)  this would lead
	to crash. Though the combination of the code is probably very hard to hit.
	If the user doesn't supply version buffer, just skip printing to buffer.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.577&r2=1.578
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139

--- LVM2/WHATS_NEW_DM	2012/03/01 09:50:04	1.577
+++ LVM2/WHATS_NEW_DM	2012/03/01 10:07:38	1.578
@@ -1,5 +1,6 @@
 Version 1.02.73 - 
 ====================================
+  Support dm_task_get_driver_version() query without version string.
   Log failure of pthread_join when cleaning unused threads in dmeventd.
   Fix empty string warning logic in _find_config_str. (1.02.68)
   Fix dm_task_set_name to properly resolve path to dm name (1.02.71).
--- LVM2/libdm/ioctl/libdm-iface.c	2012/02/15 12:17:34	1.138
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/03/01 10:07:38	1.139
@@ -467,14 +467,21 @@
 	unsigned *v;
 
 	if (!dmt->dmi.v4) {
-		version[0] = '\0';
+		if (version)
+			version[0] = '\0';
 		return 0;
 	}
 
 	v = dmt->dmi.v4->version;
-	snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]);
 	_dm_version_minor = v[1];
 	_dm_version_patchlevel = v[2];
+	if (version &&
+	    (snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]) < 0)) {
+		log_error("Buffer for version is to short.");
+		if (size > 0)
+			version[0] = '\0'
+		return 0;
+	}
 
 	return 1;
 }
@@ -494,7 +501,8 @@
 		_log_suppress = 1;
 
 	r = dm_task_run(task);
-	dm_task_get_driver_version(task, version, size);
+	if (!dm_task_get_driver_version(task, version, size))
+		stack;
 	dm_task_destroy(task);
 	_log_suppress = 0;
 


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2012-02-15 12:17 prajnoha
  0 siblings, 0 replies; 17+ messages in thread
From: prajnoha @ 2012-02-15 12:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-02-15 12:17:35

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Replace any '\' char with '\\' in table specification on input.
	
	Device-mapper in kernel uses '\' as escape character so it's better
	to double it to avoid any confusion when using existing device names
	with '\' in the table specification.
	
	For example:
	
	dmsetup create x --table "0 8 linear /dev/mapper/a\x20b 0"
	
	should pass just fine now without a need to explicitly escape the '\' char
	like this:
	
	dmsetup create x --table "0 8 linear /dev/mapper/a\\x20b 0"

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.563&r2=1.564
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138

--- LVM2/WHATS_NEW_DM	2012/02/15 12:08:57	1.563
+++ LVM2/WHATS_NEW_DM	2012/02/15 12:17:34	1.564
@@ -1,5 +1,6 @@
 Version 1.02.71 - 
 ====================================
+  Replace any '\' char with '\\' in table specification on input.
   Add mangle command to dmsetup to provide renaming to correct mangled form.
   Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.
   Add --manglename option to dmsetup to select the name mangling mode.
--- LVM2/libdm/ioctl/libdm-iface.c	2012/02/15 12:01:28	1.137
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/02/15 12:17:34	1.138
@@ -866,7 +866,9 @@
 	char *out_sp = out;
 	struct dm_target_spec sp;
 	size_t sp_size = sizeof(struct dm_target_spec);
+	unsigned int backslash_count = 0;
 	int len;
+	char *pt;
 
 	if (strlen(t->type) >= sizeof(sp.target_type)) {
 		log_error("Target type name %s is too long.", t->type);
@@ -880,15 +882,32 @@
 	sp.target_type[sizeof(sp.target_type) - 1] = '\0';
 
 	out += sp_size;
-	len = strlen(t->params);
+	pt = t->params;
+
+	while (*pt)
+		if (*pt++ == '\\')
+			backslash_count++;
+	len = strlen(t->params) + backslash_count;
 
 	if ((out >= end) || (out + len + 1) >= end) {
 		log_error("Ran out of memory building ioctl parameter");
 		return NULL;
 	}
 
-	strcpy(out, t->params);
-	out += len + 1;
+	if (backslash_count) {
+		/* replace "\" with "\\" */
+		pt = t->params;
+		do {
+			if (*pt == '\\')
+				*out++ = '\\';
+			*out++ = *pt++;
+		} while (*pt);
+		*out++ = '\0';
+	}
+	else {
+		strcpy(out, t->params);
+		out += len + 1;
+	}
 
 	/* align next block */
 	out = _align(out, ALIGNMENT);


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2012-02-08 11:25 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2012-02-08 11:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-08 11:25:10

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Set all parameters to 0
	
	Since the function dm_get_next_target() returns NULL as 'next' pointer
	so it's not a 'real' error - set 0 to all parameters when NULL is
	returned because of missing head.
	
	i.e. one of use case::
	do {
	next = dm_get_next_target(dmt, next, &start, &length,
	&target_type, &params);
	size += length;
	} while (next);

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.540&r2=1.541
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133

--- LVM2/WHATS_NEW_DM	2012/02/08 11:07:17	1.540
+++ LVM2/WHATS_NEW_DM	2012/02/08 11:25:09	1.541
@@ -1,5 +1,6 @@
 Version 1.02.70 - 
 ===================================
+  Set all parameters to 0 for dm_get_next_target() for NULL return.
   Fix fd resource leak in error path for _udev_notify_sem_create().
   Leave space for '\0' for readline() call in _sysfs_get_kernel_name().
 
--- LVM2/libdm/ioctl/libdm-iface.c	2012/01/17 14:36:59	1.132
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/02/08 11:25:10	1.133
@@ -573,8 +573,13 @@
 	if (!t)
 		t = dmt->head;
 
-	if (!t)
+	if (!t) {
+		*start = 0;
+		*length = 0;
+		*target_type = 0;
+		*params = 0;
 		return NULL;
+	}
 
 	*start = t->start;
 	*length = t->length;


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-11-08 17:32 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2011-11-08 17:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2011-11-08 17:32:11

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix _get_proc_number to be tolerant of malformed /proc/misc entries.
	
	Fixes issue reported here: http://lkml.org/lkml/2011/11/8/190

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.520&r2=1.521
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127

--- LVM2/WHATS_NEW_DM	2011/10/31 12:22:49	1.520
+++ LVM2/WHATS_NEW_DM	2011/11/08 17:32:10	1.521
@@ -1,5 +1,6 @@
 Version 1.02.68 -
 ==================================
+  Fix _get_proc_number to be tolerant of malformed /proc/misc entries.
   Add ExecReload to dm-event.service for systemd to reload dmeventd properly.
   Add dm_config_tree_find_str_allow_empty.
   Fix compile-time pool memory locking with DEBUG_MEM.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/10/20 10:38:04	1.126
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/11/08 17:32:11	1.127
@@ -172,7 +172,8 @@
 {
 	FILE *fl;
 	char nm[256];
-	int c;
+	char *line;
+	size_t len;
 	uint32_t num;
 
 	if (!(fl = fopen(file, "r"))) {
@@ -180,8 +181,8 @@
 		return 0;
 	}
 
-	while (!feof(fl)) {
-		if (fscanf(fl, "%d %255s\n", &num, &nm[0]) == 2) {
+	while (getline(&line, &len, fl) != -1) {
+		if (sscanf(line, "%d %255s\n", &num, &nm[0]) == 2) {
 			if (!strcmp(name, nm)) {
 				if (number) {
 					*number = num;
@@ -191,9 +192,7 @@
 				}
 				dm_bit_set(_dm_bitset, num);
 			}
-		} else do {
-			c = fgetc(fl);
-		} while (c != EOF && c != '\n');
+		}
 	}
 	if (fclose(fl))
 		log_sys_error("fclose", file);


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-10-20 10:38 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2011-10-20 10:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-20 10:38:04

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Cleanup backtraces
	
	Make sure stacks are at the right places when something goes wrong here.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.511&r2=1.512
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126

--- LVM2/WHATS_NEW_DM	2011/10/17 13:15:35	1.511
+++ LVM2/WHATS_NEW_DM	2011/10/20 10:38:04	1.512
@@ -1,5 +1,6 @@
 Version 1.02.68 -
 ==================================
+  Cleanup backtraces for _create_and_load_v4().
   Fix alignment warning in bitcount calculation for raid segment.
   Allocate dm_tree structure from dm_tree pool.
   Update debug logging for _resume_node.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/10/19 16:36:02	1.125
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/10/20 10:38:04	1.126
@@ -1250,23 +1250,16 @@
 
 	/* Use new task struct to create the device */
 	if (!(task = dm_task_create(DM_DEVICE_CREATE))) {
-		log_error("Failed to create device-mapper task struct");
 		_udev_complete(dmt);
-		return 0;
+		return_0;
 	}
 
 	/* Copy across relevant fields */
-	if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) {
-		dm_task_destroy(task);
-		_udev_complete(dmt);
-		return 0;
-	}
+	if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name))
+		goto_bad;
 
-	if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid)) {
-		dm_task_destroy(task);
-		_udev_complete(dmt);
-		return 0;
-	}
+	if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid))
+		goto_bad;
 
 	task->major = dmt->major;
 	task->minor = dmt->minor;
@@ -1278,26 +1271,23 @@
 	task->cookie_set = dmt->cookie_set;
 	task->add_node = dmt->add_node;
 
-	r = dm_task_run(task);
+	if (!dm_task_run(task))
+		goto_bad;
+
 	dm_task_destroy(task);
-	if (!r) {
-		_udev_complete(dmt);
-		return 0;
-	}
 
 	/* Next load the table */
 	if (!(task = dm_task_create(DM_DEVICE_RELOAD))) {
-		log_error("Failed to create device-mapper task struct");
+		stack;
 		_udev_complete(dmt);
-		r = 0;
 		goto revert;
 	}
 
 	/* Copy across relevant fields */
 	if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) {
+		stack;
 		dm_task_destroy(task);
 		_udev_complete(dmt);
-		r = 0;
 		goto revert;
 	}
 
@@ -1311,7 +1301,9 @@
 	task->head = NULL;
 	task->tail = NULL;
 	dm_task_destroy(task);
+
 	if (!r) {
+		stack;
 		_udev_complete(dmt);
 		goto revert;
 	}
@@ -1321,13 +1313,11 @@
 	dm_free(dmt->uuid);
 	dmt->uuid = NULL;
 
-	r = dm_task_run(dmt);
-
-	if (r)
-		return r;
+	if (dm_task_run(dmt))
+		return 1;
 
       revert:
- 	dmt->type = DM_DEVICE_REMOVE;
+	dmt->type = DM_DEVICE_REMOVE;
 	dm_free(dmt->uuid);
 	dmt->uuid = NULL;
 
@@ -1347,7 +1337,13 @@
 	if (!dm_task_run(dmt))
 		log_error("Failed to revert device creation.");
 
-	return r;
+	return 0;
+
+      bad:
+	dm_task_destroy(task);
+	_udev_complete(dmt);
+
+	return 0;
 }
 
 uint64_t dm_task_get_existing_table_size(struct dm_task *dmt)
@@ -1720,7 +1716,7 @@
 
 	if (!_open_control()) {
 		_udev_complete(dmt);
-		return 0;
+		return_0;
 	}
 
 	if ((suspended_counter = dm_get_suspended_counter()) &&


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-09-13 15:13 prajnoha
  0 siblings, 0 replies; 17+ messages in thread
From: prajnoha @ 2011-09-13 15:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-09-13 15:13:41

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Retry DM_DEVICE_REMOVE ioctl if device is busy.
	
	This is a workaround for long-lasting problem with using the WATCH udev
	rule. When trying to remove a DM device, this one can still be opened
	while processing the event in parallel (generated based on the WATCH
	udev rule).
	
	Let's use this until we have a proper solution.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.498&r2=1.499
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120

--- LVM2/WHATS_NEW_DM	2011/09/07 08:37:48	1.498
+++ LVM2/WHATS_NEW_DM	2011/09/13 15:13:41	1.499
@@ -1,5 +1,6 @@
 Version 1.02.68 -
 ==================================
+  Retry DM_DEVICE_REMOVE ioctl if device is busy.
   Remove unused passed parameters for _mirror_emit_segment_line().
   Add dm_config and string character escaping functions to libdevmapper.
   Mark unreleased memory pools as internal error.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/08/19 17:02:48	1.119
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/09/13 15:13:41	1.120
@@ -1539,11 +1539,14 @@
 	return sanitised_message;
 }
 
+#define DM_REMOVE_IOCTL_RETRIES 25
+
 static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
 				     unsigned repeat_count)
 {
 	struct dm_ioctl *dmi;
 	int ioctl_with_uevent;
+	int retries = DM_REMOVE_IOCTL_RETRIES;
 
 	dmi = _flatten(dmt, repeat_count);
 	if (!dmi) {
@@ -1627,11 +1630,23 @@
 		  dmt->sector, _sanitise_message(dmt->message),
 		  dmi->data_size);
 #ifdef DM_IOCTLS
+repeat_dm_ioctl:
 	if (ioctl(_control_fd, command, dmi) < 0) {
 		if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
 				       (dmt->type == DM_DEVICE_MKNODES) ||
 				       (dmt->type == DM_DEVICE_STATUS)))
 			dmi->flags &= ~DM_EXISTS_FLAG;	/* FIXME */
+		/*
+		 * FIXME: This is a workaround for asynchronous events generated
+		 *        as a result of using the WATCH udev rule with which we
+		 *        have no way of synchronizing. Processing such events in
+		 *        parallel causes devices to be open.
+		 */
+		else if (errno == EBUSY && (dmt->type == DM_DEVICE_REMOVE) && retries--) {
+			log_debug("device-mapper: device is busy, retrying removal");
+			usleep(200000);
+			goto repeat_dm_ioctl;
+		}
 		else {
 			if (_log_suppress)
 				log_verbose("device-mapper: %s ioctl "


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-08-11 20:49 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2011-08-11 20:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-08-11 20:49:33

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix memleak of geometry buffer
	
	Looks like this function is not used too often - thus leak was discovered
	by static analyzis (Coverity).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.489&r2=1.490
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116

--- LVM2/WHATS_NEW_DM	2011/08/11 17:29:04	1.489
+++ LVM2/WHATS_NEW_DM	2011/08/11 20:49:33	1.490
@@ -1,5 +1,6 @@
 Version 1.02.66 - 
 ===============================
+  Release geometry buffer in dm_task_destroy.
   Add memory pool locking functions to aid debuging of shared VG structs.
   Remove dev name prefix from dmsetup line output if major and minor is used.
   Remove support for the original version 1 dm ioctls.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/08/09 17:56:48	1.115
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/08/11 20:49:33	1.116
@@ -451,6 +451,7 @@
 	dm_free(dmt->dev_name);
 	dm_free(dmt->newname);
 	dm_free(dmt->message);
+	dm_free(dmt->geometry);
 	dm_free(dmt->uuid);
 	dm_free(dmt);
 }


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-07-24 23:59 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2011-07-24 23:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-07-24 23:59:03

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix read-only identical table reload supression.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.481&r2=1.482
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114

--- LVM2/WHATS_NEW_DM	2011/07/08 19:57:33	1.481
+++ LVM2/WHATS_NEW_DM	2011/07/24 23:59:03	1.482
@@ -1,5 +1,6 @@
 Version 1.02.66 - 
 ===============================
+  Fix read-only identical table reload supression.
 
 Version 1.02.65 - 8th July 2011
 ===============================
--- LVM2/libdm/ioctl/libdm-iface.c	2011/07/02 01:17:10	1.113
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/07/24 23:59:03	1.114
@@ -1848,7 +1848,7 @@
 		t2 = t2->next;
 	dmt->existing_table_size = t2 ? t2->start + t2->length : 0;
 
-	if ((task->dmi.v4->flags & DM_READONLY_FLAG) ? 1 : 0 != dmt->read_only)
+	if (((task->dmi.v4->flags & DM_READONLY_FLAG) ? 1 : 0) != dmt->read_only)
 		goto no_match;
 
 	t1 = dmt->head;


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-07-02  1:17 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2011-07-02  1:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-07-02 01:17:10

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Report internal error if suspending a device using an already-suspended dev.
	This catches the recent pvmove problem trapping I/O between layers.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.477&r2=1.478
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113

--- LVM2/WHATS_NEW_DM	2011/07/01 14:09:19	1.477
+++ LVM2/WHATS_NEW_DM	2011/07/02 01:17:09	1.478
@@ -1,5 +1,6 @@
 Version 1.02.65 - 
 ==================================
+  Report internal error if suspending a device using an already-suspended dev.
   Add dmsetup --checks and dm_task_enable_checks framework to validate ioctls.
   Add age_in_minutes parameter to dmsetup udevcomplete_all.
   Return immediately from dm_lib_exit() if called more than once.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/07/01 14:09:20	1.112
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/07/02 01:17:10	1.113
@@ -1884,13 +1884,104 @@
 	return r;
 }
 
-static int _suspend_with_validation_v4(struct dm_task *dmt)
+static int _check_children_not_suspended_v4(struct dm_task *dmt, uint64_t device)
 {
+	struct dm_task *task;
+	struct dm_info info;
+	struct dm_deps *deps;
+	int r = 0;
+	uint32_t i;
+
+	/* Find dependencies */
+	if (!(task = dm_task_create(DM_DEVICE_DEPS)))
+		return 0;
+
+	/* Copy across or set relevant fields */
+	if (device) {
+		task->major = MAJOR(device);
+		task->minor = MINOR(device);
+	} else {
+		if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name))
+			goto out;
+
+		if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid))
+			goto out;
+
+		task->major = dmt->major;
+		task->minor = dmt->minor;
+	}
+
+	task->uid = dmt->uid;
+	task->gid = dmt->gid;
+	task->mode = dmt->mode;
+	/* FIXME: Just for udev_check in dm_task_run. Can we avoid this? */
+	task->event_nr = dmt->event_nr & DM_UDEV_FLAGS_MASK;
+	task->cookie_set = dmt->cookie_set;
+	task->add_node = dmt->add_node;
+	
+	if (!(r = dm_task_run(task)))
+		goto out;
+
+	if (!dm_task_get_info(task, &info) || !info.exists)
+		goto out;
+
 	/*
-	 * FIXME Ensure we can't leave any I/O trapped between suspended devices.
+	 * Warn if any of the devices this device depends upon are already
+	 * suspended: I/O could become trapped between the two devices.
 	 */
+	if (info.suspended) {
+		if (!device)
+			log_debug("Attempting to suspend a device that is already suspended "
+				  "(%u:%u)", info.major, info.minor);
+		else
+			log_error(INTERNAL_ERROR "Attempt to suspend device %s%s%s%.0d%s%.0d%s%s"
+				  "that uses already-suspended device (%u:%u)", 
+				  dmt->dev_name ? : "", dmt->uuid ? : "", 
+				  dmt->major > 0 ? "(" : "",
+				  dmt->major > 0 ? dmt->major : 0,
+				  dmt->major > 0 ? ":" : "",
+				  dmt->minor > 0 ? dmt->minor : 0,
+				  dmt->major > 0 && dmt->minor == 0 ? "0" : "",
+				  dmt->major > 0 ? ") " : "",
+				  info.major, info.minor);
+
+		/* No need for further recursion */
+		r = 1;
+		goto out;
+	}
+
+        if (!(deps = dm_task_get_deps(task)))
+                goto out;
+
+	for (i = 0; i < deps->count; i++) {
+		/* Only recurse with dm devices */
+		if (MAJOR(deps->device[i]) != _dm_device_major)
+			continue;
+
+		if (!_check_children_not_suspended_v4(task, deps->device[i]))
+			goto out;
+	}
+
+	r = 1;
+
+out:
+	dm_task_destroy(task);
+
+	return r;
+}
+
+static int _suspend_with_validation_v4(struct dm_task *dmt)
+{
+	/* Avoid recursion */
 	dmt->enable_checks = 0;
-	
+
+	/*
+	 * Ensure we can't leave any I/O trapped between suspended devices.
+	 */
+	if (!_check_children_not_suspended_v4(dmt, 0))
+		return 0;
+
+	/* Finally, perform the original suspend. */
 	return dm_task_run(dmt);
 }
 


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-06-09 15:07 mbroz
  0 siblings, 0 replies; 17+ messages in thread
From: mbroz @ 2011-06-09 15:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-06-09 15:07:41

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Accept kernel version 3 (3.0-rc and similar).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.468&r2=1.469
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104

--- LVM2/WHATS_NEW_DM	2011/04/29 19:05:11	1.468
+++ LVM2/WHATS_NEW_DM	2011/06/09 15:07:40	1.469
@@ -1,5 +1,6 @@
 Version 1.02.65 - 
 ==================================
+  Accept new kernel version 3 formats in initialisation.
 
 Version 1.02.64 - 29th April 2011
 ==================================
--- LVM2/libdm/ioctl/libdm-iface.c	2011/03/25 23:50:35	1.103
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/06/09 15:07:40	1.104
@@ -73,9 +73,9 @@
 static unsigned _dm_version_patchlevel = 0;
 static int _log_suppress = 0;
 
-static int _kernel_major;
-static int _kernel_minor;
-static int _kernel_release;
+static int _kernel_major = 0;
+static int _kernel_minor = 0;
+static int _kernel_release = 0;
 
 /*
  * If the kernel dm driver only supports one major number
@@ -152,6 +152,7 @@
 {
 	static int _uts_set = 0;
 	struct utsname _uts;
+	int parts;
 
 	if (_uts_set)
 		return 1;
@@ -160,10 +161,14 @@
 		log_error("uname failed: %s", strerror(errno));
 		return 0;
 	}
-	if (sscanf(_uts.release, "%d.%d.%d",
+
+	parts = sscanf(_uts.release, "%d.%d.%d",
 			&_kernel_major,
 			&_kernel_minor,
-			&_kernel_release) != 3) {
+			&_kernel_release);
+
+	/* Kernels with a major number of 2 always had 3 parts. */
+	if (parts < 1 || (_kernel_major < 3 && parts < 3)) {
 		log_error("Could not determine kernel version used.");
 		return 0;
 	}


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-03-25 23:50 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2011-03-25 23:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-03-25 23:50:35

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Use hard-coded /dev/mapper/control details for 2.6.36+ kernels and simplify
	associated code.  (Some obscure configurations that happened to work before
	are no longer supported.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.457&r2=1.458
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103

--- LVM2/WHATS_NEW_DM	2011/03/18 13:21:03	1.457
+++ LVM2/WHATS_NEW_DM	2011/03/25 23:50:35	1.458
@@ -1,5 +1,7 @@
 Version 1.02.64 - 
 ===================================
+  Streamline /dev/mapper/control node code for common cases.
+  Use hard-coded dm control node device number for 2.6.36 kernels and above.
   Improve stack debug reporting in dm_task_create().
   Fallback to control node creation only if node doesn't exist yet.
   Change dm_hash API for binary data to accept const void *key.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/03/20 02:00:52	1.102
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/03/25 23:50:35	1.103
@@ -228,7 +228,7 @@
 }
 
 /*
- * Returns 1 if exists; 0 if it doesn't; -1 if it's wrong
+ * Returns 1 if it exists on returning; 0 if it doesn't; -1 if it's wrong.
  */
 static int _control_exists(const char *control, uint32_t major, uint32_t minor)
 {
@@ -267,8 +267,15 @@
 	int ret;
 	mode_t old_umask;
 
-	if (!major)
-		return 0;
+	/*
+	 * Return if the control already exists with intended major/minor
+	 * or there's an error unlinking an apparently incorrect one.
+	 */
+	ret = _control_exists(control, major, minor);
+	if (ret == -1)
+		return 0;	/* Failed to unlink existing incorrect node */
+	if (ret)
+		return 1;	/* Already exists and correct */
 
 	(void) dm_prepare_selinux_context(dm_dir(), S_IFDIR);
 	old_umask = umask(DM_DEV_DIR_UMASK);
@@ -359,14 +366,9 @@
 	}
 }
 
-static int _open_and_assign_control_fd(const char *control,
-				       int ignore_nodev)
+static int _open_and_assign_control_fd(const char *control)
 {
-	_close_control_fd();
-
 	if ((_control_fd = open(control, O_RDWR)) < 0) {
-		if (ignore_nodev && errno == ENODEV)
-			return 1;
 		log_sys_error("open", control);
 		return 0;
 	}
@@ -378,8 +380,8 @@
 {
 #ifdef DM_IOCTLS
 	char control[PATH_MAX];
-	uint32_t major = 0, minor;
-	int dm_mod_autoload_support, needs_open;
+	uint32_t major = MISC_MAJOR;
+	uint32_t minor = MAPPER_CTRL_MINOR;
 
 	if (_control_fd != -1)
 		return 1;
@@ -390,63 +392,27 @@
 	snprintf(control, sizeof(control), "%s/%s", dm_dir(), DM_CONTROL_NODE);
 
 	/*
-	 * dm-mod autoloading is supported since kernel 2.6.36.
-	 * Udev daemon will try to read modules.devname file extracted
-	 * by depmod and create any static nodes needed.
-	 * The /dev/mapper/control node can be created and prepared this way.
-	 * First access to such node should load dm-mod module automatically.
-	 */
-	dm_mod_autoload_support = KERNEL_VERSION(_kernel_major, _kernel_minor,
-				  _kernel_release) >= KERNEL_VERSION(2, 6, 36);
-
-	/*
-	 *  If dm-mod autoloading is supported and the control node exists
-	 *  already try to open it now. This should autoload dm-mod module.
-	 */
-	if (dm_mod_autoload_support) {
-		if (!_get_proc_number(PROC_DEVICES, MISC_NAME, &major))
-			/* If major not found, just fallback to hardcoded value. */
-			major = MISC_MAJOR;
-
-		/* Recreate the node with correct major and minor if needed. */
-		if (!_control_exists(control, major, MAPPER_CTRL_MINOR) &&
-		    !_create_control(control, major, MAPPER_CTRL_MINOR))
-			goto error;
-
-		/* Fallback to old code only if control node doesn't exist */
-		if (!_open_and_assign_control_fd(control, 1))
-			goto error;
-	}
-
-	/*
-	 * Get major and minor number assigned for the control node.
-	 * In case we make use of the module autoload support, this
-	 * information should be accessible now as well.
+	 * Prior to 2.6.36 the minor number should be looked up in /proc.
 	 */
-	if (!_control_device_number(&major, &minor))
-		log_error("Is device-mapper driver missing from kernel?");
+	if ((KERNEL_VERSION(_kernel_major, _kernel_minor, _kernel_release) <
+	     KERNEL_VERSION(2, 6, 36)) &&
+	    !_control_device_number(&major, &minor))
+		goto_bad;
 
 	/*
-	 * Check the control node and its major and minor number.
-	 * If there's anything wrong, remove the old node and create
-	 * a correct one.
+	 * Create the node with correct major and minor if not already done.
+	 * Udev may already have created /dev/mapper/control
+	 * from the modules.devname file generated by depmod.
 	 */
-	if ((needs_open = !_control_exists(control, major, minor)) &&
-	    !_create_control(control, major, minor)) {
-		_close_control_fd();
-		goto error;
-	}
+	if (!_create_control(control, major, minor))
+		goto_bad;
 
 	/*
-	 * For older kernels without dm-mod autoloading support, we always
-	 * need to open the control node here - we still haven't done that!
-	 * For newer kernels with dm-mod autoloading, we open it only if the
-	 * node was recreated and corrected in previous step.
+	 * As of 2.6.36 kernels, the open can trigger autoloading dm-mod.
 	 */
-	if ((!dm_mod_autoload_support || needs_open) &&
-	     !_open_and_assign_control_fd(control, 0))
-		goto error;
-
+	if (!_open_and_assign_control_fd(control))
+		goto_bad;
+	
 	if (!_create_dm_bitset()) {
 		log_error("Failed to set up list of device-mapper major numbers");
 		return 0;
@@ -454,8 +420,10 @@
 
 	return 1;
 
-error:
+bad:
 	log_error("Failure to communicate with kernel device-mapper driver.");
+	if (!geteuid())
+		log_error("Check that device-mapper is available in the kernel.");
 	return 0;
 #else
 	return 1;


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-03-08 22:43 zkabelac
  0 siblings, 0 replies; 17+ messages in thread
From: zkabelac @ 2011-03-08 22:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-08 22:43:20

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix reading byte from char params[-1] position
	
	When the ->params string is empty - memory access is made on the byte
	before allocated buffer (catched by valgrind) - in the case it would
	constain 0x20 - it would even overwrite this buffer.
	So fix by checking len > 0 before doing such access.
	Also slightly optimise this loop from repeated strlen call.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.453&r2=1.454
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/WHATS_NEW_DM	2011/03/03 13:05:40	1.453
+++ LVM2/WHATS_NEW_DM	2011/03/08 22:43:19	1.454
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Fix memory access of empty params string in _reload_with_suppression_v4().
   Lower severity of selabel_lookup and matchpathcon failure to log_debug.
   Accept multiple mapped device names on many dmsetup command lines.
   Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/03/05 21:17:19	1.98
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/03/08 22:43:20	1.99
@@ -1836,6 +1836,7 @@
 {
 	struct dm_task *task;
 	struct target *t1, *t2;
+	size_t len;
 	int r;
 
 	/* New task to get existing table information */
@@ -1878,8 +1879,9 @@
 	t2 = task->head;
 
 	while (t1 && t2) {
-		while (t2->params[strlen(t2->params) - 1] == ' ')
-			t2->params[strlen(t2->params) - 1] = '\0';
+		len = strlen(t2->params);
+		while (len-- > 0 && t2->params[len] == ' ')
+			t2->params[len] = '\0';
 		if ((t1->start != t2->start) ||
 		    (t1->length != t2->length) ||
 		    (strcmp(t1->type, t2->type)) ||


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-03-01 23:27 agk
  0 siblings, 0 replies; 17+ messages in thread
From: agk @ 2011-03-01 23:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-03-01 23:27:07

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix _create_and_load_v4 not to lose the --addnodeoncreate setting (1.02.62).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.449&r2=1.450
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95

--- LVM2/WHATS_NEW_DM	2011/02/21 16:26:23	1.449
+++ LVM2/WHATS_NEW_DM	2011/03/01 23:27:06	1.450
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Fix _create_and_load_v4 not to lose the --addnodeoncreate setting (1.02.62).
   Add inactive table query support for kernel driver >= 4.11.6 (RHEL 5.7).
   Log debug open_count in _node_has_closed_parents().
   Change dm_report_field_string() API to accept const char *const *data.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/02/21 16:26:24	1.94
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/03/01 23:27:07	1.95
@@ -1753,6 +1753,7 @@
 	/* FIXME: Just for udev_check in dm_task_run. Can we avoid this? */
 	task->event_nr = dmt->event_nr & DM_UDEV_FLAGS_MASK;
 	task->cookie_set = dmt->cookie_set;
+	task->add_node = dmt->add_node;
 
 	r = dm_task_run(task);
 	dm_task_destroy(task);


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2011-02-21 16:26 snitzer
  0 siblings, 0 replies; 17+ messages in thread
From: snitzer @ 2011-02-21 16:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2011-02-21 16:26:25

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Add inactive table query support for kernel driver >= 4.11.6 (RHEL 5.7).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.448&r2=1.449
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94

--- LVM2/WHATS_NEW_DM	2011/02/18 16:13:56	1.448
+++ LVM2/WHATS_NEW_DM	2011/02/21 16:26:23	1.449
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Add inactive table query support for kernel driver >= 4.11.6 (RHEL 5.7).
   Log debug open_count in _node_has_closed_parents().
   Change dm_report_field_string() API to accept const char *const *data.
 
--- LVM2/libdm/ioctl/libdm-iface.c	2011/02/18 23:09:56	1.93
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/02/21 16:26:24	1.94
@@ -992,6 +992,23 @@
 	        _dm_version_minor >= 15);
 }
 
+static int dm_inactive_supported(void)
+{
+	int inactive_supported = 0;
+
+	if (dm_check_version() && _dm_version >= 4) {
+		if (_dm_version_minor >= 16)
+			inactive_supported = 1; /* upstream */
+		else if (_dm_version_minor == 11 &&
+			 (_dm_version_patchlevel >= 6 &&
+			  _dm_version_patchlevel <= 40)) {
+			inactive_supported = 1; /* RHEL 5.7 */
+		}
+	}
+
+	return inactive_supported;
+}
+
 void *dm_get_next_target(struct dm_task *dmt, void *next,
 			 uint64_t *start, uint64_t *length,
 			 char **target_type, char **params)
@@ -1548,7 +1565,7 @@
 		dmi->flags |= DM_SECURE_DATA_FLAG;
 	}
 	if (dmt->query_inactive_table) {
-		if (_dm_version_minor < 16)
+		if (!dm_inactive_supported())
 			log_warn("WARNING: Inactive table query unsupported "
 				 "by kernel.  It will use live table.");
 		dmi->flags |= DM_QUERY_INACTIVE_TABLE_FLAG;


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2010-08-18 13:11 prajnoha
  0 siblings, 0 replies; 17+ messages in thread
From: prajnoha @ 2010-08-18 13:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-08-18 13:11:57

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix dm-mod autoloading logic to not assume control node is set correctly.
	
	We can't rely on the fact that udev should prepare the node with right major
	and minor number to trigger the module autoloading. We have to take into
	account that the node could be missing or it could exist with improper
	major and minor number assigned (e.g. from previous kernel versions in
	an environment with static nodes and without udev). Make any corrections
	if needed!

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.410&r2=1.411
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81

--- LVM2/WHATS_NEW_DM	2010/08/16 22:54:35	1.410
+++ LVM2/WHATS_NEW_DM	2010/08/18 13:11:56	1.411
@@ -1,5 +1,6 @@
 Version 1.02.54 - 
 ================================
+  Fix dm-mod autoloading logic to not assume control node is set correctly.
   Add dmeventd/executable to lvm.conf to test alternative dmeventd.
   Export dm_event_handler_set_dmeventd_path to override built-in dmeventd path.
   Generate libdevmapper-event exported symbols.
--- LVM2/libdm/ioctl/libdm-iface.c	2010/08/16 11:13:18	1.80
+++ LVM2/libdm/ioctl/libdm-iface.c	2010/08/18 13:11:57	1.81
@@ -58,6 +58,15 @@
 
 #define NUMBER_OF_MAJORS 4096
 
+/*
+ * Static minor number assigned since kernel version 2.6.36.
+ * The original definition is in kernel's include/linux/miscdevice.h.
+ * This number is also visible in modules.devname exported by depmod
+ * utility (support included in module-init-tools version >= 3.12).
+ */
+#define MAPPER_CTRL_MINOR 236
+#define MISC_MAJOR 10
+
 /* dm major version no for running kernel */
 static unsigned _dm_version = DM_VERSION_MAJOR;
 static unsigned _dm_version_minor = 0;
@@ -341,10 +350,23 @@
 		return (major == _dm_device_major) ? 1 : 0;
 }
 
-static int _open_and_assign_control_fd(const char *control)
+static void _close_control_fd(void)
 {
+	if (_control_fd != -1) {
+		if (close(_control_fd) < 0)
+			log_sys_error("close", "_control_fd");
+		_control_fd = -1;
+	}
+}
+
+static int _open_and_assign_control_fd(const char *control,
+				       int ignore_nodev)
+{
+	_close_control_fd();
+
 	if ((_control_fd = open(control, O_RDWR)) < 0) {
-		log_sys_error("open", control);
+		if (!(ignore_nodev && errno == ENODEV))
+			log_sys_error("open", control);
 		return 0;
 	}
 
@@ -356,6 +378,7 @@
 #ifdef DM_IOCTLS
 	char control[PATH_MAX];
 	uint32_t major = 0, minor;
+	int dm_mod_autoload_support, needs_open;
 
 	if (_control_fd != -1)
 		return 1;
@@ -366,45 +389,61 @@
 	snprintf(control, sizeof(control), "%s/%s", dm_dir(), DM_CONTROL_NODE);
 
 	/*
-	 * Try to make use of module autoload kernel feature first.
-	 * This is accomplished with the help of udev that will
-	 * create static nodes based on modules.devname file extracted
-	 * by depmod (that udev reads). The /dev/mapper/control will
-	 * be created this way and the first access to a node will
-	 * load dm module automatically.
-	 *
-	 * To check for the module autoload support, we need:
-	 *
-	 *   - to check if the control node was created before (this
-	 *     should be the static node created by udev at its start)
-	 *
-	 *   - to check if we have recent enough kernel that is supposed
-	 *     to support this feature (a change in dm itself). We can't
-	 *     check dm version - we don't have a node to make an ioctl yet.
-	 *
-	 *   - try to open the control node (this will trigger the autoload).
-	 *     Successfull open means the autoload was successfull.
-	 *
-	 * If any of these three conditions fails, we fallback to old way.
-	 * It means we'll try to get the major:minor of control node,
-	 * we'll check its existence (checking the exact major:minor)
-	 * and we'll create the node if needed.
+	 * dm-mod autoloading is supported since kernel 2.6.36.
+	 * Udev daemon will try to read modules.devname file extracted
+	 * by depmod and create any static nodes needed.
+	 * The /dev/mapper/control node can be created and prepared this way.
+	 * First access to such node should load dm-mod module automatically.
 	 */
-	if (!_control_exists(control, 0, 0) ||
-	    !(KERNEL_VERSION(_kernel_major, _kernel_minor, _kernel_release) >=
-	      KERNEL_VERSION(2, 6, 36)) ||
-	    !_open_and_assign_control_fd(control)) {
-		if (!_control_device_number(&major, &minor))
-			log_error("Is device-mapper driver missing from kernel?");
+	dm_mod_autoload_support = KERNEL_VERSION(_kernel_major, _kernel_minor,
+				  _kernel_release) >= KERNEL_VERSION(2, 6, 36);
 
-		if (!_control_exists(control, major, minor) &&
-		    !_create_control(control, major, minor))
+	/*
+	 *  If dm-mod autoloading is supported and the control node exists
+	 *  already try to open it now. This should autoload dm-mod module.
+	 */
+	if (dm_mod_autoload_support) {
+		if (!_get_proc_number(PROC_DEVICES, MISC_NAME, &major))
+			/* If major not found, just fallback to hardcoded value. */
+			major = MISC_MAJOR;
+
+		/* Recreate the node with correct major and minor if needed. */
+		if (!_control_exists(control, major, MAPPER_CTRL_MINOR) &&
+		    !_create_control(control, major, MAPPER_CTRL_MINOR))
 			goto error;
 
-		if (!_open_and_assign_control_fd(control))
-			goto error;
+		_open_and_assign_control_fd(control, 1);
 	}
 
+	/*
+	 * Get major and minor number assigned for the control node.
+	 * In case we make use of the module autoload support, this
+	 * information should be accessible now as well.
+	 */
+	if (!_control_device_number(&major, &minor))
+		log_error("Is device-mapper driver missing from kernel?");
+
+	/*
+	 * Check the control node and its major and minor number.
+	 * If there's anything wrong, remove the old node and create
+	 * a correct one.
+	 */
+	if ((needs_open = !_control_exists(control, major, minor)) &&
+	    !_create_control(control, major, minor)) {
+		_close_control_fd();
+		goto error;
+	}
+
+	/*
+	 * For older kernels without dm-mod autoloading support, we always
+	 * need to open the control node here - we still haven't done that!
+	 * For newer kernels with dm-mod autoloading, we open it only if the
+	 * node was recreated and corrected in previous step.
+	 */
+	if ((!dm_mod_autoload_support || needs_open) &&
+	     !_open_and_assign_control_fd(control, 0))
+		goto error;
+
 	if (!_create_dm_bitset()) {
 		log_error("Failed to set up list of device-mapper major numbers");
 		return 0;
@@ -2045,10 +2084,7 @@
 
 void dm_lib_release(void)
 {
-	if (_control_fd != -1) {
-		close(_control_fd);
-		_control_fd = -1;
-	}
+	_close_control_fd();
 	update_devs();
 }
 


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

* LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c
@ 2010-05-13 13:31 mbroz
  0 siblings, 0 replies; 17+ messages in thread
From: mbroz @ 2010-05-13 13:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-05-13 13:31:30

Modified files:
	.              : WHATS_NEW_DM 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Do not print encryption key in message debug output.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.367&r2=1.368
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74

--- LVM2/WHATS_NEW_DM	2010/04/30 15:48:39	1.367
+++ LVM2/WHATS_NEW_DM	2010/05/13 13:31:30	1.368
@@ -1,5 +1,6 @@
 Version 1.02.48 -
 =================================
+  Do not print encryption key in message debug output (cryptsetup luksResume).
 
 Version 1.02.47 - 30th April 2010
 =================================
--- LVM2/libdm/ioctl/libdm-iface.c	2010/05/03 22:08:38	1.73
+++ LVM2/libdm/ioctl/libdm-iface.c	2010/05/13 13:31:30	1.74
@@ -1102,7 +1102,7 @@
 int dm_task_set_message(struct dm_task *dmt, const char *message)
 {
 	if (!(dmt->message = dm_strdup(message))) {
-		log_error("dm_task_set_message: strdup(%s) failed", message);
+		log_error("dm_task_set_message: strdup failed");
 		return 0;
 	}
 
@@ -1724,6 +1724,18 @@
 	return r;
 }
 
+static const char *_sanitise_message(char *message)
+{
+	const char *sanitised_message = message ?: "";
+
+	/* FIXME: Check for whitespace variations. */
+	/* This traps what cryptsetup sends us. */
+	if (message && !strncasecmp(message, "key set", 7))
+		sanitised_message = "key set";
+
+	return sanitised_message;
+}
+
 static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
 				     unsigned repeat_count)
 {
@@ -1805,7 +1817,7 @@
 		  dmt->no_flush ? 'N' : 'F',
 		  dmt->skip_lockfs ? "S " : "",
 		  dmt->query_inactive_table ? "I " : "",
-		  dmt->sector, dmt->message ? dmt->message : "",
+		  dmt->sector, _sanitise_message(dmt->message),
 		  dmi->data_size);
 #ifdef DM_IOCTLS
 	if (ioctl(_control_fd, command, dmi) < 0) {


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

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

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 12:59 LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-03-01 10:07 zkabelac
2012-02-15 12:17 prajnoha
2012-02-08 11:25 zkabelac
2011-11-08 17:32 snitzer
2011-10-20 10:38 zkabelac
2011-09-13 15:13 prajnoha
2011-08-11 20:49 zkabelac
2011-07-24 23:59 agk
2011-07-02  1:17 agk
2011-06-09 15:07 mbroz
2011-03-25 23:50 agk
2011-03-08 22:43 zkabelac
2011-03-01 23:27 agk
2011-02-21 16:26 snitzer
2010-08-18 13:11 prajnoha
2010-05-13 13:31 mbroz

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