From: Mike Snitzer Date: Fri, 15 Jan 2010 16:35:26 +0000 (+0000) Subject: Improve target type compatibility checking in _percent_run(). X-Git-Tag: v2_02_91~2362 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=e47a591d7634604f74467905f488c707d04d0752;p=lvm2.git Improve target type compatibility checking in _percent_run(). Add 'target_status_compatible' method to 'struct segtype_handler'. --- diff --git a/WHATS_NEW b/WHATS_NEW index d7571c432..dc4cfa540 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,7 @@ Version 2.02.59 - =================================== + Improve target type compatibility checking in _percent_run(). + Add 'target_status_compatible' method to 'struct segtype_handler'. Fix difference between CTR table built and expected for cluster log. Version 2.02.58 - 14th January 2010 diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 6f2a45293..6c37e7f9e 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -443,19 +443,19 @@ static int _percent_run(struct dev_manager *dm, const char *name, seg = dm_list_item(segh, struct lv_segment); } - /* - * If target status doesn't have 'params' or 'type' is not in the same - * target base class as 'target_type' (e.g. snapshot*, mirror*) skip it - * - allows the situation when 'type' is "snapshot-merge" and - * 'target_type' is "snapshot" - */ - /* FIXME Do this properly - relying on target prefixes is incorrect. (E.g. snapshot-origin)*/ - if (!type || !params || strncmp(type, target_type, strlen(target_type))) + if (!type || !params) continue; if (!(segtype = get_segtype_from_string(dm->cmd, target_type))) continue; + if (strcmp(type, target_type)) { + /* If kernel's type isn't an exact match is it compatible? */ + if (!segtype->ops->target_status_compatible || + !segtype->ops->target_status_compatible(type)) + continue; + } + if (segtype->ops->target_percent && !segtype->ops->target_percent(&dm->target_state, &percent_range, dm->mem, diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h index c9a01aac3..7b31c1ddb 100644 --- a/lib/metadata/segtype.h +++ b/lib/metadata/segtype.h @@ -77,6 +77,7 @@ struct segtype_handler { struct lv_segment *seg, struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count); + int (*target_status_compatible) (const char *type); int (*target_percent) (void **target_state, percent_range_t *percent_range, struct dm_pool * mem, diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c index 3f59e8109..d1dd1223f 100644 --- a/lib/snapshot/snapshot.c +++ b/lib/snapshot/snapshot.c @@ -92,6 +92,11 @@ static int _snap_text_export(const struct lv_segment *seg, struct formatter *f) return 1; } +static int _snap_target_status_compatible(const char *type) +{ + return (strcmp(type, "snapshot-merge") == 0); +} + #ifdef DEVMAPPER_SUPPORT static int _snap_target_percent(void **target_state __attribute((unused)), percent_range_t *percent_range, @@ -303,6 +308,7 @@ static struct segtype_handler _snapshot_ops = { .name = _snap_name, .text_import = _snap_text_import, .text_export = _snap_text_export, + .target_status_compatible = _snap_target_status_compatible, #ifdef DEVMAPPER_SUPPORT .target_percent = _snap_target_percent, .target_present = _snap_target_present,