From: Pierre Veyre Date: Mon, 10 Mar 2014 11:42:56 +0000 (+0100) Subject: Add SD_storage_get_host() and MSG_storage_get_host() X-Git-Tag: v3_11~224 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e50d4a9de8334346d43f962316c081e0069e56b3?ds=sidebyside Add SD_storage_get_host() and MSG_storage_get_host() --- diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index fc63fc4731..7a4bd0fdb2 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -138,8 +138,7 @@ typedef xbt_dictelm_t msg_storage_t; typedef s_xbt_dictelm_t s_msg_storage_t; typedef struct msg_storage_priv { - // TODO PV: fill it (or not) ! - void * dummy; + const char *host; } s_msg_storage_priv_t, *msg_storage_priv_t; static inline msg_storage_priv_t MSG_storage_priv(msg_storage_t storage){ diff --git a/include/msg/msg.h b/include/msg/msg.h index 1c19a5cee5..e3e5bee730 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -112,6 +112,7 @@ XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage); XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage); XBT_PUBLIC(msg_error_t) MSG_storage_file_move(msg_file_t fd, msg_host_t dest, char* mount, char* fullname); XBT_PUBLIC(msg_error_t) MSG_storage_file_rename(msg_storage_t storage, const char* src, const char* dest); +XBT_PUBLIC(const char *) MSG_storage_get_host(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/simdag/simdag.h b/include/simdag/simdag.h index 7bccbbb820..eee8f60f15 100644 --- a/include/simdag/simdag.h +++ b/include/simdag/simdag.h @@ -109,6 +109,7 @@ XBT_PUBLIC(xbt_dict_t) SD_workstation_get_mounted_storage_list(SD_workstation_t workstation); XBT_PUBLIC(xbt_dynar_t) SD_workstation_get_attached_storage_list(SD_workstation_t workstation); +XBT_PUBLIC(const char*) SD_storage_get_host(SD_storage_t storage); /** @} */ /************************** Task handling ************************************/ diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index c63d21bdd5..623f7614f1 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -506,6 +506,7 @@ XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage); XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage); XBT_PUBLIC(sg_size_t) SIMIX_storage_get_size(smx_storage_t storage); XBT_PUBLIC(void) simcall_storage_file_rename(smx_storage_t storage, const char* src, const char* dest); +XBT_PUBLIC(const char*) SIMIX_storage_get_host(smx_storage_t storage); /************************** AS router **********************************/ XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name); /************************** AS router simcalls ***************************/ diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 1ec1f94fbb..e83c9fa2dc 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -906,6 +906,15 @@ XBT_PUBLIC(surf_file_t) surf_storage_action_get_file(surf_action_t action); */ XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action); + +/** + * @brief Get the host the storage is attached to + * + * @param resource The surf storage + * @return The host name + */ +XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource); + XBT_PUBLIC(surf_model_t) surf_resource_model(const void *host, int level); /** @} */ diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 26b45ed5ec..c2b108e69e 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -263,7 +263,9 @@ void __MSG_file_destroy(msg_file_priv_t file) { msg_storage_t __MSG_storage_create(smx_storage_t storage) { const char *name = SIMIX_storage_get_name(storage); + const char *host = SIMIX_storage_get_host(storage); msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1); + storage_private->host = host; xbt_lib_set(storage_lib,name,MSG_STORAGE_LEVEL,storage_private); return xbt_lib_get_elm_or_null(storage_lib, name); } @@ -423,3 +425,15 @@ msg_error_t MSG_storage_file_move (msg_file_t fd, msg_host_t dest, char* mount, THROW_UNIMPLEMENTED; return MSG_OK; } + +/** \ingroup msg_storage_management + * + * \brief Returns the host name the storage is attached to + * + * This functions checks whether a storage is a valid pointer or not and return its name. + */ +const char *MSG_storage_get_host(msg_storage_t storage) { + xbt_assert((storage != NULL), "Invalid parameters"); + msg_storage_priv_t priv = MSG_storage_priv(storage); + return priv->host; +} diff --git a/src/simdag/private.h b/src/simdag/private.h index 513dd1e2a6..ada782bbad 100644 --- a/src/simdag/private.h +++ b/src/simdag/private.h @@ -73,8 +73,12 @@ static inline SD_workstation_priv_t SD_workstation_priv(SD_workstation_t host){ typedef s_xbt_dictelm_t s_SD_storage_t; typedef struct SD_storage { void *data; /* user data */ + const char *host; } s_SD_storage_priv_t, *SD_storage_priv_t; +static inline SD_storage_priv_t SD_storage_priv(SD_storage_t storage){ + return xbt_lib_get_level(storage, SD_STORAGE_LEVEL); +} /* Task */ typedef struct SD_task { diff --git a/src/simdag/sd_workstation.c b/src/simdag/sd_workstation.c index 4c7aa384b4..7474bba02b 100644 --- a/src/simdag/sd_workstation.c +++ b/src/simdag/sd_workstation.c @@ -45,7 +45,7 @@ SD_storage_t __SD_storage_create(void *surf_storage, void *data) storage = xbt_new(s_SD_storage_priv_t, 1); storage->data = data; /* user data */ - + storage->host = surf_storage_get_host(surf_storage); name = surf_resource_name(surf_storage); xbt_lib_set(storage_lib,name, SD_STORAGE_LEVEL, storage); return xbt_lib_get_elm_or_null(storage_lib, name); @@ -490,6 +490,16 @@ xbt_dynar_t SD_workstation_get_attached_storage_list(SD_workstation_t workstatio return surf_workstation_get_attached_storage_list(workstation); } +/** + * \brief Returns the host name the storage is attached to + * + * This functions checks whether a storage is a valid pointer or not and return its name. + */ +const char *SD_storage_get_host(msg_storage_t storage) { + xbt_assert((storage != NULL), "Invalid parameters"); + SD_storage_priv_t priv = SD_storage_priv(storage); + return priv->host; +} /* Returns whether a task can start now on a workstation*/ /* diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index 7e86d4b965..6833b8ad09 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -395,6 +395,15 @@ sg_size_t SIMIX_storage_get_size(smx_storage_t storage){ return surf_storage_get_size(storage); } +const char* SIMIX_pre_storage_get_host(smx_simcall_t simcall, smx_storage_t storage){ + return SIMIX_storage_get_host(storage); +} + +const char* SIMIX_storage_get_host(smx_storage_t storage){ + xbt_assert((storage != NULL), "Invalid parameters"); + return surf_storage_get_host(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 6bd066eac8..f3f10588f3 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -70,7 +70,7 @@ xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t st xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage); const char* SIMIX_pre_storage_get_name(smx_simcall_t simcall, smx_storage_t storage); - +const char* SIMIX_pre_storage_get_host(smx_simcall_t simcall, 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/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 7f8d40f35c..9d364aaedb 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -476,6 +476,10 @@ sg_size_t surf_storage_get_size(surf_resource_t resource){ return static_cast(surf_storage_resource_priv(resource))->getSize(); } +const char* surf_storage_get_host(surf_resource_t resource){ + return static_cast(surf_storage_resource_priv(resource))->p_attach; +} + void surf_storage_rename(surf_resource_t resource, const char* src, const char* dest){ static_cast(surf_storage_resource_priv(resource))->rename(src, dest); }