From: Pierre Veyre Date: Wed, 10 Jul 2013 10:56:00 +0000 (+0200) Subject: Add msg_storage_t structure, msg_storage_get_free_size function X-Git-Tag: v3_9_90~172 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/636c4a39fd7018786f10c6e66954aae0ed5677d5 Add msg_storage_t structure, msg_storage_get_free_size function --- diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index 91310e9139..c14242066d 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -113,8 +113,24 @@ typedef struct msg_file { You should consider this as an opaque object. */ + typedef struct msg_file *msg_file_t; +/* ******************************** Storage ************************************ */ +typedef struct simdata_storage *simdata_storage_t; + +typedef struct msg_storage { + char *model; + char *content_type; + char *type_id; + size_t size; + xbt_dict_t properties; + simdata_storage_t simdata; /**< @brief simulator data */ + void *data; /**< @brief user data */ +} s_msg_storage_t; + +typedef struct msg_storage *msg_storage_t; + /*************** Begin GPU ***************/ typedef struct simdata_gpu_task *simdata_gpu_task_t; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 5ac6e2c2ef..d62fc66923 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -70,6 +70,9 @@ typedef struct s_smx_sem *smx_sem_t; /********************************** File *************************************/ typedef struct s_smx_file *smx_file_t; +/********************************** Storage *************************************/ +typedef struct s_smx_storage *smx_storage_t; + /********************************** Action *************************************/ typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */ diff --git a/src/include/surf/datatypes.h b/src/include/surf/datatypes.h index 3171b355f0..955a6e2370 100644 --- a/src/include/surf/datatypes.h +++ b/src/include/surf/datatypes.h @@ -23,6 +23,7 @@ typedef struct surf_model *surf_model_t; */ typedef struct surf_action *surf_action_t; typedef struct surf_file *surf_file_t; +typedef struct surf_storage *surf_storage_t; typedef struct surf_stat *surf_stat_t; typedef struct lmm_element *lmm_element_t; diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index e6fd6ff33c..a61c76ac95 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -288,6 +288,9 @@ typedef struct surf_workstation_model_extension_public { xbt_dict_t(*get_properties) (const void *resource); void (*add_traces) (void); + + size_t (*get_free_size) (void *workstation, surf_storage_t storage); + } s_surf_model_extension_workstation_t; diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index e6cade0433..68930837bb 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -120,3 +120,14 @@ xbt_dict_t MSG_file_ls(const char *mount, const char *path) return simcall_file_ls(mount, path); } + +/** \ingroup msg_storage_management + * \brief Return the free space size of a storage element + * + * \param sd is the storage descriptor (#msg_storage_t) + * \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); +} diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 02af63d702..f9edb1166a 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -45,6 +45,11 @@ typedef struct simdata_file { smx_file_t smx_file; } s_simdata_file_t; +/********************************* Storage **************************************/ +typedef struct simdata_storage { + smx_storage_t smx_storage; +} s_simdata_storage_t; + /*************** Begin GPU ***************/ typedef struct simdata_gpu_task { double computation_amount; /* Computation size */ diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index fa32593884..7ebb6f1f21 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -239,6 +239,18 @@ size_t SIMIX_file_get_size(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) +{ + return SIMIX_storage_get_free_size(simcall->issuer, storage); +} + +size_t SIMIX_storage_get_free_size(smx_process_t process, smx_storage_t storage) +{ + smx_host_t host = process->smx_host; + return surf_workstation_model->extension.workstation.get_free_size(host, + storage->surf_storage); +} + 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 fbd377ae74..82b447181f 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -32,6 +32,9 @@ smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount, const char *path); size_t SIMIX_file_get_size(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); + 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/simix/smx_private.h b/src/simix/smx_private.h index 1130ff9329..1875079000 100644 --- a/src/simix/smx_private.h +++ b/src/simix/smx_private.h @@ -75,6 +75,11 @@ typedef struct s_smx_file { surf_file_t surf_file; } s_smx_file_t; +/* ******************************** Storage ************************************ */ +typedef struct s_smx_storage { + surf_storage_t surf_storage; +} s_smx_storage_t; + /*********************************** Time ************************************/ /** @brief Timer datatype */ diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index d92dc3e568..a6cfd8789d 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -353,6 +353,7 @@ ACTION(SIMCALL_FILE_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fd, s ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITH_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \ 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_STORAGE_GET_FREE_SIZE, storage_get_free_size, WITH_ANSWER, TSIZE(result), TSPEC(storage, smx_storage_t)) 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 81cef92c70..9a5d1f4381 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1235,6 +1235,14 @@ size_t simcall_file_get_size (smx_file_t fd){ return simcall_BODY_file_get_size(fd); } +/** + * \ingroup simix_storage_management + * + */ +size_t simcall_storage_get_free_size (smx_storage_t storage){ + return simcall_BODY_storage_get_free_size(storage); +} + #ifdef HAVE_MC void *simcall_mc_snapshot(void) diff --git a/src/surf/storage_private.h b/src/surf/storage_private.h index 5fe1b8fe71..9979e033f7 100644 --- a/src/surf/storage_private.h +++ b/src/surf/storage_private.h @@ -14,6 +14,7 @@ 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 { @@ -27,7 +28,7 @@ typedef struct surf_file { size_t size; } s_surf_file_t; -typedef struct storage { +typedef struct surf_storage { s_surf_resource_t generic_resource; /*< Structure with generic data. Needed at begin to interact with SURF */ e_surf_resource_state_t state_current; /*< STORAGE current state (ON or OFF) */ lmm_constraint_t constraint; /* Constraint for maximum bandwidth from connection */ @@ -36,6 +37,8 @@ typedef struct storage { xbt_dict_t content; /* char * -> s_surf_file_t */ size_t size; size_t used_size; + char *type_id; + char *content_type; xbt_dynar_t write_actions; } s_storage_t, *storage_t; diff --git a/src/surf/workstation.c b/src/surf/workstation.c index ed841dce8c..e413b2176d 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -443,6 +443,14 @@ static size_t ws_file_get_size(void *workstation, surf_file_t fd) return fd->size; } +static size_t ws_storage_get_free_size(void *workstation, surf_storage_t storage) +{ + return storage->size - storage->used_size; + +} + + + static void surf_workstation_model_init_internal(void) { surf_workstation_model = surf_model_init(); @@ -508,6 +516,7 @@ static void surf_workstation_model_init_internal(void) surf_workstation_model->extension.workstation.unlink = ws_file_unlink; surf_workstation_model->extension.workstation.ls = ws_action_ls; surf_workstation_model->extension.workstation.get_size = ws_file_get_size; + surf_workstation_model->extension.workstation.get_free_size = ws_storage_get_free_size; } void surf_workstation_model_init_current_default(void)