public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm ...
@ 2011-11-18 19:34 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2011-11-18 19:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-18 19:34:03

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

Log message:
	Check target type name for DM_MAX_TYPE_NAME length
	
	Avoid creation of target type name when it's longer then
	DM_MAX_TYPE_NAME (noticed by static analyzer where the
	sp.target_type might be missing '\0' at the end.)
	
	Before patch:
	
	$> dmsetup create long
	0 1000 looooooooooooooooooooooooooong
	^D
	device-mapper: reload ioctl failed: Invalid argument
	
	After patch:
	
	$> dmsetup create xxx
	0 1000 looooooooooooooooooooooooooong
	Target type name looooooooooooooooooooooooooong is too long.
	Command failed

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.523&r2=1.524
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.127&r2=1.128
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129

--- LVM2/WHATS_NEW_DM	2011/11/15 13:54:20	1.523
+++ LVM2/WHATS_NEW_DM	2011/11/18 19:34:02	1.524
@@ -1,5 +1,6 @@
 Version 1.02.68 -
 ==================================
+  Add test for max length (DM_MAX_TYPE_NAME) of target type name.
   Include a copy of kernel DM documentation in doc/kernel.
   Improve man page style for dmsetup.
   Fix _get_proc_number to be tolerant of malformed /proc/misc entries.
