From fc795d8701b048e6efe1c43fe5ccc033430d558c Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 14 Dec 2007 19:49:27 +0000 Subject: [PATCH] more readahead node fixes/debug messages --- WHATS_NEW_DM | 1 + libdm/libdm-common.c | 22 +++++++++++++++++++++- libdm/libdm-deptree.c | 10 ++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 2c2b54a40..b4792df5c 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,6 +1,7 @@ Version 1.02.24 - =================================== Fix deptree to pass new name to _resume_node after a rename. + Suppress other node operations if node is deleted. Add node operation stack debug messages. Report error when empty device name passed to readahead functions. Fix minimum readahead debug message. diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c index 36dada496..e1f4300cb 100644 --- a/libdm/libdm-common.c +++ b/libdm/libdm-common.c @@ -300,6 +300,8 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor, return 0; } + log_debug("Created %s", path); + #ifdef HAVE_SELINUX if (!dm_set_selinux_context(path, S_IFBLK)) return 0; @@ -341,6 +343,8 @@ static int _rename_dev_node(const char *old_name, const char *new_name) return 0; } + log_debug("Renamed %s to %s", oldpath, newpath); + return 1; } @@ -359,6 +363,8 @@ static int _rm_dev_node(const char *dev_name) return 0; } + log_debug("Removed %s", path); + return 1; } @@ -531,9 +537,23 @@ static int _stack_node_op(node_op_t type, const char *dev_name, uint32_t major, uint32_t read_ahead_flags) { struct node_op_parms *nop; + struct list *noph, *nopht; size_t len = strlen(dev_name) + strlen(old_name) + 2; char *pos; + /* + * Ignore any outstanding operations on the node if deleting it + */ + if (type == NODE_DEL) { + list_iterate_safe(noph, nopht, &_node_ops) { + nop = list_item(noph, struct node_op_parms); + if (!strcmp(dev_name, nop->dev_name)) { + list_del(&nop->list); + dm_free(nop); + } + } + } + if (!(nop = dm_malloc(sizeof(*nop) + len))) { log_error("Insufficient memory to stack mknod operation"); return 0; @@ -592,7 +612,7 @@ int rename_dev_node(const char *old_name, const char *new_name) int rm_dev_node(const char *dev_name) { - log_debug("%s: Stacking NODE_DEL", dev_name); + log_debug("%s: Stacking NODE_DEL (replaces other stacked ops)", dev_name); return _stack_node_op(NODE_DEL, dev_name, 0, 0, 0, 0, 0, "", 0, 0); } diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 96e1c5167..927f331d7 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -1510,7 +1510,6 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, void *handle = NULL; struct dm_tree_node *child; struct dm_info newinfo; - const char *name; /* Preload children first */ while ((child = dm_tree_next_child(&handle, dnode, 0))) { @@ -1526,11 +1525,6 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, if (dm_tree_node_num_children(child, 0)) dm_tree_preload_children(child, uuid_prefix, uuid_prefix_len); - if (!(name = dm_tree_node_get_name(child))) { - stack; - continue; - } - /* FIXME Cope if name exists with no uuid? */ if (!child->info.exists) { if (!_create_node(child)) { @@ -1553,11 +1547,11 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, if (!child->info.inactive_table && !child->info.suspended) continue; - if (!_resume_node(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, &newinfo)) { log_error("Unable to resume %s (%" PRIu32 - ":%" PRIu32 ")", name, child->info.major, + ":%" PRIu32 ")", child->name, child->info.major, child->info.minor); continue; }