Skip to contentSkip to conversation

LVM2 ./WHATS_NEW lib/activate/activate.h lib/a ...

PATCH [email protected] 4 participants 4 messages May 13, 2010 – May 14, 2010

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mbroz at sourceware.org 2010-05-13 18:38:40

Modified files:

	.              : WHATS_NEW 
	lib/activate   : activate.h dev_manager.c 
	lib/filters    : filter.c 

Log message:
Skip also special lvm devices in scan (if ignore suspended is used).

This should avoid various races between dmeventd on multiple nodes in cluster where one node already repairing device and another run full scan and locks the device.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1556&r2=1.1557
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.187&r2=1.188
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.65 - 
 =================================
+  Skip internal lvm devices in scan if ignore suspended devices is requested.
   Do not merge old device cache after we run full scan. (2.02.56)
   Add pkgconfigdir Makefile variable for make install override.
   Switch usage of Libs.private: to Requires.private: in devmapper.pc, lvm2app.pc.
lib/activate/activate.h +1 -1
@@ -110,6 +110,6 @@
 /*
  * Returns 1 if mapped device is not suspended.
  */
-int device_is_usable(dev_t dev);
+int device_is_usable(struct device *dev);
 
 #endif
lib/activate/dev_manager.c +14 -4
@@ -126,11 +126,11 @@
 	return r;
 }
 
-int device_is_usable(dev_t dev)
+int device_is_usable(struct device *dev)
 {
 	struct dm_task *dmt;
 	struct dm_info info;
-	const char *name;
+	const char *name, *uuid;
 	uint64_t start, length;
 	char *target_type = NULL;
 	char *params;
@@ -142,7 +142,7 @@
 		return 0;
 	}
 
-	if (!dm_task_set_major_minor(dmt, MAJOR(dev), MINOR(dev), 1))
+	if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1))
 		goto_out;
 
 	if (!dm_task_run(dmt)) {
@@ -157,6 +157,7 @@
 		goto out;
 
 	name = dm_task_get_name(dmt);
+	uuid = dm_task_get_uuid(dmt);
 
 	/* FIXME Also check for mirror block_on_error and mpath no paths */
 	/* For now, we exclude all mirrors */
@@ -165,12 +166,21 @@
 		next = dm_get_next_target(dmt, next, &start, &length,
 					  &target_type, &params);
 		/* Skip if target type doesn't match */
-		if (target_type && !strcmp(target_type, "mirror"))
+		if (target_type && !strcmp(target_type, "mirror")) {
+			log_debug("%s: Mirror device not usable.", dev_name(dev));
 			goto out;
+		}
 	} while (next);
 
 	/* FIXME Also check dependencies? */
 
+	/* Check internal lvm devices */
+	if (is_reserved_lvname(name) && uuid &&
+	    !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
+		log_debug("%s: Reserved internal LVM device not usable.", dev_name(dev));
+		goto out;
+	}
+
 	r = 1;
 
       out:
lib/filters/filter.c +2 -2
@@ -132,8 +132,8 @@
 
 	/* Skip suspended devices */
 	if (MAJOR(dev->dev) == _device_mapper_major &&
-	    ignore_suspended_devices() && !device_is_usable(dev->dev)) {
-		log_debug("%s: Skipping: Suspended dm device", name);
+	    ignore_suspended_devices() && !device_is_usable(dev)) {
+		log_debug("%s: Skipping: Suspended or internal dm device", name);
 		return 0;
 	}
 
#1 lore raw

lib/activate/dev_manager.c line 182

Quoted 6 lines · mbroz at sourceware.org
lib/activate/dev_manager.c +6 -0
+	/* Check internal lvm devices */
+	if (is_reserved_lvname(name) && uuid &&
+	    !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
+		log_debug("%s: Reserved internal LVM device not usable.", dev_name(dev));
+		goto out;
+	}

Mixing up types there.
name is a dm device name

is_reserved_lvname() accepts an lvname.

They are not the same thing.

E.g. A simple test gives me this bogus error:
/dev/mapper/pvmove-lvol0: Reserved internal LVM device not usable.

Either perform a type conversion (e.g. using dm_split_lvm_name) or add a specialist validation function (e.g. move the layer suffix checks out to a separate shared fn and only pass the LV name part for checking; it wouldn't be necessary to un-escape the hyphens, but you would have to parse them properly to find the start of the LV name).

Another matter we need to consider is this:
# If, while scanning the system for PVs, LVM2 encounters a device-mapper # device that has its I/O suspended, it waits for it to become accessible. # Set this to 1 to skip such devices. This should only be needed # in recovery situations.
ignore_suspended_devices = 0

i.e. The default is *disabled*. (Well, dmeventd may always enable it of course.)

But should the new check in this patch be independent of that setting and be *always* enabled?

Alasdair

#2 lore raw
Quoted 4 lines · Alasdair G Kergon

Mixing up types there.
name is a dm device name

yep. ok with that patch? (we have no mempool available there, that's why dm_strdup)

lib/activate/dev_manager.c +13 -5
index 710b3ae..d01bd63 100644
@@ -133,7 +133,7 @@ int device_is_usable(struct device *dev)
 	const char *name, *uuid;
 	uint64_t start, length;
 	char *target_type = NULL;
-	char *params;
+	char *params, *vgname = NULL, *lvname, *layer;
 	void *next = NULL;
 	int r = 0;
 
@@ -175,15 +175,23 @@ int device_is_usable(struct device *dev)
 	/* FIXME Also check dependencies? */
 
 	/* Check internal lvm devices */
-	if (is_reserved_lvname(name) && uuid &&
-	    !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
-		log_debug("%s: Reserved internal LVM device not usable.", dev_name(dev));
-		goto out;
+	if (uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
+		if (!(vgname = dm_strdup(name)) ||
+		    !dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
+			goto_out;
+
+		if (lvname && is_reserved_lvname(lvname)) {
+			log_debug("%s: Reserved internal LV device %s/%s not usable.",
+				  dev_name(dev), vgname, lvname);
+			goto out;
+		}
 	}
 
 	r = 1;
 
       out:
+	if (vgname)
+		dm_free(vgname);
 	dm_task_destroy(dmt);
 	return r;
 }
#3 lore raw

Dne 14.5.2010 11:00, Milan Broz napsal(a):

Quoted 13 lines · Alasdair G Kergon
Quoted 4 lines

Mixing up types there.
name is a dm device name

yep. ok with that patch? (we have no mempool available there, that's why dm_strdup)

lib/activate/dev_manager.c +0 -0
index 710b3ae..d01bd63 100644

lib/activate/dev_manager.c int device_is_usable(struct device *dev) · line 137

Quoted 5 lines
lib/activate/dev_manager.c +1 -0
@@ -133,7 +133,7 @@ int device_is_usable(struct device *dev)
 
 	r = 1;
 
       out:
+	if (vgname)

- this check is not really needed and done by dm_free itself.

lib/activate/dev_manager.c int device_is_usable(struct device *dev) · line 194

Quoted 1 line
lib/activate/dev_manager.c +1 -0
+		dm_free(vgname);

Zdenek