--- LVM2/libdm/libdm-common.c	2011/09/24 11:47:53	1.127
+++ LVM2/libdm/libdm-common.c	2011/11/18 19:34:03	1.128
@@ -407,9 +407,8 @@
 		       const char *ttype, const char *params)
 {
 	struct target *t = create_target(start, size, ttype, params);
-
 	if (!t)
-		return 0;
+		return_0;
 
 	if (!dmt->head)
 		dmt->head = dmt->tail = t;
--- LVM2/libdm/ioctl/libdm-iface.c	2011/11/08 19:02:21	1.128
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/11/18 19:34:03	1.129
@@ -853,9 +853,14 @@
 struct target *create_target(uint64_t start, uint64_t len, const char *type,
 			     const char *params)
 {
-	struct target *t = dm_zalloc(sizeof(*t));
+	struct target *t;
+
+	if (strlen(type) >= DM_MAX_TYPE_NAME) {
+		log_error("Target type name %s is too long.", type);
+		return NULL;
+	}
 
-	if (!t) {
+	if (!(t = dm_zalloc(sizeof(*t)))) {
 		log_error("create_target: malloc(%" PRIsize_t ") failed",
 			  sizeof(*t));
 		return NULL;
@@ -889,19 +894,24 @@
 	size_t sp_size = sizeof(struct dm_target_spec);
 	int len;
 
-	out += sp_size;
-	if (out >= end)
-		return_NULL;
+	if (strlen(t->type) >= sizeof(sp.target_type)) {
+		log_error("Target type name %s is too long.", t->type);
+		return NULL;
+	}
 
 	sp.status = 0;
 	sp.sector_start = t->start;
 	sp.length = t->length;
-	strncpy(sp.target_type, t->type, sizeof(sp.target_type));
+	strncpy(sp.target_type, t->type, sizeof(sp.target_type) - 1);
+	sp.target_type[sizeof(sp.target_type) - 1] = '\0';
 
+	out += sp_size;
 	len = strlen(t->params);
 
-	if ((out + len + 1) >= end)
-		return_NULL;
+	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;
@@ -1110,10 +1120,8 @@
 	e = (char *) dmi + len;
 
 	for (t = dmt->head; t; t = t->next)
-		if (!(b = _add_target(t, b, e))) {
-			log_error("Ran out of memory building ioctl parameter");
-			goto bad;
-		}
+		if (!(b = _add_target(t, b, e)))
+			goto_bad;
 
 	if (dmt->newname)
 		strcpy(b, dmt->newname);


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

* LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm ...
@ 2012-03-05 12:48 prajnoha
  0 siblings, 0 replies; 6+ messages in thread
From: prajnoha @ 2012-03-05 12:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-03-05 12:48:13

Modified files:
	.              : WHATS_NEW_DM 
	libdm          : libdm-common.c libdm-common.h 
	libdm/ioctl    : libdm-iface.c 
	tools          : dmsetup.c 

Log message:
	Check for multiple mangled names in auto mangling mode.
	
	Auto mode can't deal with multiple mangled names. We can do that while working
	in hex mode, but in auto mode, this would lead to device name ambiguity.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.588&r2=1.589
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.h.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.185&r2=1.186

--- LVM2/WHATS_NEW_DM	2012/03/05 12:45:43	1.588
+++ LVM2/WHATS_NEW_DM	2012/03/05 12:48:12	1.589
@@ -1,5 +1,6 @@
 Version 1.02.74 - 
 ================================
+  Check for multiple mangled names in auto mangling mode.
   Fix dm_task_get_name_unmangled to not unmangle already unmangled name.
   Check whether device names are properly mangled on ioctl return.
   Deactivation of failed thin check on thin pool returns success.
--- LVM2/libdm/libdm-common.c	2012/03/05 12:45:43	1.146
+++ LVM2/libdm/libdm-common.c	2012/03/05 12:48:12	1.147
@@ -326,6 +326,17 @@
         return 0;
 }
 
+int check_multiple_mangled_name_allowed(dm_string_mangling_t mode, const char *name)
+{
+	if (mode == DM_STRING_MANGLING_AUTO && strstr(name, "\\x5cx")) {
+		log_error("The name \"%s\" seems to be multiple mangled. "
+			  "This is not allowed in auto mode.", name);
+		return 0;
+	}
+
+	return 1;
+}
+
 /*
  * Mangle all characters in the input string which are not on a whitelist
  * with '\xNN' format where NN is the hex value of the character.
@@ -485,6 +496,9 @@
 		return 0;
 	}
 
+	if (!check_multiple_mangled_name_allowed(mangling_mode, name))
+		return_0;
+
 	if (mangling_mode != DM_STRING_MANGLING_NONE &&
 	    (r = mangle_name(name, strlen(name), mangled_name,
 			     sizeof(mangled_name), mangling_mode)) < 0) {
@@ -620,6 +634,9 @@
 		return 0;
 	}
 
+	if (!check_multiple_mangled_name_allowed(mangling_mode, newname))
+		return_0;
+
 	if (mangling_mode != DM_STRING_MANGLING_NONE &&
 	    (r = mangle_name(newname, strlen(newname), mangled_name,
 			     sizeof(mangled_name), mangling_mode)) < 0) {
--- LVM2/libdm/libdm-common.h	2012/02/15 12:23:16	1.14
+++ LVM2/libdm/libdm-common.h	2012/03/05 12:48:13	1.15
@@ -28,6 +28,8 @@
 int unmangle_name(const char *str, size_t len, char *buf,
 		  size_t buf_len, dm_string_mangling_t mode);
 
+int check_multiple_mangled_name_allowed(dm_string_mangling_t mode, const char *name);
+
 struct target *create_target(uint64_t start,
 			     uint64_t len,
 			     const char *type, const char *params);
--- LVM2/libdm/ioctl/libdm-iface.c	2012/03/05 12:43:03	1.142
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/03/05 12:48:13	1.143
@@ -1559,6 +1559,9 @@
 	if (mode == DM_STRING_MANGLING_NONE)
 		return 1;
 
+	if (!check_multiple_mangled_name_allowed(mode, name))
+		return_0;
+
 	if ((r = unmangle_name(name, DM_NAME_LEN, buf, sizeof(buf),
 			       dm_get_name_mangling_mode())) < 0) {
 		log_debug("_do_dm_ioctl_unmangle_name: failed to "
--- LVM2/tools/dmsetup.c	2012/03/01 21:56:44	1.185
+++ LVM2/tools/dmsetup.c	2012/03/05 12:48:13	1.186
@@ -2944,6 +2944,12 @@
 	target_format = _switches[MANGLENAME_ARG] ? _int_args[MANGLENAME_ARG]
 						  : DEFAULT_DM_NAME_MANGLING;
 
+	if (target_format == DM_STRING_MANGLING_AUTO && strstr(name, "\\x5cx")) {
+		log_error("The name \"%s\" seems to be multiple mangled. "
+			  "Manual intervention required to rename the device.", name);
+		goto out;
+	}
+
 	if (target_format == DM_STRING_MANGLING_NONE) {
 		if (!(new_name = dm_task_get_name_unmangled(dmt)))
 			goto out;


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

* LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm ...
@ 2012-03-05 12:43 prajnoha
  0 siblings, 0 replies; 6+ messages in thread
From: prajnoha @ 2012-03-05 12:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-03-05 12:43:03

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

Log message:
	Check whether device names are properly mangled on ioctl return.
	
	Be more strict when unmangling names on ioctl return - require the name to be
	properly mangled in 'auto' and 'hex' mode. There really should not be any
	blacklisted character since the names should be renamed already (by means of
	renaming it directly or running 'dmsetup mangle' for automatic rename).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.586&r2=1.587
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.144&r2=1.145
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142

--- LVM2/WHATS_NEW_DM	2012/03/04 17:40:59	1.586
+++ LVM2/WHATS_NEW_DM	2012/03/05 12:43:03	1.587
@@ -1,5 +1,6 @@
 Version 1.02.74 - 
 ================================
+  Check whether device names are properly mangled on ioctl return.
   Deactivation of failed thin check on thin pool returns success.
 
 Version 1.02.73 - 3rd March 2012
--- LVM2/libdm/libdm-common.c	2012/03/05 12:40:34	1.144
+++ LVM2/libdm/libdm-common.c	2012/03/05 12:43:03	1.145
@@ -421,6 +421,7 @@
 int unmangle_name(const char *str, size_t len, char *buf,
 		  size_t buf_len, dm_string_mangling_t mode)
 {
+	int strict = mode != DM_STRING_MANGLING_NONE;
 	char str_rest[DM_NAME_LEN];
 	size_t i, j;
 	int code;
@@ -439,6 +440,13 @@
 	}
 
 	for (i = 0, j = 0; str[i]; i++, j++) {
+		if (strict && !(_is_whitelisted_char(str[i]) || str[i]=='\\')) {
+			log_error("The name \"%s\" should be mangled but "
+				  "it contains blacklisted characters.", str);
+			j=0; r=-1;
+			goto out;
+		}
+
 		if (str[i] == '\\' && str[i+1] == 'x') {
 			if (!sscanf(&str[i+2], "%2x%s", &code, str_rest)) {
 				log_debug("Hex encoding mismatch detected in \"%s\" "
--- LVM2/libdm/ioctl/libdm-iface.c	2012/03/05 12:40:34	1.141
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/03/05 12:43:03	1.142
@@ -1550,41 +1550,47 @@
 	return sanitised_message;
 }
 
-static void _do_dm_ioctl_unmangle_name(char *name)
+static int _do_dm_ioctl_unmangle_name(char *name)
 {
 	dm_string_mangling_t mode = dm_get_name_mangling_mode();
 	char buf[DM_NAME_LEN];
 	int r;
 
 	if (mode == DM_STRING_MANGLING_NONE)
-		return;
+		return 1;
 
 	if ((r = unmangle_name(name, DM_NAME_LEN, buf, sizeof(buf),
-			       dm_get_name_mangling_mode())) < 0)
+			       dm_get_name_mangling_mode())) < 0) {
 		log_debug("_do_dm_ioctl_unmangle_name: failed to "
 			  "unmangle \"%s\"", name);
-	else if (r)
+		return 0;
+	} else if (r)
 		memcpy(name, buf, strlen(buf) + 1);
+
+	return 1;
 }
 
-static void _dm_ioctl_unmangle_names(int type, struct dm_ioctl *dmi)
+static int _dm_ioctl_unmangle_names(int type, struct dm_ioctl *dmi)
 {
 	struct dm_names *names;
 	unsigned next = 0;
 	char *name;
+	int r = 1;
 
 	if ((name = dmi->name))
-		_do_dm_ioctl_unmangle_name(name);
+		r = _do_dm_ioctl_unmangle_name(name);
 
 	if (type == DM_DEVICE_LIST &&
 	    ((names = ((struct dm_names *) ((char *)dmi + dmi->data_start)))) &&
 	    names->dev) {
 		do {
 			names = (struct dm_names *)((char *) names + next);
-			_do_dm_ioctl_unmangle_name(names->name);
+			r = _do_dm_ioctl_unmangle_name(names->name);
 			next = names->next;
 		} while (next);
 	}
+
+	return r;
 }
 
 static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
@@ -1703,8 +1709,7 @@
 			 */
 			*retryable = errno == EBUSY;
 
-			_dm_zfree_dmi(dmi);
-			return NULL;
+			goto error;
 		}
 	}
 
@@ -1715,11 +1720,16 @@
 		_udev_complete(dmt);
 	}
 
