public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW ./WHATS_NEW_DM lib/activate/d ...
@ 2011-03-18 12:18 mbroz
  0 siblings, 0 replies; 4+ messages in thread
From: mbroz @ 2011-03-18 12:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-03-18 12:17:58

Modified files:
	.              : WHATS_NEW WHATS_NEW_DM 
	lib/activate   : dev_manager.c 
	libdm/ioctl    : libdm-iface.c 

Log message:
	Mitigate some warnings if running as non-root user.
	
	LVM doesn't behave correctly if running as non-root user,
	there is warning when it detects it.
	
	Despite this, it produces many error messages, saying nothing.
	See https://bugzilla.redhat.com/show_bug.cgi?id=620571
	
	This patch fixes two things:
	1) Removes eror message from device_is_usable() which has no
	information value anyway (real warning is printed inside it).
	
	2) it fixes device-mapper initialization, if we support
	core dm module autoload and device node is present, it should
	fail early and not try recreate existing and correct node.
	(non-root == permission denied here)
	
	N.B. In future code should support user roles, some more
	drastic checks in code are probably contraproductive now.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1956&r2=1.1957
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.455&r2=1.456
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.214&r2=1.215
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100

--- LVM2/WHATS_NEW	2011/03/14 17:00:58	1.1956
+++ LVM2/WHATS_NEW	2011/03/18 12:17:57	1.1957
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Mitigate annoying error warning from device is usable check if run as non-root.
   Add missing \0 for grown debug object in _bitset_with_random_bits().
   Fix allocation of system_id buffer in volume_group structure.
   Fix readlink usage inside get_primary_dev().
--- LVM2/WHATS_NEW_DM	2011/03/10 12:48:40	1.455
+++ LVM2/WHATS_NEW_DM	2011/03/18 12:17:57	1.456
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Fallback to control node creation only if node doesn't exist yet.
   Change dm_hash API for binary data to accept const void *key.
   Fix memory access of empty params string in _reload_with_suppression_v4().
   Lower severity of selabel_lookup and matchpathcon failure to log_debug.
--- LVM2/lib/activate/dev_manager.c	2011/02/28 19:53:03	1.214
+++ LVM2/lib/activate/dev_manager.c	2011/03/18 12:17:58	1.215
@@ -141,10 +141,8 @@
 	int only_error_target = 1;
 	int r = 0;
 
-	if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
-		log_error("Failed to create dm_task struct to check dev status");
-		return 0;
-	}
+	if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
+		return_0;
 
 	if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1))
 		goto_out;
--- LVM2/libdm/ioctl/libdm-iface.c	2011/03/08 22:43:20	1.99
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/03/18 12:17:58	1.100
@@ -365,8 +365,9 @@
 	_close_control_fd();
 
 	if ((_control_fd = open(control, O_RDWR)) < 0) {
-		if (!(ignore_nodev && errno == ENODEV))
-			log_sys_error("open", control);
+		if (ignore_nodev && errno == ENODEV)
+			return 1;
+		log_sys_error("open", control);
 		return 0;
 	}
 
@@ -412,7 +413,9 @@
 		    !_create_control(control, major, MAPPER_CTRL_MINOR))
 			goto error;
 
