From: Alasdair Kergon Date: Tue, 22 Nov 2005 20:00:35 +0000 (+0000) Subject: Resume snapshot-origins last. X-Git-Tag: v1_02_01~1 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=1bb438b415ac69e8d66e97ffdd41f564084a2e46;p=dm.git Resume snapshot-origins last. --- diff --git a/lib/libdm-deptree.c b/lib/libdm-deptree.c index de7dc4c..f6447d9 100644 --- a/lib/libdm-deptree.c +++ b/lib/libdm-deptree.c @@ -115,6 +115,8 @@ struct dm_tree_node { struct list uses; /* Nodes this node uses */ struct list used_by; /* Nodes that use this node */ + int activation_priority; /* 0 gets activated first */ + void *context; /* External supplied context */ struct load_properties props; /* For creation/table (re)load */ @@ -313,6 +315,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree, node->uuid = uuid; node->info = *info; node->context = context; + node->activation_priority = 0; list_init(&node->uses); list_init(&node->used_by); @@ -1055,6 +1058,7 @@ int dm_tree_activate_children(struct dm_tree_node *dnode, struct dm_info newinfo; const char *name; const char *uuid; + int priority; /* Activate children first */ while ((child = dm_tree_next_child(&handle, dnode, 0))) { @@ -1068,36 +1072,53 @@ int dm_tree_activate_children(struct dm_tree_node *dnode, if (dm_tree_node_num_children(child, 0)) dm_tree_activate_children(child, uuid_prefix, uuid_prefix_len); + } - if (!(name = dm_tree_node_get_name(child))) { - stack; - continue; - } + handle = NULL; - /* Rename? */ - if (child->props.new_name) { - if (!_rename_node(name, child->props.new_name, child->info.major, child->info.minor)) { - log_error("Failed to rename %s (%" PRIu32 - ":%" PRIu32 ") to %s", name, child->info.major, - child->info.minor, child->props.new_name); - return 0; + for (priority = 0; priority < 2; priority++) { + while ((child = dm_tree_next_child(&handle, dnode, 0))) { + if (!(uuid = dm_tree_node_get_uuid(child))) { + stack; + continue; } - child->name = child->props.new_name; - child->props.new_name = NULL; - } - if (!child->info.inactive_table && !child->info.suspended) - continue; + if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) + continue; - if (!_resume_node(name, child->info.major, child->info.minor, &newinfo)) { - log_error("Unable to resume %s (%" PRIu32 - ":%" PRIu32 ")", name, child->info.major, - child->info.minor); - continue; - } + if (priority != child->activation_priority) + continue; - /* Update cached info */ - child->info = newinfo; + if (!(name = dm_tree_node_get_name(child))) { + stack; + continue; + } + + /* Rename? */ + if (child->props.new_name) { + if (!_rename_node(name, child->props.new_name, child->info.major, child->info.minor)) { + log_error("Failed to rename %s (%" PRIu32 + ":%" PRIu32 ") to %s", name, child->info.major, + child->info.minor, child->props.new_name); + return 0; + } + child->name = child->props.new_name; + child->props.new_name = NULL; + } + + if (!child->info.inactive_table && !child->info.suspended) + continue; + + if (!_resume_node(name, child->info.major, child->info.minor, &newinfo)) { + log_error("Unable to resume %s (%" PRIu32 + ":%" PRIu32 ")", name, child->info.major, + child->info.minor); + continue; + } + + /* Update cached info */ + child->info = newinfo; + } } handle = NULL; @@ -1511,6 +1532,9 @@ int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode, if (!_link_tree_nodes(dnode, origin_node)) return_0; + /* Resume snapshot origins after new snapshots */ + dnode->activation_priority = 1; + return 1; }