-	(void) _dm_ioctl_unmangle_names(dmt->type, dmi);
+	if (!_dm_ioctl_unmangle_names(dmt->type, dmi))
+		goto error;
 
 #else /* Userspace alternative for testing */
 #endif
 	return dmi;
+
+error:
+	_dm_zfree_dmi(dmi);
+	return NULL;
 }
 
 void dm_task_update_nodes(void)


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

* LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm ...
@ 2012-01-09 12:26 zkabelac
  0 siblings, 0 replies; 6+ messages in thread
From: zkabelac @ 2012-01-09 12:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-09 12:26:15

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

Log message:
	Use sysfs to set/get of read-ahead
	
	If we know major:minor number of device (which is known after resume) we will
	try to use  sysfs to set/get read ahead parameters of device.
	This avoid potential problem of blocking commands like 'dmsetup info' awaiting
	for device being usable for open/close - i.e. overfilled thin pool may block
	such command.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.526&r2=1.527
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.129&r2=1.130
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131

--- LVM2/WHATS_NEW_DM	2011/12/21 12:47:44	1.526
+++ LVM2/WHATS_NEW_DM	2012/01/09 12:26:14	1.527
@@ -1,5 +1,6 @@
 Version 1.02.68 -
 ==================================
+  Use sysfs to set/get of read-ahead setting if possible.
   Fix lvm2-monitor init script to use normalized output when using vgs.
   Add test for max length (DM_MAX_TYPE_NAME) of target type name.
   Include a copy of kernel DM documentation in doc/kernel.
