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

cleanup: use _node_name

Use existing internal method for create 'name (major:minor)' string
for debug messages and reduce some messages.
This commit is contained in:
Zdenek Kabelac 2017-12-04 13:33:05 +01:00
parent 925fec6ecb
commit 2a01e3d4ca

View File

@ -597,8 +597,9 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
static const char *_node_name(struct dm_tree_node *dnode) static const char *_node_name(struct dm_tree_node *dnode)
{ {
if (dm_snprintf(dnode->dtree->buf, sizeof(dnode->dtree->buf), if (dm_snprintf(dnode->dtree->buf, sizeof(dnode->dtree->buf),
"%s (%" PRIu32 ":%" PRIu32 ")", "%s (" FMTu32 ":" FMTu32 ")",
dnode->name, dnode->info.major, dnode->info.minor) < 0) { dnode->name ? dnode->name : "",
dnode->info.major, dnode->info.minor) < 0) {
stack; stack;
return dnode->name; return dnode->name;
} }
@ -609,12 +610,9 @@ static const char *_node_name(struct dm_tree_node *dnode)
void dm_tree_node_set_udev_flags(struct dm_tree_node *dnode, uint16_t udev_flags) void dm_tree_node_set_udev_flags(struct dm_tree_node *dnode, uint16_t udev_flags)
{ {
struct dm_info *dinfo = &dnode->info;
if (udev_flags != dnode->udev_flags) if (udev_flags != dnode->udev_flags)
log_debug_activation("Resetting %s (%" PRIu32 ":%" PRIu32 log_debug_activation("Resetting %s udev_flags from 0x%x to 0x%x.",
") udev_flags from 0x%x to 0x%x", _node_name(dnode),
dnode->name, dinfo->major, dinfo->minor,
dnode->udev_flags, udev_flags); dnode->udev_flags, udev_flags);
dnode->udev_flags = udev_flags; dnode->udev_flags = udev_flags;
} }
@ -1398,8 +1396,8 @@ static int _thin_pool_get_status(struct dm_tree_node *dnode,
dm_get_next_target(dmt, NULL, &start, &length, &type, &params); dm_get_next_target(dmt, NULL, &start, &length, &type, &params);
if (type && (strcmp(type, "thin-pool") != 0)) { if (type && (strcmp(type, "thin-pool") != 0)) {
log_error("Expected thin-pool target for %d:%d and got %s.", log_error("Expected thin-pool target for %s and got %s.",
dnode->info.major, dnode->info.minor, type); _node_name(dnode), type);
goto out; goto out;
} }
@ -1895,9 +1893,7 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
if (!_resume_node(child->name, child->info.major, child->info.minor, if (!_resume_node(child->name, child->info.major, child->info.minor,
child->props.read_ahead, child->props.read_ahead_flags, child->props.read_ahead, child->props.read_ahead_flags,
&newinfo, &child->dtree->cookie, child->udev_flags, child->info.suspended)) { &newinfo, &child->dtree->cookie, child->udev_flags, child->info.suspended)) {
log_error("Unable to resume %s (%" PRIu32 log_error("Unable to resume %s.", _node_name(child));
":%" PRIu32 ")", child->name, child->info.major,
child->info.minor);
r = 0; r = 0;
continue; continue;
} }
@ -1997,9 +1993,8 @@ static int _remove_node(struct dm_tree_node *dnode)
if (!_deactivate_node(dnode->name, dnode->info.major, dnode->info.minor, if (!_deactivate_node(dnode->name, dnode->info.major, dnode->info.minor,
&dnode->dtree->cookie, dnode->udev_flags, 0)) { &dnode->dtree->cookie, dnode->udev_flags, 0)) {
log_error("Failed to clean-up device with no table: %s %u:%u", log_error("Failed to clean-up device with no table: %s.",
dnode->name ? dnode->name : "", _node_name(dnode));
dnode->info.major, dnode->info.minor);
return 0; return 0;
} }
return 1; return 1;
@ -2691,22 +2686,21 @@ static int _load_node(struct dm_tree_node *dnode)
struct load_segment *seg; struct load_segment *seg;
uint64_t seg_start = 0, existing_table_size; uint64_t seg_start = 0, existing_table_size;
log_verbose("Loading %s table (%" PRIu32 ":%" PRIu32 ")", dnode->name, log_verbose("Loading table for %s.", _node_name(dnode));
dnode->info.major, dnode->info.minor);
if (!(dmt = dm_task_create(DM_DEVICE_RELOAD))) { if (!(dmt = dm_task_create(DM_DEVICE_RELOAD))) {
log_error("Reload dm_task creation failed for %s", dnode->name); log_error("Reload dm_task creation failed for %s.", _node_name(dnode));
return 0; return 0;
} }
if (!dm_task_set_major(dmt, dnode->info.major) || if (!dm_task_set_major(dmt, dnode->info.major) ||
!dm_task_set_minor(dmt, dnode->info.minor)) { !dm_task_set_minor(dmt, dnode->info.minor)) {
log_error("Failed to set device number for %s reload.", dnode->name); log_error("Failed to set device number for %s reload.", _node_name(dnode));
goto out; goto out;
} }
if (dnode->props.read_only && !dm_task_set_ro(dmt)) { if (dnode->props.read_only && !dm_task_set_ro(dmt)) {
log_error("Failed to set read only flag for %s", dnode->name); log_error("Failed to set read only flag for %s.", _node_name(dnode));
goto out; goto out;
} }
@ -2724,10 +2718,8 @@ static int _load_node(struct dm_tree_node *dnode)
if ((r = dm_task_run(dmt))) { if ((r = dm_task_run(dmt))) {
r = dm_task_get_info(dmt, &dnode->info); r = dm_task_get_info(dmt, &dnode->info);
if (r && !dnode->info.inactive_table) if (r && !dnode->info.inactive_table)
log_verbose("Suppressed %s (%" PRIu32 ":%" PRIu32 log_verbose("Suppressed %s identical table reload.",
") identical table reload.", _node_name(dnode));
dnode->name,
dnode->info.major, dnode->info.minor);
existing_table_size = dm_task_get_existing_table_size(dmt); existing_table_size = dm_task_get_existing_table_size(dmt);
if ((dnode->props.size_changed = if ((dnode->props.size_changed =
@ -2742,9 +2734,8 @@ static int _load_node(struct dm_tree_node *dnode)
dnode->props.size_changed = 0; dnode->props.size_changed = 0;
log_debug_activation("Table size changed from %" PRIu64 " to %" log_debug_activation("Table size changed from %" PRIu64 " to %"
PRIu64 " for %s (%" PRIu32 ":%" PRIu32 ").%s", PRIu64 " for %s.%s", existing_table_size,
existing_table_size, seg_start, dnode->name, seg_start, _node_name(dnode),
dnode->info.major, dnode->info.minor,
dnode->props.size_changed ? "" : " (Ignoring.)"); dnode->props.size_changed ? "" : " (Ignoring.)");
} }
} }
@ -2773,9 +2764,7 @@ static int _dm_tree_revert_activated(struct dm_tree_node *parent)
} }
if (!_deactivate_node(child->name, child->info.major, child->info.minor, if (!_deactivate_node(child->name, child->info.major, child->info.minor,
&child->dtree->cookie, child->udev_flags, 0)) { &child->dtree->cookie, child->udev_flags, 0)) {
log_error("Unable to deactivate %s (%" PRIu32 log_error("Unable to deactivate %s.", _node_name(child));
":%" PRIu32 ")", child->name, child->info.major,
child->info.minor);
return 0; return 0;
} }
if (!_dm_tree_revert_activated(child)) if (!_dm_tree_revert_activated(child))
@ -2869,16 +2858,12 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
child->props.read_ahead, child->props.read_ahead_flags, child->props.read_ahead, child->props.read_ahead_flags,
&newinfo, &child->dtree->cookie, child->udev_flags, &newinfo, &child->dtree->cookie, child->udev_flags,
child->info.suspended)) { child->info.suspended)) {
log_error("Unable to resume %s (%" PRIu32 log_error("Unable to resume %s.", _node_name(child));
":%" PRIu32 ")", child->name, child->info.major,
child->info.minor);
/* If the device was not previously active, we might as well remove this node. */ /* If the device was not previously active, we might as well remove this node. */
if (!child->info.live_table && if (!child->info.live_table &&
!_deactivate_node(child->name, child->info.major, child->info.minor, !_deactivate_node(child->name, child->info.major, child->info.minor,
&child->dtree->cookie, child->udev_flags, 0)) &child->dtree->cookie, child->udev_flags, 0))
log_error("Unable to deactivate %s (%" PRIu32 log_error("Unable to deactivate %s.", _node_name(child));
":%" PRIu32 ")", child->name, child->info.major,
child->info.minor);
r = 0; r = 0;
/* Each child is handled independently */ /* Each child is handled independently */
continue; continue;