From f4249251cb4de9be6cccf2c9e9239f352a210d9e Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 24 Jun 2011 19:33:41 +0000 Subject: [PATCH] Return immediately dm_lib_exit() if called more than once. (Avoiding calling it twice would involve some untangling.) Decrement the new suspended_counter if removing a suspended device. --- WHATS_NEW_DM | 1 + libdm/ioctl/libdm-iface.c | 9 +++++++++ libdm/libdm-deptree.c | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index c17475f17..9654aef56 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.65 - ================================== + Return immediately dm_lib_exit() if called more than once. Disable udev fallback by default and add --udevfallback option to dmsetup. Warn if a table is loaded while a device is known to be in suspended state. Add dm_get_suspended_counter() for number of devs in suspended state by lib. diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 3028fd850..1157f25df 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -2173,6 +2173,15 @@ void dm_pools_check_leaks(void); void dm_lib_exit(void) { + int suspended_counter; + static unsigned _exited = 0; + + if (_exited++) + return; + + if ((suspended_counter = dm_get_suspended_counter())) + log_error("libdevmapper exiting with %d device(s) still suspended.", suspended_counter); + dm_lib_release(); selinux_release(); if (_dm_bitset) diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index e316a4261..ff1f0dded 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -1188,7 +1188,8 @@ static int _dm_tree_deactivate_children(struct dm_tree_node *dnode, info.minor); r = 0; continue; - } + } else if (info.suspended) + dec_suspended(); if (dm_tree_node_num_children(child, 0)) { if (!_dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len, level + 1)) -- 2.43.5