From bb875bb9e4a5ae9ac1e1924efa9242ed625844a6 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 18 Sep 2008 18:34:53 +0000 Subject: [PATCH] Only resume devices in dm_tree_preload_children if size changes. --- WHATS_NEW_DM | 7 ++++--- libdm/ioctl/libdm-iface.c | 11 +++++++++++ libdm/ioctl/libdm-targets.h | 2 ++ libdm/libdm-deptree.c | 17 +++++++++++++---- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 7c9daeeec..6a443c13e 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,7 +1,8 @@ -Version 1.02.28 - -================================ +Version 1.02.28 - 18th September 2008 +===================================== + Only resume devices in dm_tree_preload_children if size changes. Extend deptree buffers so the largest possible device numbers fit. - Added generation of the versioned libdevmapper-event.so for LVM's test + Generate versioned libdevmapper-event.so. Underline longer report help text headings. Version 1.02.27 - 25th June 2008 diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index fb54665cd..7366f08b1 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1501,6 +1501,11 @@ static int _create_and_load_v4(struct dm_task *dmt) return r; } +uint64_t dm_task_get_existing_table_size(struct dm_task *dmt) +{ + return dmt->existing_table_size; +} + static int _reload_with_suppression_v4(struct dm_task *dmt) { struct dm_task *task; @@ -1534,6 +1539,12 @@ static int _reload_with_suppression_v4(struct dm_task *dmt) return r; } + /* Store existing table size */ + t2 = task->head; + while (t2 && t2->next) + t2 = t2->next; + dmt->existing_table_size = t2 ? t2->start + t2->length : 0; + if ((task->dmi.v4->flags & DM_READONLY_FLAG) ? 1 : 0 != dmt->read_only) goto no_match; diff --git a/libdm/ioctl/libdm-targets.h b/libdm/ioctl/libdm-targets.h index 3caa8dd6a..1bb9ce176 100644 --- a/libdm/ioctl/libdm-targets.h +++ b/libdm/ioctl/libdm-targets.h @@ -58,6 +58,7 @@ struct dm_task { int no_open_count; int skip_lockfs; int suppress_identical_reload; + uint64_t existing_table_size; char *uuid; }; @@ -69,5 +70,6 @@ struct cmd_data { }; int dm_check_version(void); +uint64_t dm_task_get_existing_table_size(struct dm_task *dmt); #endif diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 8c4797d9e..d687d8fa5 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -99,6 +99,7 @@ struct load_properties { uint32_t read_ahead_flags; unsigned segment_count; + unsigned size_changed; struct list segs; const char *new_name; @@ -603,6 +604,7 @@ struct dm_tree_node *dm_tree_add_new_dev(struct dm_tree *dtree, dnode->props.major = major; dnode->props.minor = minor; dnode->props.new_name = NULL; + dnode->props.size_changed = 0; } else if (strcmp(name, dnode->name)) { /* Do we need to rename node? */ if (!(dnode->props.new_name = dm_pool_strdup(dtree->mem, name))) { @@ -1494,6 +1496,13 @@ static int _load_node(struct dm_tree_node *dnode) if (r && !dnode->info.inactive_table) log_verbose("Suppressed %s identical table reload.", dnode->name); + + if ((dnode->props.size_changed = + (dm_task_get_existing_table_size(dmt) == seg_start) ? 0 : 1)) + log_debug("Table size changed from %" PRIu64 " to %" + PRIu64 " for %s", + dm_task_get_existing_table_size(dmt), + seg_start, dnode->name); } dnode->props.segment_count = 0; @@ -1505,8 +1514,8 @@ out: } int dm_tree_preload_children(struct dm_tree_node *dnode, - const char *uuid_prefix, - size_t uuid_prefix_len) + const char *uuid_prefix, + size_t uuid_prefix_len) { void *handle = NULL; struct dm_tree_node *child; @@ -1541,8 +1550,8 @@ int dm_tree_preload_children(struct dm_tree_node *dnode, } } - /* Resume device immediately if it has parents */ - if (!dm_tree_node_num_children(child, 1)) + /* Resume device immediately if it has parents and its size changed */ + if (!dm_tree_node_num_children(child, 1) || !dnode->props.size_changed) continue; if (!child->info.inactive_table && !child->info.suspended)