From: Pierre Veyre Date: Fri, 12 Jul 2013 14:24:18 +0000 (+0200) Subject: Fix MSG_storage_get_free_size() and add MSG_storage_get_used_size() X-Git-Tag: v3_9_90~149 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f72e3ef2896f8dbb89dd641508f99817a1438756?ds=sidebyside Fix MSG_storage_get_free_size() and add MSG_storage_get_used_size() --- diff --git a/include/msg/msg.h b/include/msg/msg.h index 154af259b6..578e222c32 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -84,12 +84,14 @@ XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path); XBT_PUBLIC(int) MSG_file_close(msg_file_t fd); XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd); XBT_PUBLIC(void) MSG_file_dump(msg_file_t fd); - XBT_PUBLIC(int) MSG_file_unlink(msg_file_t fd); XBT_PUBLIC(xbt_dict_t) MSG_file_ls(const char *mount, const char *path); -XBT_PUBLIC(size_t) MSG_storage_get_free_size(msg_storage_t sd); - XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd); + +/************************** Storage handling ***********************************/ +XBT_PUBLIC(size_t) MSG_storage_get_free_size(const char* name); +XBT_PUBLIC(size_t) MSG_storage_get_used_size(const char* name); + /************************** 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 1c72dbeb1e..4a521c55e2 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -481,7 +481,11 @@ XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd); XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path); XBT_PUBLIC(size_t) simcall_file_get_size(smx_file_t fd); XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd); -XBT_PUBLIC(size_t) simcall_storage_get_free_size (smx_storage_t storage); + +/***************************** Storage **********************************/ +XBT_PUBLIC(size_t) simcall_storage_get_free_size (const char* name); +XBT_PUBLIC(size_t) simcall_storage_get_used_size (const char* name); + /************************** 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 b1aab86202..ec366eabd3 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -286,10 +286,11 @@ typedef struct surf_workstation_model_extension_public { xbt_dynar_t (*get_info) (void *workstation, surf_file_t fd); int (*link_shared) (const void *link); - xbt_dict_t(*get_properties) (const void *resource); + xbt_dict_t(*get_properties) (const void *resource); void (*add_traces) (void); - size_t (*get_free_size) (void *workstation, surf_storage_t storage); + size_t (*get_free_size) (void *workstation,const char* name); + size_t (*get_used_size) (void *workstation,const char* name); xbt_dynar_t (*get_storage_list) (void *workstation); } s_surf_model_extension_workstation_t; diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index c443d83f95..898582daa3 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -151,9 +151,18 @@ xbt_dict_t MSG_file_ls(const char *mount, const char *path) /** \ingroup msg_storage_management * \brief Return the free space size of a storage element - * \param sd is the storage descriptor (#msg_storage_t) + * \param the storage name (#char*) * \return the free space size of the storage element (as a size_t) */ -size_t MSG_storage_get_free_size(msg_storage_t sd){ - return simcall_storage_get_free_size(sd->simdata->smx_storage); +size_t MSG_storage_get_free_size(const char* name){ + return simcall_storage_get_free_size(name); +} + +/** \ingroup msg_storage_management + * \brief Return the used space size of a storage element + * \param the storage name (#char*) + * \return the used space size of the storage element (as a size_t) + */ +size_t MSG_storage_get_used_size(const char* name){ + return simcall_storage_get_used_size(name); } diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index 78be8b0d6b..dd52bf1d47 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -251,18 +251,27 @@ xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd) fd->surf_file); } -size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage) +size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name) { - return SIMIX_storage_get_free_size(simcall->issuer, storage); + return SIMIX_storage_get_free_size(simcall->issuer, name); } -size_t SIMIX_storage_get_free_size(smx_process_t process, smx_storage_t storage) +size_t SIMIX_storage_get_free_size(smx_process_t process, const char* name) { smx_host_t host = process->smx_host; - return surf_workstation_model->extension.workstation.get_free_size(host, - storage->surf_storage); + return surf_workstation_model->extension.workstation.get_free_size(host,name); } +size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, const char* name) +{ + return SIMIX_storage_get_used_size(simcall->issuer, name); +} + +size_t SIMIX_storage_get_used_size(smx_process_t process, const char* name) +{ + smx_host_t host = process->smx_host; + return surf_workstation_model->extension.workstation.get_used_size(host,name); +} void SIMIX_post_io(smx_action_t action) { diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index d52cc64e49..8b3be6af63 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -34,8 +34,11 @@ smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount, size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd); xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd); -size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage); -size_t SIMIX_storage_get_free_size(smx_process_t process, smx_storage_t storage); +size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name); +size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name); + +size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,const char* name); +size_t SIMIX_storage_get_used_size(smx_process_t process,const char* name); void SIMIX_post_io(smx_action_t action); void SIMIX_io_destroy(smx_action_t action); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index fe5c8fa882..9e6bc2f40e 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -355,7 +355,8 @@ ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITH_ANSWER, TINT(result), TSPEC(fd, sm ACTION(SIMCALL_FILE_LS, file_ls, WITHOUT_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(mount), TSTRING(path)) sep \ ACTION(SIMCALL_FILE_GET_SIZE, file_get_size, WITH_ANSWER, TSIZE(result), TSPEC(fd, smx_file_t)) sep \ ACTION(SIMCALL_FILE_GET_INFO, file_get_info, WITH_ANSWER, TSPEC(result, xbt_dynar_t), TSPEC(fd, smx_file_t)) sep \ -ACTION(SIMCALL_STORAGE_GET_FREE_SIZE, storage_get_free_size, WITH_ANSWER, TSIZE(result), TSPEC(storage, smx_storage_t)) sep \ +ACTION(SIMCALL_STORAGE_GET_FREE_SIZE, storage_get_free_size, WITH_ANSWER, TSIZE(result), TSTRING(name)) sep \ +ACTION(SIMCALL_STORAGE_GET_USED_SIZE, storage_get_used_size, WITH_ANSWER, TSIZE(result), TSTRING(name)) sep \ ACTION(SIMCALL_ASR_GET_PROPERTIES, asr_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(name)) sep /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 15b9899de3..3e0c130ee0 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1246,12 +1246,22 @@ xbt_dynar_t simcall_file_get_info(smx_file_t fd) /** * \ingroup simix_storage_management - * \brief Return the free size on a given storage element. - * \param storage A SIMIX storage - * \return a dynar containing all mounted storages on the host + * \brief Return the free space size on a given storage element. + * \param storage name + * \return Return the free space size on a given storage element (as size_t) */ -size_t simcall_storage_get_free_size (smx_storage_t storage){ - return simcall_BODY_storage_get_free_size(storage); +size_t simcall_storage_get_free_size (const char* name){ + return simcall_BODY_storage_get_free_size(name); +} + +/** + * \ingroup simix_storage_management + * \brief Return the used space size on a given storage element. + * \param storage name + * \return Return the used space size on a given storage element (as size_t) + */ +size_t simcall_storage_get_used_size (const char* name){ + return simcall_BODY_storage_get_used_size(name); } /** diff --git a/src/surf/storage_private.h b/src/surf/storage_private.h index 8a18c5ce67..fe8db87c6d 100644 --- a/src/surf/storage_private.h +++ b/src/surf/storage_private.h @@ -14,7 +14,6 @@ typedef struct s_storage_type { char *type_id; xbt_dict_t properties; size_t size; - size_t used_size; } s_storage_type_t, *storage_type_t; typedef struct s_mount { diff --git a/src/surf/workstation.c b/src/surf/workstation.c index ea645c5a4d..5cc0873ab8 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -367,8 +367,18 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* mount) static xbt_dynar_t ws_get_storage_list(void *workstation) { + s_mount_t mnt; + unsigned int i; + xbt_dynar_t storage_list = xbt_dynar_new(sizeof(void*), NULL); + workstation_CLM03_t ws = (workstation_CLM03_t) surf_workstation_resource_priv(workstation); - return ws->storage; + xbt_dynar_t storages = ws->storage; + + xbt_dynar_foreach(storages,i,mnt) + { + xbt_dynar_push_as(storage_list, char*, mnt.name); + } + return storage_list; } static surf_action_t ws_action_open(void *workstation, const char* mount, @@ -462,13 +472,17 @@ static xbt_dynar_t ws_file_get_info(void *workstation, surf_file_t fd) return info; } -static size_t ws_storage_get_free_size(void *workstation, surf_storage_t storage) +static size_t ws_storage_get_free_size(void *workstation,const char* name) { - return storage->size - storage->used_size; - + storage_t st = find_storage_on_mount_list(workstation, name); + return st->size - st->used_size; } - +static size_t ws_storage_get_used_size(void *workstation,const char* name) +{ + storage_t st = find_storage_on_mount_list(workstation, name); + return st->used_size; +} static void surf_workstation_model_init_internal(void) { @@ -537,6 +551,7 @@ static void surf_workstation_model_init_internal(void) surf_workstation_model->extension.workstation.get_size = ws_file_get_size; surf_workstation_model->extension.workstation.get_info = ws_file_get_info; surf_workstation_model->extension.workstation.get_free_size = ws_storage_get_free_size; + surf_workstation_model->extension.workstation.get_used_size = ws_storage_get_used_size; surf_workstation_model->extension.workstation.get_storage_list = ws_get_storage_list; }