Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify the way free and used space are accessed
authorsuter <frederic.suter@cc.in2p3.fr>
Fri, 11 Apr 2014 14:51:31 +0000 (16:51 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Fri, 11 Apr 2014 15:01:37 +0000 (17:01 +0200)
17 files changed:
include/msg/msg.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/simcalls.in
src/simix/simcalls_generated_args_getter_setter.h
src/simix/simcalls_generated_body.c
src/simix/simcalls_generated_case.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_user.c
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/surf_c_bindings.cpp
src/surf/workstation_interface.cpp
src/surf/workstation_interface.hpp
teshsuite/msg/storage/storage_basic.c

index 8800100..14da996 100644 (file)
@@ -101,8 +101,8 @@ XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const cha
 /************************** Storage handling ***********************************/
 XBT_PUBLIC(msg_host_t) MSG_get_storage_by_name(const char *name);
 XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(const char* name);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(const char* name);
+XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(msg_storage_t storage);
+XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(msg_storage_t storage);
 XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name);
 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
 XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn);
index 6299fd9..8a32204 100644 (file)
@@ -499,8 +499,8 @@ XBT_PUBLIC(sg_size_t) simcall_file_tell(smx_file_t fd);
 XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_size_t offset, int origin);
 XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath);
 /*****************************   Storage   **********************************/
-XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (const char* name);
-XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (const char* name);
+XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (smx_storage_t storage);
+XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (smx_storage_t storage);
 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
 XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
 XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
index 08d073e..1da385d 100644 (file)
@@ -751,6 +751,23 @@ XBT_PUBLIC(xbt_dict_t) surf_storage_get_content(surf_resource_t resource);
  */
 XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
 
+/**
+ * @brief Get the available size in bytes of a storage
+ *
+ * @param resource The surf storage
+ * @return The available size in bytes of the storage
+ */
+XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource);
+
+/**
+ * @brief Get the size in bytes of a storage
+ *
+ * @param resource The surf storage
+ * @return The used size in bytes of the storage
+ */
+XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_resource_t resource);
+
+
 /**
  * @brief Get the data associated to the action
  *
index 3f7e1f8..d5e1690 100644 (file)
@@ -443,20 +443,20 @@ const char *MSG_storage_get_name(msg_storage_t storage) {
 
 /** \ingroup msg_storage_management
  * \brief Returns the free space size of a storage element
- * \param name the name of a storage
+ * \param storage a storage
  * \return the free space size of the storage element (as a #sg_size_t)
  */