--- LVM2/libdm/libdm-common.c	2011/12/18 21:56:03	1.129
+++ LVM2/libdm/libdm-common.c	2012/01/09 12:26:15	1.130
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of the device-mapper userspace tools.
  *
@@ -59,6 +59,7 @@
 
 static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
 static char _sysfs_dir[PATH_MAX] = "/sys/";
+static char _path0[PATH_MAX];           /* path buffer, safe 4kB on stack */
 
 static int _verbose = 0;
 static int _suspended_dev_counter = 0;
@@ -658,12 +659,53 @@
 	return fd;
 }
 
-int get_dev_node_read_ahead(const char *dev_name, uint32_t *read_ahead)
+int get_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor,
+			    uint32_t *read_ahead)
 {
+	char buf[24];
+	int len;
 	int r = 1;
 	int fd;
 	long read_ahead_long;
 
+	/*
+	 * If we know the device number, use sysfs if we can.
+	 * Otherwise use BLKRAGET ioctl.
+	 */
+	if (*_sysfs_dir && major != 0) {
+		if (dm_snprintf(_path0, sizeof(_path0), "%sdev/block/%" PRIu32
+				":%" PRIu32 "/bdi/read_ahead_kb", _sysfs_dir,
+				major, minor) < 0) {
+			log_error("Failed to build sysfs_path.");
+			return 0;
+		}
+
+		if ((fd = open(_path0, O_RDONLY, 0)) != -1) {
+			/* Reading from sysfs, expecting number\n */
+			if ((len = read(fd, buf, sizeof(buf))) < 1) {
+				log_sys_error("read", _path0);
+				r = 0;
+			} else {
+				buf[len] = 0; /* kill \n and ensure \0 */
+				*read_ahead = atoi(buf) * 2;
+				log_debug("%s (%d:%d): read ahead is %" PRIu32,
+					  dev_name, major, minor, *read_ahead);
+			}
+
+			if (close(fd))
+				log_sys_debug("close", _path0);
+
+			return r;
+		}
+
+		log_sys_debug("open", _path0);
+		/* Fall back to use dev_name */
+	}
+
+	/*
+	 * Open/close dev_name may block the process
+	 * (i.e. overfilled thin pool volume)
+	 */
 	if (!*dev_name) {
 		log_error("Empty device name passed to BLKRAGET");
 		return 0;
@@ -676,23 +718,64 @@
 		log_sys_error("BLKRAGET", dev_name);
 		*read_ahead = 0;
 		r = 0;
-	}  else {
+	} else {
 		*read_ahead = (uint32_t) read_ahead_long;
 		log_debug("%s: read ahead is %" PRIu32, dev_name, *read_ahead);
 	}
 
 	if (close(fd))
-		stack;
+		log_sys_debug("close", dev_name);
 
 	return r;
 }
 
