]> sourceware.org Git - dm.git/commitdiff
attempt to cope with uuid transition
authorAlasdair Kergon <agk@redhat.com>
Wed, 26 Oct 2005 15:21:13 +0000 (15:21 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 26 Oct 2005 15:21:13 +0000 (15:21 +0000)
lib/libdm-deptree.c

index 2b05823c8db23080490413fd50a736b5ce65e987..da1eeafa26207fa2f3e49b279bffb2ad0618a429 100644 (file)
@@ -362,6 +362,30 @@ int dm_deptree_node_num_children(struct deptree_node *node, uint32_t inverted)
        return list_size(&node->uses);
 }
 
+/*
+ * Returns 1 if no prefix supplied
+ */
+static int _uuid_prefix_matches(const char *uuid, const char *uuid_prefix, size_t uuid_prefix_len)
+{
+       if (!uuid_prefix)
+               return 1;
+
+       if (!strncmp(uuid, uuid_prefix, uuid_prefix_len))
+               return 1;
+
+       /* Handle transition: active device uuids might be missing the prefix */
+       if (uuid_prefix_len <= 4)
+               return 0;
+
+       if (!strcmp(uuid, "LVM-") || strcmp(uuid_prefix, "LVM-"))
+               return 0;
+
+       if (!strncmp(uuid, uuid_prefix + 4, uuid_prefix_len - 4))
+               return 1;
+
+       return 0;
+}
+
 /*
  * Returns 1 if no children.
  */
@@ -392,7 +416,7 @@ static int _children_suspended(struct deptree_node *node,
                }
 
                /* Ignore if it doesn't belong to this VG */
-               if (uuid_prefix && strncmp(uuid, uuid_prefix, uuid_prefix_len))
+               if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
                        continue;
 
                if (!(dinfo = dm_deptree_node_get_info(dlink->node))) {
@@ -563,7 +587,7 @@ int dm_deptree_deactivate_children(struct deptree_node *dnode,
                }
 
                /* Ignore if it doesn't belong to this VG */
-               if (uuid_prefix && strncmp(uuid, uuid_prefix, uuid_prefix_len))
+               if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
                        continue;
 
                /* Refresh open_count */
@@ -614,7 +638,7 @@ int dm_deptree_suspend_children(struct deptree_node *dnode,
                }
 
                /* Ignore if it doesn't belong to this VG */
-               if (uuid_prefix && strncmp(uuid, uuid_prefix, uuid_prefix_len))
+               if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
                        continue;
 
                /* Ensure immediate parents are already suspended */
This page took 0.024419 seconds and 5 git commands to generate.