]> sourceware.org Git - lvm2.git/commitdiff
Improve target type compatibility checking in _percent_run().
authorMike Snitzer <snitzer@redhat.com>
Fri, 15 Jan 2010 16:35:26 +0000 (16:35 +0000)
committerMike Snitzer <snitzer@redhat.com>
Fri, 15 Jan 2010 16:35:26 +0000 (16:35 +0000)
Add 'target_status_compatible' method to 'struct segtype_handler'.

WHATS_NEW
lib/activate/dev_manager.c
lib/metadata/segtype.h
lib/snapshot/snapshot.c

index d7571c4325542b95add56ee930055acb8e714813..dc4cfa54058d092400378c16d54d67403e6d9dcd 100644 (file)
--- 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
index 6f2a4529316c64be7bd09eb57b49655ddab589b5..6c37e7f9e0cf29ff725fde1805b46ff299cc4dd2 100644 (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,
index c9a01aac32bc8b35d209f5272e06921ad5ebd826..7b31c1ddbec7c927255b462c9ffa06417fc3ec90 100644 (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,
index 3f59e81092ab43d9a4d960d37d897e168022c664..d1dd1223fb5a4c03a8384097504093692d0893b6 100644 (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,
This page took 0.051225 seconds and 5 git commands to generate.