-static int _set_read_ahead(const char *dev_name, uint32_t read_ahead)
+static int _set_read_ahead(const char *dev_name, uint32_t major, uint32_t minor,
+			   uint32_t read_ahead)
 {
+	char buf[24];
+	int len;
 	int r = 1;
 	int fd;
 	long read_ahead_long = (long) read_ahead;
 
+	log_debug("%s (%d:%d): Setting read ahead to %" PRIu32, dev_name,
+		  major, minor, read_ahead);
+
+	/*
+	 * If we know the device number, use sysfs if we can.
+	 * Otherwise use BLKRASET ioctl. RA is set after resume.
+	 */
+	if (*_sysfs_dir && major != 0) {
+		if (dm_snprintf(_path0, sizeof(_path0), "%sdev/block/%" PRIu32
+				":%" PRIu32 "/bdi/read_ahead_kb",
+				_sysfs_dir, major, minor) < 0) {
+			log_error("Failed to build sysfs_path.");
+			return 0;
+		}
+
+		/* Sysfs is kB based, round up to kB */
+		if ((len = dm_snprintf(buf, sizeof(buf), "%" PRIu32,
+				       (read_ahead + 1) / 2)) < 0) {
+			log_error("Failed to build size in kB.");
+			return 0;
+		}
+
+		if ((fd = open(_path0, O_WRONLY, 0)) != -1) {
+			if (write(fd, buf, len) < len) {
+				log_sys_error("write", _path0);
+				r = 0;
+			}
+
+			if (close(fd))
+				log_sys_debug("close", _path0);
+
+			return r;
+		}
+
+		log_sys_debug("open", _path0);
+		/* Fall back to use dev_name */
+	}
+
 	if (!*dev_name) {
 		log_error("Empty device name passed to BLKRAGET");
 		return 0;
@@ -701,21 +784,20 @@
 	if ((fd = _open_dev_node(dev_name)) < 0)
 		return_0;
 
-	log_debug("%s: Setting read ahead to %" PRIu32, dev_name, read_ahead);
-
 	if (ioctl(fd, BLKRASET, read_ahead_long)) {
 		log_sys_error("BLKRASET", dev_name);
 		r = 0;
 	}
 
 	if (close(fd))
-		stack;
+		log_sys_debug("close", dev_name);
 
 	return r;
 }
 
-static int _set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead,
-				    uint32_t read_ahead_flags)
+static int _set_dev_node_read_ahead(const char *dev_name,
+				    uint32_t major, uint32_t minor,
+				    uint32_t read_ahead, uint32_t read_ahead_flags)
 {
 	uint32_t current_read_ahead;
 
@@ -726,7 +808,7 @@
 		read_ahead = 0;
 
 	if (read_ahead_flags & DM_READ_AHEAD_MINIMUM_FLAG) {
-		if (!get_dev_node_read_ahead(dev_name, &current_read_ahead))
+		if (!get_dev_node_read_ahead(dev_name, major, minor, &current_read_ahead))
 			return_0;
 
 		if (current_read_ahead > read_ahead) {
@@ -737,7 +819,7 @@
 		}
 	}
 
-	return _set_read_ahead(dev_name, read_ahead);
+	return _set_read_ahead(dev_name, major, minor, read_ahead);
 }
 
 #else