-		_open_and_assign_control_fd(control, 1);
+		/* Fallback to old code only if control node doesn't exist */
+		if (!_open_and_assign_control_fd(control, 1))
+			goto error;
 	}
 
 	/*


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

* LVM2 ./WHATS_NEW ./WHATS_NEW_DM lib/activate/d ...
@ 2009-07-31 18:30 agk
  0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2009-07-31 18:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-31 18:30:32

Modified files:
	.              : WHATS_NEW WHATS_NEW_DM 
	lib/activate   : dev_manager.c 
	libdm          : .exported_symbols libdevmapper.h 
	                 libdm-deptree.c 

Log message:
	Set cookies in activation code and wait for udev to complete processing.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1222&r2=1.1223
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.290&r2=1.291
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.153&r2=1.154
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/.exported_symbols.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54

--- LVM2/WHATS_NEW	2009/07/31 17:51:45	1.1222
+++ LVM2/WHATS_NEW	2009/07/31 18:30:31	1.1223
@@ -1,7 +1,6 @@
 Version 2.02.51 - 
 ================================
-  Add udevcomplete and --noudevwait to dmsetup.
-  Add libdevmapper functions to support synchronisation with udev.
+  Set cookies in activation code and wait for udev to complete processing.
   Added configure --enable-udev_rules --enable-udev_sync.
   Added configure --with-udev-prefix --with-udevdir.
   Added udev dir to hold udev rules.
--- LVM2/WHATS_NEW_DM	2009/07/28 20:47:40	1.290
+++ LVM2/WHATS_NEW_DM	2009/07/31 18:30:31	1.291
@@ -1,5 +1,7 @@
 Version 1.02.36 -
 ================================
+  Add udevcomplete and --noudevwait to dmsetup.
+  Add libdevmapper functions to support synchronisation with udev.
 
 Version 1.02.35 - 28th July 2009
 ================================
--- LVM2/lib/activate/dev_manager.c	2009/06/17 20:55:24	1.153
+++ LVM2/lib/activate/dev_manager.c	2009/07/31 18:30:31	1.154
@@ -1131,8 +1131,12 @@
 		if (!*layer)
 			continue;
 
-		if (!dm_tree_deactivate_children(root, uuid, strlen(uuid)))
+		dm_tree_set_cookie(root, 0);
+		if (!dm_tree_deactivate_children(root, uuid, strlen(uuid))) {
+			dm_udev_cleanup(dm_tree_get_cookie(root));
 			return_0;
+		}
+		dm_udev_wait(dm_tree_get_cookie(root));
 	}
 
 	return 1;
@@ -1165,8 +1169,12 @@
 		break;
 	case DEACTIVATE:
  		/* Deactivate LV and all devices it references that nothing else has open. */
-		if (!dm_tree_deactivate_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1))
+		dm_tree_set_cookie(root, 0);
+		if (!dm_tree_deactivate_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1)) {
+			dm_udev_cleanup(dm_tree_get_cookie(root));
 			goto_out;
+		}
+		dm_udev_wait(dm_tree_get_cookie(root));
 		if (!_remove_lv_symlinks(dm, root))
 			log_error("Failed to remove all device symlinks associated with %s.", lv->name);
 		break;
@@ -1185,15 +1193,24 @@
 			goto_out;
 
 		/* Preload any devices required before any suspensions */
-		if (!dm_tree_preload_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1))
+		dm_tree_set_cookie(root, 0);
+		if (!dm_tree_preload_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1)) {
+			dm_udev_cleanup(dm_tree_get_cookie(root));
 			goto_out;
+		}
+		dm_udev_wait(dm_tree_get_cookie(root));
 
 		if (dm_tree_node_size_changed(root))
 			dm->flush_required = 1;
 
-		if ((action == ACTIVATE) &&
-		    !dm_tree_activate_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1))
-			goto_out;
+		if (action == ACTIVATE) {
+			dm_tree_set_cookie(root, 0);
+			if (!dm_tree_activate_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1)) {
+				dm_udev_cleanup(dm_tree_get_cookie(root));
+				goto_out;
+			}
+			dm_udev_wait(dm_tree_get_cookie(root));
+		}
 
 		if (!_create_lv_symlinks(dm, root)) {
 			log_error("Failed to create symlinks for %s.", lv->name);
--- LVM2/libdm/.exported_symbols	2009/07/31 17:51:46	1.40
+++ LVM2/libdm/.exported_symbols	2009/07/31 18:30:31	1.41
@@ -79,6 +79,8 @@
 dm_tree_node_set_read_ahead
 dm_tree_skip_lockfs
 dm_tree_use_no_flush_suspend
+dm_tree_set_cookie
+dm_tree_get_cookie
 dm_is_dm_major
 dm_mknodes
 dm_malloc_aux
--- LVM2/libdm/libdevmapper.h	2009/07/31 17:51:46	1.93
+++ LVM2/libdm/libdevmapper.h	2009/07/31 18:30:32	1.94
@@ -433,6 +433,9 @@
 				 uint32_t read_ahead,
 				 uint32_t read_ahead_flags);
 
