Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add msg_storage_t structure, msg_storage_get_free_size function
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 10 Jul 2013 10:56:00 +0000 (12:56 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 10 Jul 2013 10:56:00 +0000 (12:56 +0200)
13 files changed:
include/msg/datatypes.h
include/simgrid/simix.h
src/include/surf/datatypes.h
src/include/surf/surf.h
src/msg/msg_io.c
src/msg/msg_private.h
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/storage_private.h
src/surf/workstation.c

index 91310e9..c142420 100644 (file)
@@ -113,8 +113,24 @@ typedef struct msg_file {
  
     You should consider this as an opaque object.
  */
  
     You should consider this as an opaque object.
  */
+
 typedef struct msg_file *msg_file_t;
 
 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;
 
 /*************** Begin GPU ***************/
 typedef struct simdata_gpu_task *simdata_gpu_task_t;
 
index 5ac6e2c..d62fc66 100644 (file)
@@ -70,6 +70,9 @@ typedef struct s_smx_sem *smx_sem_t;
 /********************************** File *************************************/
 typedef struct s_smx_file *smx_file_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 */
 
 /********************************** Action *************************************/
 typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
 
index 3171b35..955a6e2 100644 (file)
@@ -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_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;
 typedef struct surf_stat *surf_stat_t;
 
 typedef struct lmm_element *lmm_element_t;
index e6fd6ff..a61c76a 100644 (file)
@@ -288,6 +288,9 @@ typedef struct surf_workstation_model_extension_public {
    xbt_dict_t(*get_properties) (const void *resource);
   void (*add_traces) (void);
 
    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;
 
 
 } s_surf_model_extension_workstation_t;
 
 
index e6cade0..6893083 100644 (file)
@@ -120,3 +120,14 @@ xbt_dict_t MSG_file_ls(const char *mount, const char *path)
 
   return simcall_file_ls(mount, 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);
+}
index 02af63d..f9edb11 100644 (file)
@@ -45,6 +45,11 @@ typedef struct simdata_file {
   smx_file_t smx_file;
 } s_simdata_file_t;
 
   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 */
 /*************** Begin GPU ***************/
 typedef struct simdata_gpu_task {
   double computation_amount;    /* Computation size */
index fa32593..7ebb6f1 100644 (file)
@@ -239,6 +239,18 @@ size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd)
       fd->surf_file);
 }
 
       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)
 {
 
 void SIMIX_post_io(smx_action_t action)
 {
index fbd377a..82b4471 100644 (file)
@@ -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);
 
                            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);
 void SIMIX_post_io(smx_action_t action);
 void SIMIX_io_destroy(smx_action_t action);
 void SIMIX_io_finish(smx_action_t action);
index 1130ff9..1875079 100644 (file)
@@ -75,6 +75,11 @@ typedef struct s_smx_file {
   surf_file_t surf_file;
 } s_smx_file_t;
 
   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 */
 /*********************************** Time ************************************/
 
 /** @brief Timer datatype */
index d92dc3e..a6cfd87 100644 (file)
@@ -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_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
 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
index 81cef92..9a5d1f4 100644 (file)
@@ -1235,6 +1235,14 @@ size_t simcall_file_get_size (smx_file_t fd){
   return simcall_BODY_file_get_size(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)
 #ifdef HAVE_MC
 
 void *simcall_mc_snapshot(void)
index 5fe1b8f..9979e03 100644 (file)
@@ -14,6 +14,7 @@ typedef struct s_storage_type {
   char *type_id;
   xbt_dict_t properties;
   size_t size;
   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 {
 } 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;
 
   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 */
   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;
   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;
 
   xbt_dynar_t write_actions;
 } s_storage_t, *storage_t;
 
index ed841dc..e413b21 100644 (file)
@@ -443,6 +443,14 @@ static size_t ws_file_get_size(void *workstation, surf_file_t fd)
   return fd->size;
 }
 
   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();
 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.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)
 }
 
 void surf_workstation_model_init_current_default(void)