Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix MSG_storage_get_free_size() and add MSG_storage_get_used_size()
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Fri, 12 Jul 2013 14:24:18 +0000 (16:24 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Fri, 12 Jul 2013 14:24:18 +0000 (16:24 +0200)
include/msg/msg.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/storage_private.h
src/surf/workstation.c

index 154af25..578e222 100644 (file)
@@ -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);
index 1c72dbe..4a521c5 100644 (file)
@@ -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 ***************************/
index b1aab86..ec366ea 100644 (file)
@@ -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;
index c443d83..898582d 100644 (file)
@@ -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);
 }
index 78be8b0..dd52bf1 100644 (file)
@@ -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)
 {
index d52cc64..8b3be6a 100644 (file)
@@ -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);
index fe5c8fa..9e6bc2f 100644 (file)
@@ -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
index 15b9899..3e0c130 100644 (file)
@@ -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);
 }
 
 /**
index 8a18c5c..fe8db87 100644 (file)
@@ -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 {
index ea645c5..5cc0873 100644 (file)
@@ -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;
 }