From 6116333ccc4969e69bfd10aa0fe64238dc7f4dab Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 24 Feb 2014 09:36:38 +0100 Subject: [PATCH] libdm: proper traversion of revert list Deactivation of top level node has to happen, before traversing subtree. Swap list logic and rather append new nodes to the head and then use normal iteration. (in-release update) --- libdm/libdm-deptree.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 7fcc7ed59..764074d2f 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -2625,13 +2625,16 @@ out: return r; } +/* + * Currently try to deactivate only nodes created during preload. + * New node is always attached to the front of activated_list + */ static int _dm_tree_revert_activated(struct dm_tree_node *parent) { struct dm_tree_node *child; - dm_list_iterate_back_items_gen(child, &parent->activated, activated_list) { - _dm_tree_revert_activated(child); - log_debug("Reverting preloaded %s.", child->name); + dm_list_iterate_items_gen(child, &parent->activated, activated_list) { + log_debug_activation("Reverting %s.", child->name); if (!_deactivate_node(child->name, child->info.major, child->info.minor, &child->dtree->cookie, child->udev_flags, 0)) { log_error("Unable to deactivate %s (%" PRIu32 @@ -2639,6 +2642,8 @@ static int _dm_tree_revert_activated(struct dm_tree_node *parent) child->info.minor); return 0; } + if (!_dm_tree_revert_activated(child)) + return_0; } return 1; @@ -2708,9 +2713,10 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, continue; } - if (!child->info.live_table) + if (!child->info.live_table) { /* Collect newly introduced devices for revert */ - dm_list_add(&dnode->activated, &child->activated_list); + dm_list_add_h(&dnode->activated, &child->activated_list); + } /* Update cached info */ child->info = newinfo;