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

Improve target type compatibility checking in _percent_run().

Add 'target_status_compatible' method to 'struct segtype_handler'.
This commit is contained in:
Mike Snitzer 2010-01-15 16:35:26 +00:00
parent ed2bef01e5
commit e47a591d76
4 changed files with 17 additions and 8 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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,