]> sourceware.org Git - dm.git/commitdiff
Resume snapshot-origins last.
authorAlasdair Kergon <agk@redhat.com>
Tue, 22 Nov 2005 20:00:35 +0000 (20:00 +0000)
committerAlasdair Kergon <agk@redhat.com>
Tue, 22 Nov 2005 20:00:35 +0000 (20:00 +0000)
lib/libdm-deptree.c

index de7dc4c1f7ba99d53d42a67bda8685a8d8754496..f6447d9c61eba3bfd08f83f05a6ba59ebf1fa585 100644 (file)
@@ -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;
 }
 
This page took 0.030664 seconds and 5 git commands to generate.