+void dm_tree_set_cookie(struct dm_tree_node *node, uint32_t cookie);
+uint32_t dm_tree_get_cookie(struct dm_tree_node *node);
+
 /*****************************************************************************
  * Library functions
  *****************************************************************************/
--- LVM2/libdm/libdm-deptree.c	2009/07/07 16:36:05	1.53
+++ LVM2/libdm/libdm-deptree.c	2009/07/31 18:30:32	1.54
@@ -141,6 +141,7 @@
 	struct dm_tree_node root;
 	int skip_lockfs;		/* 1 skips lockfs (for non-snapshots) */
 	int no_flush;		/* 1 sets noflush (mirrors/multipath) */
+	uint32_t cookie;
 };
 
 struct dm_tree *dm_tree_create(void)
@@ -819,10 +820,10 @@
 	return r;
 }
 
-static int _deactivate_node(const char *name, uint32_t major, uint32_t minor)
+static int _deactivate_node(const char *name, uint32_t major, uint32_t minor, uint32_t *cookie)
 {
 	struct dm_task *dmt;
-	int r;
+	int r = 0;
 
 	log_verbose("Removing %s (%" PRIu32 ":%" PRIu32 ")", name, major, minor);
 
@@ -833,26 +834,33 @@
 
 	if (!dm_task_set_major(dmt, major) || !dm_task_set_minor(dmt, minor)) {
 		log_error("Failed to set device number for %s deactivation", name);
-		dm_task_destroy(dmt);
-		return 0;
+		goto out;
 	}
 
 	if (!dm_task_no_open_count(dmt))
 		log_error("Failed to disable open_count");
 
+	if (!dm_task_set_cookie(dmt, cookie))
+		goto out;
+
 	r = dm_task_run(dmt);
 
+	if (!r)
+		(void) dm_udev_complete(*cookie);
+
 	/* FIXME Until kernel returns actual name so dm-ioctl.c can handle it */
 	rm_dev_node(name);
 
 	/* FIXME Remove node from tree or mark invalid? */
 
+out:
 	dm_task_destroy(dmt);
 
 	return r;
 }
 
-static int _rename_node(const char *old_name, const char *new_name, uint32_t major, uint32_t minor)
+static int _rename_node(const char *old_name, const char *new_name, uint32_t major,
+			uint32_t minor, uint32_t *cookie)
 {
 	struct dm_task *dmt;
 	int r = 0;
@@ -875,8 +883,14 @@
 	if (!dm_task_no_open_count(dmt))
 		log_error("Failed to disable open_count");
 
+	if (!dm_task_set_cookie(dmt, cookie))
+		goto out;
+
 	r = dm_task_run(dmt);
 
+	if (!r)
+		(void) dm_udev_complete(*cookie);
+
 out:
 	dm_task_destroy(dmt);
 
@@ -886,10 +900,10 @@
 /* FIXME Merge with _suspend_node? */
 static int _resume_node(const char *name, uint32_t major, uint32_t minor,
 			uint32_t read_ahead, uint32_t read_ahead_flags,
-			struct dm_info *newinfo)
+			struct dm_info *newinfo, uint32_t *cookie)
 {
 	struct dm_task *dmt;
-	int r;
+	int r = 0;
 
 	log_verbose("Resuming %s (%" PRIu32 ":%" PRIu32 ")", name, major, minor);
 
@@ -901,14 +915,12 @@
 	/* FIXME Kernel should fill in name on return instead */
 	if (!dm_task_set_name(dmt, name)) {
 		log_error("Failed to set readahead device name for %s", name);
-		dm_task_destroy(dmt);
-		return 0;
+		goto out;
 	}
 
 	if (!dm_task_set_major(dmt, major) || !dm_task_set_minor(dmt, minor)) {
 		log_error("Failed to set device number for %s resumption.", name);
-		dm_task_destroy(dmt);
-		return 0;
+		goto out;
 	}
 
 	if (!dm_task_no_open_count(dmt))
@@ -917,9 +929,15 @@
 	if (!dm_task_set_read_ahead(dmt, read_ahead, read_ahead_flags))
 		log_error("Failed to set read ahead");
 
+	if (!dm_task_set_cookie(dmt, cookie))
+		goto out;
+
 	if ((r = dm_task_run(dmt)))
 		r = dm_task_get_info(dmt, newinfo);
+	else
+		(void) dm_udev_complete(*cookie);
 
+out:
 	dm_task_destroy(dmt);
 
 	return r;
@@ -1000,7 +1018,7 @@
 		    !info.exists || info.open_count)
 			continue;
 
