--- evms-2.2.2/include/common.h.orig 2004-02-03 15:39:46 +0200 +++ evms-2.2.2/include/common.h 2004-02-03 15:40:34 +0200 @@ -200,6 +200,7 @@ #define SOFLAG_CLUSTER_PRIVATE (1<<14) #define SOFLAG_CLUSTER_SHARED (1<<15) #define SOFLAG_CLUSTER_DEPORTED (1<<16) +#define SOFLAG_DELAYED (1<<17) /* Defines for flags in the storage_container_t structure */ #define SCFLAG_DIRTY (1<<0) @@ -227,6 +228,7 @@ #define VOLFLAG_CLUSTER_SHARED (1<<15) #define VOLFLAG_CLUSTER_DEPORTED (1<<16) #define VOLFLAG_SUSPENDED (1<<17) +#define VOLFLAG_DELAYED (1<<18) /* A boolean variable is one which is either TRUE or FALSE. */ #ifndef boolean_DEFINED --- evms-2.2.2/engine/dm.c.orig 2004-02-03 15:35:45 +0200 +++ evms-2.2.2/engine/dm.c 2004-02-03 15:37:37 +0200 @@ -1243,6 +1243,12 @@ goto out; } + if (object->flags & SOFLAG_DELAYED) { + LOG_DEBUG("activating is delayed for [%s]\n", object->name); + rc = EACCES; + goto out; + } + reactivate = object->flags & SOFLAG_ACTIVE; read_only = object->flags & SOFLAG_READ_ONLY; @@ -1304,6 +1310,12 @@ goto out; } + if (volume->flags & VOLFLAG_DELAYED) { + LOG_DEBUG("activating is delayed for [%s]\n", volume->name); + rc = EACCES; + goto out; + } + base_name = volume->name + EVMS_DEV_NODE_PATH_LEN; reactivate = volume->flags & VOLFLAG_ACTIVE; read_only = volume->flags & VOLFLAG_READ_ONLY; --- evms-2.2.2/engine/engine.c.orig 2004-02-03 15:35:31 +0200 +++ evms-2.2.2/engine/engine.c 2004-02-03 15:37:23 +0200 @@ -1563,6 +1563,224 @@ } +static void undo_children_activation(storage_object_t *child) +{ + int rc = 0; + storage_object_t *obj; + + if (!child || !child->child_objects) { + return; + } + + GoToStartOfList(child->child_objects); + + DLIST_FOR_EACH(obj, child->child_objects, rc) { + if (obj && obj->object_type != DISK) { + obj->flags |= SOFLAG_DELAYED; + undo_children_activation(obj); + } + } + + return; +} + + +static void undo_volumes_activation(dlist_t vols, const char *const *list, int count) +{ + int i = 0; + int rc = 0; + logical_volume_t *vol; + + LOG_PROC_ENTRY(); + + GoToStartOfList(vols); + + if (count == 0) { + DLIST_FOR_EACH(vol, vols, rc) { + vol->flags |= VOLFLAG_DELAYED; + vol->object->flags |= SOFLAG_DELAYED; + undo_children_activation(vol->object); + } + } else { + DLIST_FOR_EACH(vol, vols, rc) { + for (i = 0; i < count; i ++) { + LOG_DEBUG("[%s] ? [%s]\n", (char *) list[i], vol->name); + if (strncmp(list[i], vol->name, EVMS_VOLUME_NAME_SIZE) == 0) { + vol->flags |= VOLFLAG_DELAYED; + vol->object->flags |= SOFLAG_DELAYED; + undo_children_activation(vol->object); + } + } + } + } +} + + +static void undo_objects_activation(dlist_t objs, const char *const *list, int count) +{ + int i = 0; + int rc = 0; + storage_object_t *obj; + + LOG_PROC_ENTRY(); + + GoToStartOfList(objs); + + if (count == 0) { + DLIST_FOR_EACH(obj, objs, rc) { + obj->flags |= SOFLAG_DELAYED; + undo_children_activation(obj); + } + } else { + DLIST_FOR_EACH(obj, objs, rc) { + for (i = 0; i < count; i ++) { + LOG_DEBUG("[%s] ? [%s]\n", (char *) list[i], obj->name); + if (strncmp(list[i], obj->name, EVMS_VOLUME_NAME_SIZE) == 0) { + obj->flags |= SOFLAG_DELAYED; + undo_children_activation(obj); + } + } + } + } +} + + +static void do_children_activation(storage_object_t *child) +{ + int rc = 0; + storage_object_t *obj; + + if (!child || !child->child_objects) { + return; + } + + GoToStartOfList(child->child_objects); + + DLIST_FOR_EACH(obj, child->child_objects, rc) { + if (obj && obj->object_type != DISK) { + obj->flags &= ~SOFLAG_DELAYED; + do_children_activation(obj); + } + } +} + + +static void do_volumes_activation(dlist_t vols, const char *const *list, int count) +{ + int i = 0; + int rc = 0; + logical_volume_t *vol; + + GoToStartOfList(vols); + + if (count == 0) { + DLIST_FOR_EACH(vol, vols, rc) { + vol->flags &= ~VOLFLAG_DELAYED; + vol->object->flags &= ~SOFLAG_DELAYED; + do_children_activation(vol->object); + } + } else { + DLIST_FOR_EACH(vol, vols, rc) { + for (i = 0; i < count; i ++) { + LOG_DEBUG("[%s] ? [%s]\n", list[i], vol->name); + if (strncmp(list[i], vol->name, EVMS_VOLUME_NAME_SIZE) == 0) { + vol->flags &= ~VOLFLAG_DELAYED; + vol->object->flags &= ~SOFLAG_DELAYED; + do_children_activation(vol->object); + } + } + } + } +} + + +static void do_objects_activation(dlist_t objs, const char *const *list, int count) +{ + int i = 0; + int rc = 0; + storage_object_t *obj; + + GoToStartOfList(objs); + + if (count == 0) { + DLIST_FOR_EACH(obj, objs, rc) { + obj->flags &= ~SOFLAG_DELAYED; + do_children_activation(obj); + } + } else { + DLIST_FOR_EACH(obj, objs, rc) { + for (i = 0; i < count; i ++) { + LOG_DEBUG("[%s] ? [%s]\n", list[i], obj->name); + if (strncmp(list[i], obj->name, EVMS_VOLUME_NAME_SIZE) == 0) { + obj->flags &= ~SOFLAG_DELAYED; + do_children_activation(obj); + } + } + } + } +} + + +static void do_engine_lists() +{ + int exclude_count = 0; + int include_count = 0; + const char *const *excludes = NULL; + const char *const *includes = NULL; + + LOG_PROC_ENTRY(); + + evms_get_config_string_array("engine.include", &include_count, &includes); + evms_get_config_string_array("engine.exclude", &exclude_count, &excludes); + + if (include_count > 0 && exclude_count > 0) { + // Process exclude list only.. there is nothing to do + // with include list, everything goes as is. + + if (strcmp(includes[0], "*") == 0 && strcmp(excludes[0], "*") != 0) { + undo_volumes_activation(VolumeList, excludes, exclude_count); + undo_objects_activation(RegionList, excludes, exclude_count); + + // Do both include and exclude lists as follows: firstly + // delay all volumes, then do list with volumes allowed + // to activate. + + } else if (strcmp(excludes[0], "*") == 0 && strcmp(includes[0], "*") != 0) { + undo_volumes_activation(VolumeList, NULL, 0); + undo_objects_activation(RegionList, NULL, 0); + + do_volumes_activation(VolumeList, includes, include_count); + do_objects_activation(RegionList, includes, include_count); + + // Do both include and exclude lists as follows: firstly + // enable activation for all volumes, then process + // exclude list. + + } else if (strcmp(excludes[0], "*") != 0 && strcmp(includes[0], "*") != 0) { + do_volumes_activation(VolumeList, NULL, 0); + do_objects_activation(RegionList, NULL, 0); + + undo_volumes_activation(VolumeList, excludes, exclude_count); + undo_objects_activation(RegionList, excludes, exclude_count); + } else { + // all others rules are wrong.. by now :) + LOG_WARNING("this combination is not currently acceptable\n"); + } + } else if (include_count > 0) { + undo_volumes_activation(VolumeList, NULL, 0); + undo_objects_activation(RegionList, NULL, 0); + + do_volumes_activation(VolumeList, includes, include_count); + do_objects_activation(RegionList, includes, include_count); + } else if (exclude_count > 0) { + undo_volumes_activation(VolumeList, excludes, exclude_count); + undo_objects_activation(RegionList, excludes, exclude_count); + } else { + LOG_DEBUG("neither include nor exclude lists are defined\n"); + } +} + + /* Incremental size to allocate for the name array */ #define ALLOC_SIZE 4096 @@ -2174,8 +2392,8 @@ rc = do_discovery(); if (rc == 0) { + do_engine_lists(); cleanup_dev_evms_tree(); - } else { destroy_all_handles(); }