[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] Never scan internal LVM devices.



Hi,

the attached patch disables scanning for any LVM-created internal
devices, such as mirror images, mirror logs, snapshot COW areas etc.

There are two reasons for this: First, scanning these devices can
disrupt more complex operations (primarily lvconvert) involving
deactivation of these internal devices. See BZs 596453, 606931 and
607316.

Second that even if such a device contains a PV label (or an MDA), it
should never be used by LVM as a PV. Since these logical volumes are
never visible to the user (disregarding any bugs in LVM) and they cannot
be created by the user, they always exist as a part of a composite
logical volume.

Even if a PV was stacked in an LV, and this LV was composite (so it is
using some internal LVs as its components), it is desirable that this
*and only* this composite LV is seen by LVM as a PV. If the PV label or
MDA is propagated into the component LVs (such as mimages) and these are
found during a scan, this would lead to the PV being found multiple
times which is certainly undesirable. Cf. the situation with MD
component devices, which is analogous.

For all I can tell, this patch would fix all the above-mentioned BZs,
which are all high-priority test blockers.

Yours,
   Petr.

PS: There are other options to address the disruption issue that is
causing all the above bugzillas. Nevertheless, all other options seem to
be too complex to implement and would run a high risk of regressions in
unrelated areas of functionality -- we have discussed this last week
with Alasdair. I believe the proposed patch is relatively simple and
does not introduce any bad behaviours (nor eliminates any desirable
behaviours).

Index: lib/activate/activate.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/activate/activate.h,v
retrieving revision 1.68
diff -u -p -r1.68 activate.h
--- lib/activate/activate.h	24 May 2010 15:32:20 -0000	1.68
+++ lib/activate/activate.h	4 Aug 2010 15:37:30 -0000
@@ -111,6 +111,6 @@ int pv_uses_vg(struct physical_volume *p
 /*
  * Returns 1 if mapped device is not suspended.
  */
-int device_is_usable(struct device *dev);
+int device_is_usable(struct device *dev, int suspended_usable);
 
 #endif
Index: lib/activate/dev_manager.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/activate/dev_manager.c,v
retrieving revision 1.197
diff -u -p -r1.197 dev_manager.c
--- lib/activate/dev_manager.c	3 Aug 2010 13:13:01 -0000	1.197
+++ lib/activate/dev_manager.c	4 Aug 2010 15:37:31 -0000
@@ -126,7 +126,7 @@ static int _info_run(const char *name, c
 	return r;
 }
 
-int device_is_usable(struct device *dev)
+int device_is_usable(struct device *dev, int suspended_usable)
 {
 	struct dm_task *dmt;
 	struct dm_info info;
@@ -153,12 +153,17 @@ int device_is_usable(struct device *dev)
 	if (!dm_task_get_info(dmt, &info))
 		goto_out;
 
-	if (!info.exists || info.suspended)
+	if (!info.exists)
 		goto out;
 
 	name = dm_task_get_name(dmt);
 	uuid = dm_task_get_uuid(dmt);
 
+	if (info.suspended && !suspended_usable) {
+		log_debug("%s: Suspended device %s not usable.", dev_name(dev), name);
+		goto out;
+	}
+
 	/* FIXME Also check for mirror block_on_error and mpath no paths */
 	/* For now, we exclude all mirrors */
 
@@ -166,8 +171,8 @@ int device_is_usable(struct device *dev)
 		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")) {
-			log_debug("%s: Mirror device not usable.", dev_name(dev));
+		if (target_type && !strcmp(target_type, "mirror") && !suspended_usable) {
+			log_debug("%s: Mirror device %s not usable.", dev_name(dev), name);
 			goto out;
 		}
 	} while (next);
Index: lib/filters/filter-persistent.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/filters/filter-persistent.c,v
retrieving revision 1.43
diff -u -p -r1.43 filter-persistent.c
--- lib/filters/filter-persistent.c	2 Jul 2010 02:09:57 -0000	1.43
+++ lib/filters/filter-persistent.c	4 Aug 2010 15:37:31 -0000
@@ -279,8 +279,8 @@ static int _lookup_p(struct dev_filter *
 		if (!l)
 			dm_list_iterate_items(sl, &dev->aliases)
 				dm_hash_insert(pf->devices, sl->str, PF_GOOD_DEVICE);
-		if (ignore_suspended_devices() && !device_is_usable(dev)) {
-                	log_debug("%s: Skipping (suspended/internal)", dev_name(dev));
+		if (!device_is_usable(dev, !ignore_suspended_devices())) {
+                	log_debug("%s: Skipping unusable device", dev_name(dev));
 			return 0;
 		}
 		return pf->real->passes_filter(pf->real, dev);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]