1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

debug: enhace device_mapper debug log for dm tree

This commit is contained in:
Zdenek Kabelac 2024-03-14 18:16:19 +01:00
parent 8c7400121e
commit 68fdae1184
2 changed files with 22 additions and 20 deletions

View File

@ -590,6 +590,7 @@ void dm_tree_set_optional_uuid_suffixes(struct dm_tree *dtree, const char **opti
dtree->optional_uuid_suffixes = optional_uuid_suffixes;
}
static const char *_node_name(struct dm_tree_node *dnode);
static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
const char *uuid)
{
@ -602,13 +603,10 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
const char **suffix_list = dtree->optional_uuid_suffixes;
if ((node = dm_hash_lookup(dtree->uuids, uuid))) {
log_debug("Matched uuid %s in deptree.", uuid);
log_debug_activation("Matched uuid %s %s in deptree.", uuid, _node_name(node));
return node;
}
default_uuid_prefix = dm_uuid_prefix();
default_uuid_prefix_len = strlen(default_uuid_prefix);
if (suffix_list && (suffix_position = strrchr(uuid, '-'))) {
while ((suffix = suffix_list[i++])) {
if (strcmp(suffix_position + 1, suffix))
@ -618,7 +616,8 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
uuid_without_suffix[suffix_position - uuid] = '\0';
if ((node = dm_hash_lookup(dtree->uuids, uuid_without_suffix))) {
log_debug("Matched uuid %s (missing suffix -%s) in deptree.", uuid_without_suffix, suffix);
log_debug_activation("Matched uuid %s %s (missing suffix -%s) in deptree.",
uuid_without_suffix, _node_name(node), suffix);
return node;
}
@ -626,15 +625,17 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
};
}
if (strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len))
return NULL;
default_uuid_prefix = dm_uuid_prefix();
default_uuid_prefix_len = strlen(default_uuid_prefix);
if ((node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
log_debug("Matched uuid %s (missing prefix) in deptree.", uuid + default_uuid_prefix_len);
if ((strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len) == 0) &&
(node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
log_debug_activation("Matched uuid %s %s (missing prefix) in deptree.",
uuid + default_uuid_prefix_len, _node_name(node));
return node;
}
log_debug("Not matched uuid %s in deptree.", uuid);
log_debug_activation("Not matched uuid %s in deptree.", uuid);
return NULL;
}

View File

@ -550,6 +550,7 @@ void dm_tree_set_optional_uuid_suffixes(struct dm_tree *dtree, const char **opti
dtree->optional_uuid_suffixes = optional_uuid_suffixes;
}
static const char *_node_name(struct dm_tree_node *dnode);
static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
const char *uuid)
{
@ -562,13 +563,10 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
const char **suffix_list = dtree->optional_uuid_suffixes;
if ((node = dm_hash_lookup(dtree->uuids, uuid))) {
log_debug("Matched uuid %s in deptree.", uuid);
log_debug_activation("Matched uuid %s %s in deptree.", uuid, _node_name(node));
return node;
}
default_uuid_prefix = dm_uuid_prefix();
default_uuid_prefix_len = strlen(default_uuid_prefix);
if (suffix_list && (suffix_position = strrchr(uuid, '-'))) {
while ((suffix = suffix_list[i++])) {
if (strcmp(suffix_position + 1, suffix))
@ -578,7 +576,8 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
uuid_without_suffix[suffix_position - uuid] = '\0';
if ((node = dm_hash_lookup(dtree->uuids, uuid_without_suffix))) {
log_debug("Matched uuid %s (missing suffix -%s) in deptree.", uuid_without_suffix, suffix);
log_debug_activation("Matched uuid %s %s (missing suffix -%s) in deptree.",
uuid_without_suffix, _node_name(node), suffix);
return node;
}
@ -586,15 +585,17 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
};
}
if (strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len))
return NULL;
default_uuid_prefix = dm_uuid_prefix();
default_uuid_prefix_len = strlen(default_uuid_prefix);
if ((node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
log_debug("Matched uuid %s (missing prefix) in deptree.", uuid + default_uuid_prefix_len);
if ((strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len) == 0) &&
(node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
log_debug_activation("Matched uuid %s %s (missing prefix) in deptree.",
uuid + default_uuid_prefix_len, _node_name(node));
return node;
}
log_debug("Not matched uuid %s in deptree.", uuid);
log_debug_activation("Not matched uuid %s in deptree.", uuid);
return NULL;
}