[PATCH] Add a debug message for tree-based deactivation

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

 



dm_tree_deactivate_children() of libdevmapper is a function
to walk down the dm deptree and deactivate each child
(i.e. remove dm device).

Since a dm device with open count > 0 can't be removed, it checks
info.open_count before the removal.
info.open_count > 0 is valid if the device is shared from other parent.

However, even if it's not shared, the open count can be non 0 if
something temporarily opens the device, for example.
Printing the reason why it was not deactivated makes it easier
to check whether the deptree was not correctly built or such
access happened.

The debug output will look like this:
(in this case, vg-lvol0_mimage_0 and 1 had non-zero open count
 and were not removed after the deactivation of the tree)

#ioctl/libdm-iface.c:1606         dm info   (253:14) OF   [16384]
#libdm-deptree.c:830     Removing vg-lvol0 (253:14)
#ioctl/libdm-iface.c:1606         dm remove   (253:14) NF   [16384]
#ioctl/libdm-iface.c:1606         dm info   (253:16) OF   [16384]
#libdm-deptree.c:830     Removing vg-lvol0_mimage_2 (253:16)
#ioctl/libdm-iface.c:1606         dm remove   (253:16) NF   [16384]
#ioctl/libdm-iface.c:1606         dm info   (253:15) OF   [16384]
#libdm-deptree.c:830     Removing vg-lvol0_mimagetmp_2 (253:15)
#ioctl/libdm-iface.c:1606         dm remove   (253:15) NF   [16384]
#ioctl/libdm-iface.c:1606         dm info   (253:13) OF   [16384]
#libdm-deptree.c:1009         vg-lvol0_mimage_1 (253:13) has open count 1
#ioctl/libdm-iface.c:1606         dm info   (253:12) OF   [16384]
#libdm-deptree.c:1009         vg-lvol0_mimage_0 (253:12) has open count 1
#ioctl/libdm-iface.c:1606         dm info   (253:4) OF   [16384]
#libdm-deptree.c:830     Removing vg-lvol0_mlog (253:4)
#ioctl/libdm-iface.c:1606         dm remove   (253:4) NF   [16384]

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Add a verbose message useful for debugging deactivation failure.

dm_tree_deactivate_children() of libdevmapper is a function
to walk down the dm deptree and deactivate each child
(i.e. remove dm device).

Since a dm device with open count > 0 can't be removed, it checks
info.open_count before the removal.
info.open_count > 0 is valid if the device is shared from other parent.

However, even if it's not shared, the open count can be non 0 if
something temporarily opens the device, for example.
Printing the reason why it was not deactivated makes it easier
to check whether the deptree was not correctly built or such
access happened.

Index: device-mapper.work/lib/libdm-deptree.c
===================================================================
--- device-mapper.work.orig/lib/libdm-deptree.c
+++ device-mapper.work/lib/libdm-deptree.c
@@ -1000,9 +1000,16 @@ int dm_tree_deactivate_children(struct d
 
 		/* Refresh open_count */
 		if (!_info_by_dev(dinfo->major, dinfo->minor, 1, &info) ||
-		    !info.exists || info.open_count)
+		    !info.exists)
 			continue;
 
+		if (info.open_count) {
+			log_debug("%s (%" PRIu32 ":%" PRIu32 ") has open count"
+				  " %d", name, info.major, info.minor,
+				  info.open_count);
+			continue;
+		}
+
 		if (!_deactivate_node(name, info.major, info.minor)) {
 			log_error("Unable to deactivate %s (%" PRIu32
 				  ":%" PRIu32 ")", name, info.major,
--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux