From a5fa633fb631a244d02464b9f43de6cd4983fb99 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Tue, 1 Dec 2015 11:45:57 +0100 Subject: [PATCH] [surf] Remove sg_platf_storage_cb --- src/include/simgrid/platf_interface.h | 1 - src/surf/sg_platf.cpp | 61 ++++++++++++++++++++++----- src/surf/storage_n11.cpp | 58 ------------------------- 3 files changed, 50 insertions(+), 70 deletions(-) diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index 3d534c6eee..61bb5ffe61 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -67,7 +67,6 @@ XBT_PUBLIC(void) sg_platf_bypassASroute_add_cb(sg_platf_route_cb_t); XBT_PUBLIC(void) sg_platf_trace_add_cb(sg_platf_trace_cb_t); XBT_PUBLIC(void) sg_platf_trace_connect_add_cb(sg_platf_trace_connect_cb_t); -XBT_PUBLIC(void) sg_platf_storage_add_cb(sg_platf_storage_cb_t fct); XBT_PUBLIC(void) sg_platf_mstorage_add_cb(sg_platf_mstorage_cb_t fct); XBT_PUBLIC(void) sg_platf_storage_type_add_cb(sg_platf_storage_type_cb_t fct); XBT_PUBLIC(void) sg_platf_mount_add_cb(sg_platf_mount_cb_t fct); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 7a7868b653..6677aaa090 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -38,7 +38,6 @@ xbt_dynar_t sg_platf_bypassASroute_cb_list = NULL; // of sg_platf_bypassASroute_ xbt_dynar_t sg_platf_trace_cb_list = NULL; xbt_dynar_t sg_platf_trace_connect_cb_list = NULL; -xbt_dynar_t sg_platf_storage_cb_list = NULL; // of sg_platf_storage_cb_t xbt_dynar_t sg_platf_storage_type_cb_list = NULL; // of sg_platf_storage_cb_t xbt_dynar_t sg_platf_mstorage_cb_list = NULL; // of sg_platf_storage_cb_t xbt_dynar_t sg_platf_mount_cb_list = NULL; // of sg_platf_storage_cb_t @@ -82,7 +81,6 @@ void sg_platf_init(void) { sg_platf_trace_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_cb_t), NULL); sg_platf_trace_connect_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_connect_cb_t), NULL); - sg_platf_storage_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL); sg_platf_storage_type_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL); sg_platf_mstorage_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL); sg_platf_mount_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL); @@ -115,7 +113,6 @@ void sg_platf_exit(void) { xbt_dynar_free(&sg_platf_bypassRoute_cb_list); xbt_dynar_free(&sg_platf_bypassASroute_cb_list); - xbt_dynar_free(&sg_platf_storage_cb_list); xbt_dynar_free(&sg_platf_storage_type_cb_list); xbt_dynar_free(&sg_platf_mstorage_cb_list); xbt_dynar_free(&sg_platf_mount_cb_list); @@ -203,12 +200,57 @@ void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet){ fun(cabinet); } } -void sg_platf_new_storage(sg_platf_storage_cbarg_t storage){ - unsigned int iterator; - sg_platf_storage_cb_t fun; - xbt_dynar_foreach(sg_platf_storage_cb_list, iterator, fun) { - fun(storage); +void sg_platf_new_storage(sg_platf_storage_cbarg_t storage) +{ + xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL), + "Reading a storage, processing unit \"%s\" already exists", storage->id); + + // Verification of an existing type_id +#ifndef NDEBUG + void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL); +#endif + xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id); + + XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'", + storage->id, + storage->type_id, + storage->content); + + xbt_lib_set(storage_lib, + storage->id, + ROUTING_STORAGE_LEVEL, + (void *) xbt_strdup(storage->type_id)); + + void* stype = xbt_lib_get_or_null(storage_type_lib, + storage->type_id, + ROUTING_STORAGE_TYPE_LEVEL); + if(!stype) xbt_die("No storage type '%s'",storage->type_id); + + // if storage content is not specified use the content of storage_type if exist + if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){ + storage->content = ((storage_type_t) stype)->content; + storage->content_type = ((storage_type_t) stype)->content_type; + XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s) from storage type '%s' ", + storage->id,((storage_type_t) stype)->content_type, + ((storage_type_t) stype)->type_id); } + + XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' " + "\n\t\tmodel '%s' \n\t\tcontent '%s'\n\t\tcontent_type '%s' " + "\n\t\tproperties '%p''\n", + storage->id, + ((storage_type_t) stype)->model, + ((storage_type_t) stype)->type_id, + storage->content, + storage->content_type, + storage->properties); + + surf_storage_model->createStorage(storage->id, + ((storage_type_t) stype)->type_id, + storage->content, + storage->content_type, + storage->properties, + storage->attach); } void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type){ unsigned int iterator; @@ -473,9 +515,6 @@ void sg_platf_AS_begin_add_cb(sg_platf_AS_cb_t fct) { void sg_platf_AS_end_add_cb(sg_platf_AS_cb_t fct) { xbt_dynar_push(sg_platf_AS_end_cb_list, &fct); } -void sg_platf_storage_add_cb(sg_platf_storage_cb_t fct) { - xbt_dynar_push(sg_platf_storage_cb_list, &fct); -} void sg_platf_storage_type_add_cb(sg_platf_storage_type_cb_t fct) { xbt_dynar_push(sg_platf_storage_type_cb_list, &fct); } diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 01769e102b..e7f7a535ab 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -42,40 +42,6 @@ static XBT_INLINE void routing_storage_host_free(void *r) xbt_dynar_free(&dyn); } -static void parse_storage_init(sg_platf_storage_cbarg_t storage) -{ - void* stype = xbt_lib_get_or_null(storage_type_lib, - storage->type_id, - ROUTING_STORAGE_TYPE_LEVEL); - if(!stype) xbt_die("No storage type '%s'",storage->type_id); - - // if storage content is not specified use the content of storage_type if exist - if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){ - storage->content = ((storage_type_t) stype)->content; - storage->content_type = ((storage_type_t) stype)->content_type; - XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s) from storage type '%s' ", - storage->id,((storage_type_t) stype)->content_type, - ((storage_type_t) stype)->type_id); - } - - XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' " - "\n\t\tmodel '%s' \n\t\tcontent '%s'\n\t\tcontent_type '%s' " - "\n\t\tproperties '%p''\n", - storage->id, - ((storage_type_t) stype)->model, - ((storage_type_t) stype)->type_id, - storage->content, - storage->content_type, - storage->properties); - - surf_storage_model->createStorage(storage->id, - ((storage_type_t) stype)->type_id, - storage->content, - storage->content_type, - storage->properties, - storage->attach); -} - static void parse_mstorage_init(sg_platf_mstorage_cbarg_t /*mstorage*/) { XBT_DEBUG("parse_mstorage_init"); @@ -91,28 +57,6 @@ static void parse_mount_init(sg_platf_mount_cbarg_t /*mount*/) XBT_DEBUG("parse_mount_init"); } -static void storage_parse_storage(sg_platf_storage_cbarg_t storage) -{ - xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL), - "Reading a storage, processing unit \"%s\" already exists", storage->id); - - // Verification of an existing type_id -#ifndef NDEBUG - void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL); -#endif - xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id); - - XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'", - storage->id, - storage->type_id, - storage->content); - - xbt_lib_set(storage_lib, - storage->id, - ROUTING_STORAGE_LEVEL, - (void *) xbt_strdup(storage->type_id)); -} - static void storage_parse_storage_type(sg_platf_storage_type_cbarg_t storage_type) { xbt_assert(!xbt_lib_get_or_null(storage_type_lib, storage_type->id,ROUTING_STORAGE_TYPE_LEVEL), @@ -187,7 +131,6 @@ static void storage_parse_mount(sg_platf_mount_cbarg_t mount) static void storage_define_callbacks() { - sg_platf_storage_add_cb(parse_storage_init); sg_platf_storage_type_add_cb(parse_storage_type_init); sg_platf_mstorage_add_cb(parse_mstorage_init); sg_platf_mount_add_cb(parse_mount_init); @@ -200,7 +143,6 @@ void storage_register_callbacks() { ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free); SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, surf_storage_resource_free); - sg_platf_storage_add_cb(storage_parse_storage); sg_platf_mstorage_add_cb(storage_parse_mstorage); sg_platf_storage_type_add_cb(storage_parse_storage_type); sg_platf_mount_add_cb(storage_parse_mount); -- 2.20.1