From: Pierre Veyre Date: Tue, 24 Sep 2013 08:45:30 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_9_90~104 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/89d98a56977c70b61c8dba09f5c5136e73784339?hp=693515c53d38d9dd1ee48ce080e9259356ba6583 Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/include/msg/msg.h b/include/msg/msg.h index 55685ad8c0..ddc962c04c 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -101,6 +101,7 @@ XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage); XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(void); XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data); XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage); +XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage); /************************** AS Router handling ************************************/ XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name); XBT_PUBLIC(xbt_dict_t) MSG_as_router_get_properties(const char* asr); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index fdd78b7442..1c095a8822 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -497,6 +497,7 @@ XBT_PUBLIC(size_t) simcall_storage_get_used_size (const char* name); XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage); XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage); XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data); +XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage); /************************** AS router **********************************/ XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index afeb5f79ab..5e767d2487 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -237,7 +237,8 @@ typedef struct surf_storage_model_extension_public { surf_action_t(*write) (void *storage, size_t size, surf_file_t fd); surf_action_t(*stat) (void *storage, surf_file_t fd); surf_action_t(*ls) (void *storage, const char *path); - xbt_dict_t(*get_properties) (const void *resource); + xbt_dict_t(*get_properties) (const void *storage); + xbt_dict_t(*get_content) (void *storage); } s_surf_model_extension_storage_t; /** \ingroup SURF_models @@ -359,8 +360,8 @@ static inline void *surf_cpu_resource_priv(const void *host) { static inline void *surf_workstation_resource_priv(const void *host){ return xbt_lib_get_level((void *)host, SURF_WKS_LEVEL); } -static inline void *surf_storage_resource_priv(const void *host){ - return xbt_lib_get_level((void *)host, SURF_STORAGE_LEVEL); +static inline void *surf_storage_resource_priv(const void *storage){ + return xbt_lib_get_level((void *)storage, SURF_STORAGE_LEVEL); } static inline void *surf_cpu_resource_by_name(const char *name) { diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 8d9fa637fe..ed88e74596 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -290,7 +290,7 @@ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data) * * \brief Returns the user data of a #msg_storage_t. * - * This functions checks whether \a storage is a valid pointer or not and return + * This functions checks whether \a storage is a valid pointer or not and returns the user data associated to \a storage if it is possible. */ void *MSG_storage_get_data(msg_storage_t storage) @@ -298,3 +298,12 @@ void *MSG_storage_get_data(msg_storage_t storage) return SIMIX_storage_get_data(storage); } +/** \ingroup msg_storage_management + * + * \brief Returns the content (file list) of a #msg_storage_t. + * \param storage a storage + */ +xbt_dict_t MSG_storage_get_content(msg_storage_t storage){ + + return SIMIX_storage_get_content(storage); +} diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index daa80e5420..1c16b3b73f 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -338,12 +338,22 @@ void SIMIX_storage_set_data(smx_storage_t storage, void *data){ void* SIMIX_pre_storage_get_data(smx_simcall_t simcall,smx_storage_t storage){ return SIMIX_storage_get_data(storage); } + void* SIMIX_storage_get_data(smx_storage_t storage){ xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)"); return SIMIX_storage_priv(storage)->data; } +xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage){ + return SIMIX_storage_get_content(storage); +} + +xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage){ + xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)"); + return surf_storage_model->extension.storage.get_content(storage); +} + void SIMIX_post_io(smx_action_t action) { xbt_fifo_item_t i; diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index f2496b9ebc..7914bc8d1f 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -55,6 +55,9 @@ xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t, smx_storage_t); void SIMIX_pre_storage_set_data(smx_simcall_t, smx_storage_t, void*); void* SIMIX_pre_storage_get_data(smx_simcall_t, smx_storage_t); +xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage); +xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage); + void SIMIX_post_io(smx_action_t action); void SIMIX_io_destroy(smx_action_t action); void SIMIX_io_finish(smx_action_t action); diff --git a/src/surf/storage.c b/src/surf/storage.c index e5d8d02a79..21a9c630f4 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -197,6 +197,22 @@ static xbt_dict_t storage_get_properties(const void *storage) return surf_resource_properties(surf_storage_resource_priv(storage)); } +static xbt_dict_t storage_get_content(void *storage) +{ + /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */ + /* surf_action_t action = storage_action_execute(storage,0, LS); */ + xbt_dict_t content_dict = xbt_dict_new(); + + xbt_dict_cursor_t cursor = NULL; + char *file; + size_t size; + + xbt_dict_foreach(((storage_t)storage)->content,cursor,file,size) + xbt_dict_set(content_dict,file,&size,NULL); + + return content_dict; +} + static void* storage_create_resource(const char* id, const char* model, const char* type_id, const char* content_name, const char* content_type, xbt_dict_t properties){ storage_t storage = NULL; @@ -503,8 +519,8 @@ static void surf_storage_model_init_internal(void) surf_storage_model->extension.storage.read = storage_action_read; surf_storage_model->extension.storage.write = storage_action_write; surf_storage_model->extension.storage.ls = storage_action_ls; - surf_storage_model->extension.storage.get_properties = storage_get_properties; + surf_storage_model->extension.storage.get_content = storage_get_content; if (!storage_maxmin_system) { storage_maxmin_system = lmm_system_new(storage_selective_update);