@@ -749,8 +831,9 @@
 	return 1;
 }
 
-static int _set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead,
-				    uint32_t read_ahead_flags)
+static int _set_dev_node_read_ahead(const char *dev_name,
+				    uint32_t major, uint32_t minor,
+				    uint32_t read_ahead, uint32_t read_ahead_flags)
 {
 	return 1;
 }
@@ -778,8 +861,8 @@
 	case NODE_RENAME:
 		return _rename_dev_node(old_name, dev_name, warn_if_udev_failed);
 	case NODE_READ_AHEAD:
-		return _set_dev_node_read_ahead(dev_name, read_ahead,
-						read_ahead_flags);
+		return _set_dev_node_read_ahead(dev_name, major, minor,
+						read_ahead, read_ahead_flags);
 	default:
 		; /* NOTREACHED */
 	}
@@ -993,13 +1076,14 @@
 			      0, 0, "", 0, 0, check_udev, rely_on_udev);
 }
 
-int set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead,
-			    uint32_t read_ahead_flags)
+int set_dev_node_read_ahead(const char *dev_name,
+                            uint32_t major, uint32_t minor,
+			    uint32_t read_ahead, uint32_t read_ahead_flags)
 {
 	if (read_ahead == DM_READ_AHEAD_AUTO)
 		return 1;
 
-	return _stack_node_op(NODE_READ_AHEAD, dev_name, 0, 0, 0, 0,
+	return _stack_node_op(NODE_READ_AHEAD, dev_name, major, minor, 0, 0,
                               0, "", read_ahead, read_ahead_flags, 0, 0);
 }
 
--- LVM2/libdm/libdm-common.h	2011/06/27 21:43:59	1.9
+++ LVM2/libdm/libdm-common.h	2012/01/09 12:26:15	1.10
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of the device-mapper userspace tools.
  *
@@ -27,9 +27,10 @@
 int rm_dev_node(const char *dev_name, int check_udev, unsigned rely_on_udev);
 int rename_dev_node(const char *old_name, const char *new_name,
 		    int check_udev, unsigned rely_on_udev);
-int get_dev_node_read_ahead(const char *dev_name, uint32_t *read_ahead);
-int set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead,
-			    uint32_t read_ahead_flags);
+int get_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor,
+			    uint32_t *read_ahead);
+int set_dev_node_read_ahead(const char *dev_name, uint32_t major, uint32_t minor,
+			    uint32_t read_ahead, uint32_t read_ahead_flags);
 void update_devs(void);
 void selinux_release(void);
 
--- LVM2/libdm/ioctl/libdm-iface.c	2011/11/30 02:02:12	1.130
+++ LVM2/libdm/ioctl/libdm-iface.c	2012/01/09 12:26:15	1.131
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
  *
  * This file is part of the device-mapper userspace tools.
  *
@@ -665,7 +665,8 @@
 		return 0;
 	}
 
-	return get_dev_node_read_ahead(dev_name, read_ahead);
+	return get_dev_node_read_ahead(dev_name, MAJOR(dmt->dmi.v4->dev),
+				       MINOR(dmt->dmi.v4->dev), read_ahead);
 }
 
 const char *dm_task_get_name(const struct dm_task *dmt)
@@ -1818,8 +1819,9 @@
 				     MINOR(dmi->dev), dmt->uid, dmt->gid,
 				     dmt->mode, check_udev, rely_on_udev);
 		/* FIXME Kernel needs to fill in dmi->name */