-sg_size_t MSG_storage_get_free_size(const char* name){
-  return simcall_storage_get_free_size(name);
+sg_size_t MSG_storage_get_free_size(msg_storage_t storage){
+  return simcall_storage_get_free_size(storage);
 }
 
 /** \ingroup msg_storage_management
  * \brief Returns the used space size of a storage element
- * \param name the name of a storage
+ * \param storage a storage
  * \return the used space size of the storage element (as a #sg_size_t)
  */
-sg_size_t MSG_storage_get_used_size(const char* name){
-  return simcall_storage_get_used_size(name);
+sg_size_t MSG_storage_get_used_size(msg_storage_t storage){
+  return simcall_storage_get_used_size(storage);
 }
 
 /** \ingroup msg_storage_management
index e28d7cc..d4b61ae 100644 (file)
@@ -118,8 +118,8 @@ file_tell True (sg_size_t) (fd, void*, smx_file_t)
 file_seek True (int) (fd, void*, smx_file_t) (offset, sg_size_t) (origin, int)
 file_get_info True (void*, xbt_dynar_t) (fd, void*, smx_file_t)
 file_move True (int) (fd, void*, smx_file_t) (fullpath, const char*)
-storage_get_free_size True (sg_size_t) (name, const char*)
-storage_get_used_size True (sg_size_t) (name, const char*)
+storage_get_free_size True (sg_size_t) (storage, void*, smx_storage_t)
+storage_get_used_size True (sg_size_t) (name, void*, smx_storage_t)
 storage_get_properties True (void*, xbt_dict_t) (storage, void*, smx_storage_t)
 storage_get_content True (void*, xbt_dict_t) (storage, void*, smx_storage_t)
 asr_get_properties True (void*, xbt_dict_t) (name, const char*)
index 2cd2752..f73e443 100644 (file)
@@ -1166,17 +1166,17 @@ static inline const char* simcall_file_move__get__fullpath(smx_simcall_t simcall
 static inline void simcall_file_move__set__fullpath(smx_simcall_t simcall, const char* arg){
     simcall->args[1].cc = arg;
 }
-static inline const char* simcall_storage_get_free_size__get__name(smx_simcall_t simcall){
-  return  simcall->args[0].cc;
+static inline smx_storage_t simcall_storage_get_free_size__get__storage(smx_simcall_t simcall){
+  return (smx_storage_t) simcall->args[0].dp;
 }
-static inline void simcall_storage_get_free_size__set__name(smx_simcall_t simcall, const char* arg){
-    simcall->args[0].cc = arg;
+static inline void simcall_storage_get_free_size__set__storage(smx_simcall_t simcall, void* arg){
+    simcall->args[0].dp = arg;
 }
-static inline const char* simcall_storage_get_used_size__get__name(smx_simcall_t simcall){
-  return  simcall->args[0].cc;
+static inline smx_storage_t simcall_storage_get_used_size__get__name(smx_simcall_t simcall){
+  return (smx_storage_t) simcall->args[0].dp;
 }
-static inline void simcall_storage_get_used_size__set__name(smx_simcall_t simcall, const char* arg){
-    simcall->args[0].cc = arg;
+static inline void simcall_storage_get_used_size__set__name(smx_simcall_t simcall, void* arg){
+    simcall->args[0].dp = arg;
 }
 static inline smx_storage_t simcall_storage_get_properties__get__storage(smx_simcall_t simcall){
   return (smx_storage_t) simcall->args[0].dp;
index c6e1f25..2674738 100644 (file)
     }    
     return self->simcall.result.i;
   }
-  inline static sg_size_t simcall_BODY_storage_get_free_size(const char* name) {
+  inline static sg_size_t simcall_BODY_storage_get_free_size(smx_storage_t storage) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_STORAGE_GET_FREE_SIZE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].cc = (const char*) name;
+    self->simcall.args[0].dp = (void*) storage;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
     }    
     return self->simcall.result.sgsz;
   }
-  inline static sg_size_t simcall_BODY_storage_get_used_size(const char* name) {
+  inline static sg_size_t simcall_BODY_storage_get_used_size(smx_storage_t name) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_STORAGE_GET_USED_SIZE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].cc = (const char*) name;
+    self->simcall.args[0].dp = (void*) name;
     if (self != simix_global->maestro_process) {
       XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
                 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
index 45ef5a2..e7ebf72 100644 (file)
@@ -548,12 +548,12 @@ case SIMCALL_FILE_MOVE:
       break;  
 
 case SIMCALL_STORAGE_GET_FREE_SIZE:
-      simcall->result.sgsz = SIMIX_pre_storage_get_free_size(simcall ,  simcall->args[0].cc);
+      simcall->result.sgsz = SIMIX_pre_storage_get_free_size(simcall , (smx_storage_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
       break;  
 
 case SIMCALL_STORAGE_GET_USED_SIZE:
-      simcall->result.sgsz = SIMIX_pre_storage_get_used_size(simcall ,  simcall->args[0].cc);
+      simcall->result.sgsz = SIMIX_pre_storage_get_used_size(simcall , (smx_storage_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
       break;  
 
index 969991b..cd48e0a 100644 (file)
@@ -262,26 +262,29 @@ int SIMIX_file_move(smx_process_t process, smx_file_t file, const char* fullpath
   return  surf_workstation_file_move(host, file->surf_file, fullpath);
 }
 
-sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name)
+sg_size_t SIMIX_storage_get_size(smx_storage_t storage){
+  xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
+  return surf_storage_get_size(storage);
+}
+
+sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage)
 {
-  return SIMIX_storage_get_free_size(simcall->issuer, name);
+  return SIMIX_storage_get_free_size(simcall->issuer, storage);
 }
 
-sg_size_t SIMIX_storage_get_free_size(smx_process_t process, const char* name)
+sg_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_get_free_size(host, name);
+  return  surf_storage_get_free_size(storage);
 }
 
-sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, const char* name)
+sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, smx_storage_t storage)
 {
-  return SIMIX_storage_get_used_size(simcall->issuer, name);
+  return SIMIX_storage_get_used_size(simcall->issuer, storage);
 }
 
-sg_size_t SIMIX_storage_get_used_size(smx_process_t process, const char* name)
+sg_size_t SIMIX_storage_get_used_size(smx_process_t process, smx_storage_t storage)
 {
-  smx_host_t host = process->smx_host;
-  return  surf_workstation_get_used_size(host, name);
+  return  surf_storage_get_used_size(storage);
 }
 
 xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t simcall, smx_storage_t storage){
@@ -310,11 +313,6 @@ xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage){
   return surf_storage_get_content(storage);
 }
 
-sg_size_t SIMIX_storage_get_size(smx_storage_t storage){
-  xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
-  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);
 }
index 82f14f0..8ddde55 100644 (file)
@@ -43,11 +43,11 @@ xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd);
 int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int origin);
 int SIMIX_file_move(smx_process_t process, smx_file_t fd, const char* fullpath);
 
-sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name);
-sg_size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name);
+sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,smx_storage_t storage);
+sg_size_t SIMIX_storage_get_free_size(smx_process_t process,smx_storage_t storage);
 
-sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,const char* name);
-sg_size_t SIMIX_storage_get_used_size(smx_process_t process,const char* name);
+sg_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,smx_storage_t storage);
+sg_size_t SIMIX_storage_get_used_size(smx_process_t process,smx_storage_t storage);
 
 xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage);
 xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t, smx_storage_t);
index 4248741..18be610 100644 (file)
@@ -1405,21 +1405,21 @@ int simcall_file_move(smx_file_t fd, const char* fullpath)
 /**
  * \ingroup simix_storage_management
  * \brief Returns the free space size on a given storage element.
- * \param storage name
+ * \param storage a storage
  * \return Return the free space size on a given storage element (as sg_size_t)
  */
-sg_size_t simcall_storage_get_free_size (const char* name){
-  return simcall_BODY_storage_get_free_size(name);
+sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
+  return simcall_BODY_storage_get_free_size(storage);
 }
 
 /**
  * \ingroup simix_storage_management
  * \brief Returns the used space size on a given storage element.
- * \param storage name
+ * \param storage a storage
  * \return Return the used space size on a given storage element (as sg_size_t)
  */
-sg_size_t simcall_storage_get_used_size (const char* name){
-  return simcall_BODY_storage_get_used_size(name);
+sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
+  return simcall_BODY_storage_get_used_size(storage);
 }
 
 /**
index bbe4616..0979285 100644 (file)
@@ -163,6 +163,14 @@ sg_size_t Storage::getSize(){
   return m_size;
 }
 
+sg_size_t Storage::getFreeSize(){
+  return m_size - m_usedSize;
+}
+
+sg_size_t Storage::getUsedSize(){
+  return m_usedSize;
+}
+
 /**********
  * Action *
  **********/
index db02f42..9db89ae 100644 (file)
@@ -233,6 +233,21 @@ public:
    */
   virtual sg_size_t getSize();
 
+  /**
+   * @brief Get the available size in bytes of the current Storage
+   *
+   * @return The available size in bytes of the current Storage
+   */
+  virtual sg_size_t getFreeSize();
+
+  /**
+   * @brief Get the used size in bytes of the current Storage
+   *
+   * @return The used size in bytes of the current Storage
+   */
+  virtual sg_size_t getUsedSize();
+
+
   xbt_dict_t parseContent(char *filename);
 
   xbt_dynar_t p_writeActions;
index 0cefa0c..20931bc 100644 (file)
@@ -388,14 +388,6 @@ xbt_dynar_t surf_workstation_get_info(surf_resource_t resource, surf_file_t fd){
   return get_casted_workstation(resource)->getInfo(fd);
 }
 
-sg_size_t surf_workstation_get_free_size(surf_resource_t resource, const char* name){
-  return get_casted_workstation(resource)->getFreeSize(name);
-}
-
-sg_size_t surf_workstation_get_used_size(surf_resource_t resource, const char* name){
-  return get_casted_workstation(resource)->getUsedSize(name);
-}
-
 size_t surf_workstation_file_tell(surf_resource_t workstation, surf_file_t fd){
   return get_casted_workstation(workstation)->fileTell(fd);
 }
@@ -476,6 +468,14 @@ sg_size_t surf_storage_get_size(surf_resource_t resource){
   return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getSize();
 }
 
+sg_size_t surf_storage_get_free_size(surf_resource_t resource){
+  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getFreeSize();
+}
+
+sg_size_t surf_storage_get_used_size(surf_resource_t resource){
+  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getUsedSize();
+}
+
 const char* surf_storage_get_host(surf_resource_t resource){
   return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->p_attach;
 }
index 66e261d..70f949c 100644 (file)
@@ -362,18 +362,6 @@ int Workstation::fileMove(surf_file_t fd, const char* fullpath){
   }
 }
 
-sg_size_t Workstation::getFreeSize(const char* name)
-{
-  StoragePtr st = findStorageOnMountList(name);
-  return st->m_size - st->m_usedSize;
-}
-
-sg_size_t Workstation::getUsedSize(const char* name)
-{
-  StoragePtr st = findStorageOnMountList(name);
-  return st->m_usedSize;
-}
-
 xbt_dynar_t Workstation::getVms()
 {
   xbt_dynar_t dyn = xbt_dynar_new(sizeof(smx_host_t), NULL);
index 1be3e4a..0d50aff 100644 (file)
@@ -330,23 +330,7 @@ public:
   virtual sg_size_t fileTell(surf_file_t fd);
 
   /**
-   * @brief Get the available space of the storage at the mount point
-   *
-   * @param name The mount point
-   * @return The amount of availble space in bytes
-   */
-  virtual sg_size_t getFreeSize(const char* name);
-
-  /**
-   * @brief Get the used space of the storage at the mount point
-   *
-   * @param name The mount point
-   * @return The amount of used space in bytes
-   */
-  virtual sg_size_t getUsedSize(const char* name);
-
-  /**
-   * @brief Set the position indictator assiociated with the file descriptor to a new position
+   * @brief Set the position indicator associated with the file descriptor to a new position
    * @details [long description]
    *
    * @param fd The file descriptor
index 38e07ee..d352f27 100644 (file)
@@ -36,13 +36,14 @@ void storage_info(msg_host_t host)
   {
     XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
 
-    sg_size_t free_size = MSG_storage_get_free_size(mount_name);
-    sg_size_t used_size = MSG_storage_get_used_size(mount_name);
+    storage = MSG_storage_get_by_name(storage_name);
+
+    sg_size_t free_size = MSG_storage_get_free_size(storage);
+    sg_size_t used_size = MSG_storage_get_used_size(storage);
 
     XBT_INFO("\t\tFree size: %llu bytes", free_size);
     XBT_INFO("\t\tUsed size: %llu bytes", used_size);
 
-    storage = MSG_storage_get_by_name(storage_name);
     display_storage_properties(storage);
     dump_storage_by_name(storage_name);
   }