lib/thin/thin.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libdm/ioctl/libdm-iface.c | 13 +++++++++---- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/thin/thin.c b/lib/thin/thin.c index ab22f7b..f6090c0 100644 --- a/lib/thin/thin.c +++ b/lib/thin/thin.c @@ -491,6 +491,48 @@ static int _thin_text_export(const struct lv_segment *seg, struct formatter *f) } #ifdef DEVMAPPER_SUPPORT +static int _thin_table_matches(struct dev_manager *dm, struct dm_pool *mem, + struct logical_volume *lv) + //struct lv_segment *lv_seg) +{ + int r = 0; + struct dm_task *dmt; + const char *uuid + struct load_segment *seg; + uint64_t seg_start = 0; + + // get node with dlid for thin device, how to I get a handle on the dtree? not in activation so... + //dnode = dm_tree_find_node_by_uuid(dtree, uuid); + // have dev_manager.c caller use _create_partial_dtree() + + if (!(uuid = build_dm_uuid(dm->mem, lv->lvid.s, lv_layer(lv)))) + return_0; + if ((dnode = dm_tree_find_node_by_uuid(dtree, uuid))) + + + if (!(dmt = dm_task_create(DM_DEVICE_RELOAD))) { + log_error("Failed to create device-mapper task struct"); + return 0; + } + + if (!dm_task_set_major(dmt, dnode->info.major) || + !dm_task_set_minor(dmt, dnode->info.minor)) { + log_error("Failed to set device number for %s reload.", dnode->name); + goto out; + } + + if (dnode->props.read_only && !dm_task_set_ro(dmt)) { + log_error("Failed to set read only flag for %s", dnode->name); + goto out; + } + + dm_list_iterate_items(seg, &dnode->props.segs) + // override device_id with desired id, then run through match? + if (!_emit_segment(dmt, dnode->info.major, dnode->info.minor, + seg, &seg_start)) + goto_out; +} + static int _thin_add_target_line(struct dev_manager *dm, struct dm_pool *mem, struct cmd_context *cmd __attribute__((unused)), @@ -699,6 +741,7 @@ static struct segtype_handler _thin_ops = { .text_import = _thin_text_import, .text_export = _thin_text_export, #ifdef DEVMAPPER_SUPPORT + .table_matches = _thin_table_matches, .add_target_line = _thin_add_target_line, .target_percent = _thin_target_percent, .target_present = _thin_target_present, diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index b6f9d09..0906f7e 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1382,7 +1382,7 @@ 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) +static int _existing_table_matches(struct dm_task *dmt) { struct dm_task *task; struct target *t1, *t2; @@ -1450,12 +1450,17 @@ static int _reload_with_suppression_v4(struct dm_task *dmt) no_match: dm_task_destroy(task); + return 0; +} + +static int _reload_with_suppression_v4(struct dm_task *dmt) +{ + if (_existing_table_matches(dmt)) + return 1; /* Now do the original reload */ dmt->suppress_identical_reload = 0; - r = dm_task_run(dmt); - - return r; + return dm_task_run(dmt); } static int _check_children_not_suspended_v4(struct dm_task *dmt, uint64_t device)