-		set_dev_node_read_ahead(dmt->dev_name, dmt->read_ahead,
-					dmt->read_ahead_flags);
+		set_dev_node_read_ahead(dmt->dev_name,
+					MAJOR(dmi->dev), MINOR(dmi->dev),
+					dmt->read_ahead, dmt->read_ahead_flags);
 		break;
 	
 	case DM_DEVICE_MKNODES:


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

* LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm ...
@ 2011-03-02  0:29 agk
  0 siblings, 0 replies; 6+ messages in thread
From: agk @ 2011-03-02  0:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-03-02 00:29:58

Modified files:
	.              : WHATS_NEW_DM 
	libdm          : libdm-common.c libdm-deptree.c 
	libdm/ioctl    : libdm-iface.c 
	tools          : dmsetup.c 

Log message:
	Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
	Include an implicit dm_task_update_nodes() within dm_udev_wait().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.450&r2=1.451
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.154&r2=1.155

--- LVM2/WHATS_NEW_DM	2011/03/01 23:27:06	1.450
+++ LVM2/WHATS_NEW_DM	2011/03/02 00:29:57	1.451
@@ -1,5 +1,7 @@
 Version 1.02.64 - 
 ===================================
+  Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
+  Include an implicit dm_task_update_nodes() within dm_udev_wait().
   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().
--- LVM2/libdm/libdm-common.c	2011/02/04 22:07:44	1.110
+++ LVM2/libdm/libdm-common.c	2011/03/02 00:29:57	1.111
@@ -1044,6 +1044,8 @@
 
 int dm_udev_wait(uint32_t cookie)
 {
+	update_devs();
+
 	return 1;
 }
 
@@ -1380,7 +1382,7 @@
 	return 1;
 }
 
-int dm_udev_wait(uint32_t cookie)
+static int _udev_wait(uint32_t cookie)
 {
 	int semid;
 	struct sembuf sb = {0, 0, 0};
@@ -1420,4 +1422,11 @@
 	return _udev_notify_sem_destroy(cookie, semid);
 }
 
+int dm_udev_wait(uint32_t cookie)
+{
+	int r = _udev_wait(cookie);
+
+	update_devs();
+}
+
 #endif		/* UDEV_SYNC_SUPPORT */
--- LVM2/libdm/libdm-deptree.c	2011/02/18 16:13:56	1.90
+++ LVM2/libdm/libdm-deptree.c	2011/03/02 00:29:57	1.91
@@ -1922,7 +1922,6 @@
 		if (!dm_udev_wait(dm_tree_get_cookie(dnode)))
 			stack;
 		dm_tree_set_cookie(dnode, 0);
-		dm_task_update_nodes();
 	}
 
 	return r;
--- LVM2/libdm/ioctl/libdm-iface.c	2011/03/01 23:27:07	1.95
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/03/02 00:29:57	1.96
@@ -2025,7 +2025,8 @@
 		}
 	}
 
-	if (ioctl_with_uevent && !_check_uevent_generated(dmi)) {
+	if (ioctl_with_uevent && dm_udev_get_sync_support() &&
+	    !_check_uevent_generated(dmi)) {
 		log_debug("Uevent not generated! Calling udev_complete "
 			  "internally to avoid process lock-up.");
 		_udev_complete(dmt);
--- LVM2/tools/dmsetup.c	2011/02/18 16:17:57	1.154
+++ LVM2/tools/dmsetup.c	2011/03/02 00:29:58	1.155
@@ -658,22 +658,16 @@
 
 	r = 1;
 
+      out:
 	if (!_udev_cookie)
 		(void) dm_udev_wait(cookie);
 
-	if (_switches[VERBOSE_ARG])
+	if (r && _switches[VERBOSE_ARG])
 		r = _display_info(dmt);
 
 	dm_task_destroy(dmt);
 
 	return r;
-
-      out:
-	if (!_udev_cookie)
-		(void) dm_udev_wait(cookie);
-	dm_task_destroy(dmt);
-
-	return r;
 }
 
 static int _rename(int argc, char **argv, void *data __attribute__((unused)))
@@ -721,6 +715,7 @@
       out:
 	if (!_udev_cookie)
 		(void) dm_udev_wait(cookie);
+
 	dm_task_destroy(dmt);
 
 	return r;
@@ -1242,14 +1237,15 @@
 
 	r = dm_task_run(dmt);
 
-	if (r && display && _switches[VERBOSE_ARG])
-		r = _display_info(dmt);
-
       out:
 	if (!_udev_cookie && udev_wait_flag)
 		(void) dm_udev_wait(cookie);
 
+	if (r && display && _switches[VERBOSE_ARG])
+		r = _display_info(dmt);
+
 	dm_task_destroy(dmt);
+
 	return r;
 }
 


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

* LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm ...
@ 2009-01-07 12:17 prajnoha
  0 siblings, 0 replies; 6+ messages in thread
From: prajnoha @ 2009-01-07 12:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2009-01-07 12:17:40

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

Log message:
	Add checks for device names in dmsetup and show proper error messages.
	
	Checks added for DM device names to allow only names < DM_NAME_LEN,
	otherwise a part of lengthy name would be silently ignored and could
	cause confusion while using dmsetup. Also, the name should not contain
	'/' character, if it is used in context of creating a new device
	or renaming the existing one (because we do not consider full path
	to devices, they do not exist in filesystem yet) and appropriate error
	messages are shown.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.258&r2=1.259
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55

--- LVM2/WHATS_NEW_DM	2008/12/11 16:25:51	1.258
+++ LVM2/WHATS_NEW_DM	2009/01/07 12:17:40	1.259
@@ -1,5 +1,6 @@
 Version 1.02.30 -
 ====================================
+  Add checks for device names in dmsetup and show proper error messages.
   Replace _dm_snprintf with EMIT_PARAMS macro for creating target lines
 
 Version 1.02.29 - 10th November 2008
--- LVM2/libdm/libdm-common.c	2008/11/04 15:07:45	1.63
+++ LVM2/libdm/libdm-common.c	2009/01/07 12:17:40	1.64
@@ -143,18 +143,27 @@
 	 * as its last component.
 	 */
 	if ((pos = strrchr(name, '/'))) {
+		if (dmt->type == DM_DEVICE_CREATE) {
+			log_error("Name \"%s\" invalid. It contains \"/\".", name);
+			return 0;
+		}
+
 		snprintf(path, sizeof(path), "%s/%s", _dm_dir, pos + 1);
 
 		if (stat(name, &st1) || stat(path, &st2) ||
 		    !(st1.st_dev == st2.st_dev)) {
-			log_error("dm_task_set_name: Device %s not found",
-				  name);
+			log_error("Device %s not found", name);
 			return 0;
 		}
 
 		name = pos + 1;
 	}
 
+	if (strlen(name) >= DM_NAME_LEN) {
+		log_error("Name \"%s\" too long", name);
+		return 0;
+	}
+
 	if (!(dmt->dev_name = dm_strdup(name))) {
 		log_error("dm_task_set_name: strdup(%s) failed", name);
 		return 0;
--- LVM2/libdm/ioctl/libdm-iface.c	2008/11/03 18:59:59	1.54
+++ LVM2/libdm/ioctl/libdm-iface.c	2009/01/07 12:17:40	1.55
@@ -1018,6 +1018,16 @@
 
 int dm_task_set_newname(struct dm_task *dmt, const char *newname)
 {
+	if (strchr(newname, '/')) {
+		log_error("Name \"%s\" invalid. It contains \"/\".", newname);
+		return 0;
+	}
+
+	if (strlen(newname) >= DM_NAME_LEN) {
+		log_error("Name \"%s\" too long", newname);
+		return 0;
+	}
+
 	if (!(dmt->newname = dm_strdup(newname))) {
 		log_error("dm_task_set_newname: strdup(%s) failed", newname);
 		return 0;


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-18 19:34 LVM2 ./WHATS_NEW_DM libdm/libdm-common.c libdm zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-03-05 12:48 prajnoha
2012-03-05 12:43 prajnoha
2012-01-09 12:26 zkabelac
2011-03-02  0:29 agk
2009-01-07 12:17 prajnoha

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