-		if (!_deactivate_node(name, info.major, info.minor)) {
+		if (!_deactivate_node(name, info.major, info.minor, &dnode->dtree->cookie)) {
 			log_error("Unable to deactivate %s (%" PRIu32
 				  ":%" PRIu32 ")", name, info.major,
 				  info.minor);
@@ -1144,7 +1162,8 @@
 
 			/* Rename? */
 			if (child->props.new_name) {
-				if (!_rename_node(name, child->props.new_name, child->info.major, child->info.minor)) {
+				if (!_rename_node(name, child->props.new_name, child->info.major,
+						  child->info.minor, &child->dtree->cookie)) {
 					log_error("Failed to rename %s (%" PRIu32
 						  ":%" PRIu32 ") to %s", name, child->info.major,
 						  child->info.minor, child->props.new_name);
@@ -1158,8 +1177,8 @@
 				continue;
 
 			if (!_resume_node(child->name, child->info.major, child->info.minor,
-					  child->props.read_ahead,
-					  child->props.read_ahead_flags, &newinfo)) {
+					  child->props.read_ahead, child->props.read_ahead_flags,
+					  &newinfo, &child->dtree->cookie)) {
 				log_error("Unable to resume %s (%" PRIu32
 					  ":%" PRIu32 ")", child->name, child->info.major,
 					  child->info.minor);
@@ -1525,8 +1544,8 @@
 			continue;
 
 		if (!_resume_node(child->name, child->info.major, child->info.minor,
-				  child->props.read_ahead,
-				  child->props.read_ahead_flags, &newinfo)) {
+				  child->props.read_ahead, child->props.read_ahead_flags,
+				  &newinfo, &child->dtree->cookie)) {
 			log_error("Unable to resume %s (%" PRIu32
 				  ":%" PRIu32 ")", child->name, child->info.major,
 				  child->info.minor);
@@ -1842,3 +1861,13 @@
 
 	return 1;
 }
+
+void dm_tree_set_cookie(struct dm_tree_node *node, uint32_t cookie)
+{
+	node->dtree->cookie = cookie;
+}
+
+uint32_t dm_tree_get_cookie(struct dm_tree_node *node)
+{
+	return node->dtree->cookie;
+}


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

* LVM2 ./WHATS_NEW ./WHATS_NEW_DM lib/activate/d ...
@ 2009-06-17 20:55 mbroz
  0 siblings, 0 replies; 4+ messages in thread
From: mbroz @ 2009-06-17 20:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-17 20:55:25

Modified files:
	.              : WHATS_NEW WHATS_NEW_DM 
	lib/activate   : dev_manager.c 
	libdm          : .exported_symbols libdevmapper.h libdm-common.c 
	libdm/ioctl    : libdm-iface.c libdm-targets.h 

Log message:
	Fix backward compatibility for major:minor query.
	
	Is an application uses query and set major:minor
	to device, it should not fallback to default major by default.
	
	Add new function whoich allows that (and use it in lvm2).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1152&r2=1.1153
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.277&r2=1.278
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.152&r2=1.153
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/.exported_symbols.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.89&r2=1.90
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-targets.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24

--- LVM2/WHATS_NEW	2009/06/15 15:09:02	1.1152
+++ LVM2/WHATS_NEW	2009/06/17 20:55:24	1.1153
@@ -1,5 +1,6 @@
 Version 2.02.48 - 
 ===============================
+  Explicitly request fallback to default major number in device mapper.
   Ignore suspended devices during repair.
   Call vgreduce --removemissing automatically to clean up bad PVs in dmeventd.
   Suggest use lvchange --resync when up converting not yet synced mirror.
--- LVM2/WHATS_NEW_DM	2009/06/15 12:29:41	1.277
+++ LVM2/WHATS_NEW_DM	2009/06/17 20:55:24	1.278
@@ -1,5 +1,6 @@
 Version 1.02.33 -
 ===============================
+  Do not fallback to default major number, provide new function instead (1.02.31)
   Do not fork daemon when dmeventd cannot be found.
   Add crypt target handling to libdevmapper node.
   Add splitname command to dmsetup.
--- LVM2/lib/activate/dev_manager.c	2009/06/01 12:43:32	1.152
+++ LVM2/lib/activate/dev_manager.c	2009/06/17 20:55:24	1.153
@@ -111,10 +111,8 @@
 	if (event_nr)
 		dm_task_set_event_nr(dmt, *event_nr);
 
-	if (major) {
-		dm_task_set_major(dmt, major);
-		dm_task_set_minor(dmt, minor);
-	}
+	if (major)
+		dm_task_set_major_minor(dmt, major, minor, 1);
 
 	return dmt;
 }
@@ -171,7 +169,7 @@
 		return 0;
 	}
 
-	if (!dm_task_set_major(dmt, MAJOR(dev)) || !dm_task_set_minor(dmt, MINOR(dev)))
+	if (!dm_task_set_major_minor(dmt, MAJOR(dev), MINOR(dev), 1))
 		goto_out;
 
 	if (!dm_task_run(dmt)) {
--- LVM2/libdm/.exported_symbols	2009/06/09 16:10:24	1.36
+++ LVM2/libdm/.exported_symbols	2009/06/17 20:55:24	1.37
@@ -24,6 +24,7 @@
 dm_task_set_event_nr
 dm_task_set_major
 dm_task_set_minor
+dm_task_set_major_minor
 dm_task_set_sector
 dm_task_set_message
 dm_task_set_uid
--- LVM2/libdm/libdevmapper.h	2009/06/09 16:10:24	1.89
+++ LVM2/libdm/libdevmapper.h	2009/06/17 20:55:24	1.90
@@ -145,6 +145,7 @@
 int dm_task_set_newname(struct dm_task *dmt, const char *newname);
 int dm_task_set_minor(struct dm_task *dmt, int minor);
 int dm_task_set_major(struct dm_task *dmt, int major);
+int dm_task_set_major_minor(struct dm_task *dmt, int major, int minor, int allow_default_major_fallback);
 int dm_task_set_uid(struct dm_task *dmt, uid_t uid);
 int dm_task_set_gid(struct dm_task *dmt, gid_t gid);
 int dm_task_set_mode(struct dm_task *dmt, mode_t mode);
--- LVM2/libdm/libdm-common.c	2009/01/07 12:17:40	1.64
+++ LVM2/libdm/libdm-common.c	2009/06/17 20:55:24	1.65
@@ -118,6 +118,7 @@
 	dmt->type = type;
 	dmt->minor = -1;
 	dmt->major = -1;
+	dmt->allow_default_major_fallback = 1;
 	dmt->uid = DM_DEVICE_UID;
 	dmt->gid = DM_DEVICE_GID;
 	dmt->mode = DM_DEVICE_MODE;
@@ -190,6 +191,7 @@
 int dm_task_set_major(struct dm_task *dmt, int major)
 {
 	dmt->major = major;
+	dmt->allow_default_major_fallback = 0;
 
 	return 1;
 }
@@ -201,6 +203,16 @@
 	return 1;
 }
 
+int dm_task_set_major_minor(struct dm_task *dmt, int major, int minor,
+			    int allow_default_major_fallback)
+{
+	dmt->major = major;
+	dmt->minor = minor;
+	dmt->allow_default_major_fallback = allow_default_major_fallback;
+
+	return 1;
+}
+
 int dm_task_set_uid(struct dm_task *dmt, uid_t uid)
 {
 	dmt->uid = uid;
--- LVM2/libdm/ioctl/libdm-iface.c	2009/04/10 09:56:58	1.57
+++ LVM2/libdm/ioctl/libdm-iface.c	2009/06/17 20:55:25	1.58
@@ -1335,7 +1335,8 @@
 			goto bad;
 		}
 
-		if (!_dm_multiple_major_support && dmt->major != _dm_device_major) {
+		if (!_dm_multiple_major_support && dmt->allow_default_major_fallback &&
+		    dmt->major != _dm_device_major) {
 			log_verbose("Overriding major number of %" PRIu32 
 				    " with %" PRIu32 " for persistent device.",
 				    dmt->major, _dm_device_major);
--- LVM2/libdm/ioctl/libdm-targets.h	2008/09/18 18:34:53	1.23
+++ LVM2/libdm/ioctl/libdm-targets.h	2009/06/17 20:55:25	1.24
@@ -41,6 +41,7 @@
 	uint32_t event_nr;
 	int major;
 	int minor;
+	int allow_default_major_fallback;
 	uid_t uid;
 	gid_t gid;
 	mode_t mode;


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

* LVM2 ./WHATS_NEW ./WHATS_NEW_DM lib/activate/d ...
@ 2009-02-12 20:42 agk
  0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2009-02-12 20:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-02-12 20:42:08

Modified files:
	.              : WHATS_NEW WHATS_NEW_DM 
	lib/activate   : dev_manager.c 
	libdm/ioctl    : libdm-iface.c 

Log message:
	If kernel supports only one dm major number, use in place of any supplied.
	No longer require kernel and metadata major numbers to match.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1042&r2=1.1043
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.262&r2=1.263
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.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.55&r2=1.56

--- LVM2/WHATS_NEW	2009/02/11 10:13:20	1.1042
+++ LVM2/WHATS_NEW	2009/02/12 20:42:07	1.1043
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  No longer require kernel and metadata major numbers to match.
   Add a fully-functional get_cluster_name() to clvmd corosync interface.
   Remove duplicate cpg_initialize from clvmd startup.
   Add option to /etc/sysconfig/cluster to select cluster type for clvmd.
--- LVM2/WHATS_NEW_DM	2009/01/26 14:46:09	1.262
+++ LVM2/WHATS_NEW_DM	2009/02/12 20:42:07	1.263
@@ -1,5 +1,6 @@
 Version 1.02.31 - 
 ====================================
+  If kernel supports only one dm major number, use in place of any supplied.
 
 Version 1.02.30 - 26th January 2009
 ====================================
--- LVM2/lib/activate/dev_manager.c	2008/12/19 15:23:03	1.144
+++ LVM2/lib/activate/dev_manager.c	2009/02/12 20:42:07	1.145
@@ -640,7 +640,10 @@
 	 * requested major/minor and that major/minor pair is available for use
 	 */
 	if (!layer && lv->major != -1 && lv->minor != -1) {
-		if (info.exists && (info.major != lv->major || info.minor != lv->minor)) {
+		/*
+		 * FIXME compare info.major with lv->major if multiple major support
+		 */
+		if (info.exists && (info.minor != lv->minor)) {
 			log_error("Volume %s (%" PRIu32 ":%" PRIu32")"
 				  " differs from already active device "
 				  "(%" PRIu32 ":%" PRIu32")",
--- LVM2/libdm/ioctl/libdm-iface.c	2009/01/07 12:17:40	1.55
+++ LVM2/libdm/ioctl/libdm-iface.c	2009/02/12 20:42:07	1.56
@@ -24,6 +24,7 @@
 #include <fcntl.h>
 #include <dirent.h>
 #include <sys/ioctl.h>
+#include <sys/utsname.h>
 #include <limits.h>
 
 #ifdef linux
@@ -63,12 +64,22 @@
 static unsigned _dm_version_patchlevel = 0;
 static int _log_suppress = 0;
 
+/*
+ * If the kernel dm driver only supports one major number
+ * we store it in _dm_device_major.  Otherwise we indicate
+ * which major numbers have been claimed by device-mapper
+ * in _dm_bitset.
+ */
+static unsigned _dm_multiple_major_support = 1;
 static dm_bitset_t _dm_bitset = NULL;
+static uint32_t _dm_device_major = 0;
+
 static int _control_fd = -1;
 static int _version_checked = 0;
 static int _version_ok = 1;
 static unsigned _ioctl_buffer_double_factor = 0;
 
+
 /*
  * Support both old and new major numbers to ease the transition.
  * Clumsy, but only temporary.
@@ -249,12 +260,35 @@
 }
 #endif
 
+/*
+ * FIXME Update bitset in long-running process if dm claims new major numbers.
+ */
 static int _create_dm_bitset(void)
 {
 #ifdef DM_IOCTLS
-	if (_dm_bitset)
+	struct utsname uts;
+
+	if (_dm_bitset || _dm_device_major)
+		return 1;
+
+	if (uname(&uts))
+		return 0;
+
+	/*
+	 * 2.6 kernels are limited to one major number.
+	 * Assume 2.4 kernels are patched not to.
+	 * FIXME Check _dm_version and _dm_version_minor if 2.6 changes this.
+	 */
+	if (!strncmp(uts.release, "2.6.", 4))
+		_dm_multiple_major_support = 0;
+
+	if (!_dm_multiple_major_support) {
+		if (!_get_proc_number(PROC_DEVICES, DM_NAME, &_dm_device_major))
+			return 0;
 		return 1;
+	}
 
+	/* Multiple major numbers supported */
 	if (!(_dm_bitset = dm_bitset_create(NULL, NUMBER_OF_MAJORS)))
 		return 0;
 
@@ -275,7 +309,10 @@
 	if (!_create_dm_bitset())
 		return 0;
 
-	return dm_bit(_dm_bitset, major) ? 1 : 0;
+	if (_dm_multiple_major_support)
+		return dm_bit(_dm_bitset, major) ? 1 : 0;
+	else
+		return (major == _dm_device_major) ? 1 : 0;
 }
 
 static int _open_control(void)
@@ -1297,6 +1334,14 @@
 			log_error("Missing major number for persistent device.");
 			goto bad;
 		}
+
+		if (!_dm_multiple_major_support && dmt->major != _dm_device_major) {
+			log_verbose("Overriding major number of %" PRIu32 
+				    " with %" PRIu32 " for persistent device.",
+				    dmt->major, _dm_device_major);
+			dmt->major = _dm_device_major;
+		}
+
 		dmi->flags |= DM_PERSISTENT_DEV_FLAG;
 		dmi->dev = MKDEV(dmt->major, dmt->minor);
 	}


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

end of thread, other threads:[~2011-03-18 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 12:18 LVM2 ./WHATS_NEW ./WHATS_NEW_DM lib/activate/d mbroz
  -- strict thread matches above, loose matches on Subject: below --
2009-07-31 18:30 agk
2009-06-17 20:55 mbroz
2009-02-12 20:42 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).