Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Storage API
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Tue, 10 Sep 2013 07:59:45 +0000 (09:59 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Tue, 10 Sep 2013 07:59:45 +0000 (09:59 +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.c
src/surf/storage_private.h
src/surf/surf_routing.c

index 9f1aff9..50104e4 100644 (file)
@@ -97,7 +97,6 @@ XBT_PUBLIC(size_t) MSG_storage_get_used_size(const char* name);
 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(xbt_dynar_t) MSG_storages_as_dynar(void);
 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(xbt_dynar_t) MSG_storages_as_dynar(void);
-
 /************************** 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);
 /************************** 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 a13c31c..9692cbd 100644 (file)
@@ -491,6 +491,7 @@ XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
 /*****************************   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);
 /*****************************   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);
+XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
 
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
 
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
index ec366ea..5b63ef5 100644 (file)
@@ -237,6 +237,7 @@ typedef struct surf_storage_model_extension_public {
   surf_action_t(*write) (void *storage, size_t size, surf_file_t fd);
   surf_action_t(*stat) (void *storage, surf_file_t fd);
   surf_action_t(*ls) (void *storage, const char *path);
   surf_action_t(*write) (void *storage, size_t size, surf_file_t fd);
   surf_action_t(*stat) (void *storage, surf_file_t fd);
   surf_action_t(*ls) (void *storage, const char *path);
+  xbt_dict_t(*get_properties) (const void *resource);
 } s_surf_model_extension_storage_t;
 
      /** \ingroup SURF_models
 } s_surf_model_extension_storage_t;
 
      /** \ingroup SURF_models
@@ -584,6 +585,8 @@ XBT_PUBLIC(void) surf_storage_model_init_default(void);
  */
 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
 
  */
 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
 
+XBT_PUBLIC_DATA(surf_model_t) surf_storage_model;
+
 /** \ingroup SURF_models
  *  \brief The workstation model
  *
 /** \ingroup SURF_models
  *  \brief The workstation model
  *
index af33f20..1c1fdd6 100644 (file)
@@ -113,7 +113,6 @@ msg_file_t MSG_file_open(const char* mount, const char* fullname, void* data)
   file->info = xbt_new0(s_file_info_t,1);
   file->simdata->smx_file = simcall_file_open(mount, fullname);
   SIMIX_file_set_data(file->simdata->smx_file, data);
   file->info = xbt_new0(s_file_info_t,1);
   file->simdata->smx_file = simcall_file_open(mount, fullname);
   SIMIX_file_set_data(file->simdata->smx_file, data);
-
   return file;
 }
 
   return file;
 }
 
@@ -181,8 +180,14 @@ xbt_dict_t MSG_file_ls(const char *mount, const char *path)
 
 /********************************* Storage **************************************/
 
 
 /********************************* Storage **************************************/
 
+/** @addtogroup msg_storage_management
+ *     \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Storages" --> \endhtmlonly
+ * (#msg_storage_t) and the functions for managing it.
+ *
+ */
+
 /** \ingroup msg_storage_management
 /** \ingroup msg_storage_management
- * \brief Return the free space size of a storage element
+ * \brief Returns the free space size of a storage element
  * \param the storage name (#char*)
  * \return the free space size of the storage element (as a size_t)
  */
  * \param the storage name (#char*)
  * \return the free space size of the storage element (as a size_t)
  */
@@ -191,7 +196,7 @@ size_t MSG_storage_get_free_size(const char* name){
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
- * \brief Return the used space size of a storage element
+ * \brief Returns 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)
  */
  * \param the storage name (#char*)
  * \return the used space size of the storage element (as a size_t)
  */
@@ -207,10 +212,7 @@ size_t MSG_storage_get_used_size(const char* name){
 xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
 {
   xbt_assert((storage != NULL), "Invalid parameters (storage is NULL)");
 xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
 {
   xbt_assert((storage != NULL), "Invalid parameters (storage is NULL)");
-
-  xbt_die( "Not implemented yet");
-  return xbt_dict_new();
-  //return (simcall_host_get_properties(storage));
+  return (simcall_storage_get_properties(storage->simdata->smx_storage));
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
@@ -220,22 +222,35 @@ xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
  */
 msg_storage_t MSG_storage_get_by_name(const char *name)
 {
  */
 msg_storage_t MSG_storage_get_by_name(const char *name)
 {
-  return (msg_storage_t) xbt_lib_get_elm_or_null(host_lib,name);
+  return (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib,name);
 }
 
 /** \ingroup msg_storage_management
 }
 
 /** \ingroup msg_storage_management
- * \brief Return a dynar containing all the storages declared at a given point of time
+ * \brief Returns a dynar containing all the storage elements declared at a given point of time
+ *
+ *
+ *
+ * @TODO implement a new msg_storage_t structure that hides members (use xbt_dict)
  */
 xbt_dynar_t MSG_storages_as_dynar(void) {
 
  */
 xbt_dynar_t MSG_storages_as_dynar(void) {
 
-  xbt_dynar_t storages = xbt_dynar_new(sizeof(msg_host_t), NULL);
-  xbt_dynar_t hosts;
-  msg_host_t host;
-  unsigned int i;
-
-  hosts = MSG_hosts_as_dynar();
-  xbt_dynar_foreach(hosts, i, host){
-       xbt_dynar_push(storages,xbt_lib_get_level((void *)host, SURF_STORAGE_LEVEL));
+  xbt_lib_cursor_t cursor;
+  char *key;
+  void **data;
+  xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),NULL);
+  msg_storage_t storage;
+  xbt_lib_foreach(storage_lib, cursor, key, data) {
+    if(routing_get_network_element_type(key) == ROUTING_STORAGE_LEVEL) {
+      xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
+      storage = xbt_new(s_msg_storage_t, 1);
+      storage->name = elm->key;
+      storage->simdata = xbt_new0(s_simdata_storage_t,1);
+      smx_storage_t simix_storage = xbt_lib_get_or_null(storage_lib, elm->key, SURF_STORAGE_LEVEL);
+      storage->simdata->smx_storage = simix_storage;
+      storage->data = NULL;
+      xbt_dynar_push(res, &storage);
+    }
   }
   }
-  return storages;
+
+  return res;
 }
 }
index e572e3a..3561716 100644 (file)
@@ -293,6 +293,14 @@ size_t SIMIX_storage_get_used_size(smx_process_t process, const char* name)
   return  surf_workstation_model->extension.workstation.get_used_size(host,name);
 }
 
   return  surf_workstation_model->extension.workstation.get_used_size(host,name);
 }
 
+xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t simcall, smx_storage_t storage){
+  return SIMIX_storage_get_properties(storage);
+}
+xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage){
+  xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
+  return surf_storage_model->extension.storage.get_properties(storage);
+}
+
 void SIMIX_post_io(smx_action_t action)
 {
   xbt_fifo_item_t i;
 void SIMIX_post_io(smx_action_t action)
 {
   xbt_fifo_item_t i;
index 76396fa..584adc4 100644 (file)
@@ -44,6 +44,9 @@ 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);
 
 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);
 
+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);
+
 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 9669242..2176f1f 100644 (file)
@@ -359,6 +359,7 @@ ACTION(SIMCALL_FILE_GET_SIZE, file_get_size, WITH_ANSWER, TSIZE(result), TSPEC(f
 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), TSTRING(name)) sep \
 ACTION(SIMCALL_STORAGE_GET_USED_SIZE, storage_get_used_size, WITH_ANSWER, TSIZE(result), TSTRING(name)) 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), TSTRING(name)) sep \
 ACTION(SIMCALL_STORAGE_GET_USED_SIZE, storage_get_used_size, WITH_ANSWER, TSIZE(result), TSTRING(name)) sep \
+ACTION(SIMCALL_STORAGE_GET_PROPERTIES, storage_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), 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 0c02e5e..fb1e54f 100644 (file)
@@ -1270,7 +1270,7 @@ xbt_dynar_t simcall_file_get_info(smx_file_t fd)
 
 /**
  * \ingroup simix_storage_management
 
 /**
  * \ingroup simix_storage_management
- * \brief Return the free space size on a given storage element.
+ * \brief Returns 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)
  */
  * \param storage name
  * \return Return the free space size on a given storage element (as size_t)
  */
@@ -1280,7 +1280,7 @@ size_t simcall_storage_get_free_size (const char* name){
 
 /**
  * \ingroup simix_storage_management
 
 /**
  * \ingroup simix_storage_management
- * \brief Return the used space size on a given storage element.
+ * \brief Returns 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)
  */
  * \param storage name
  * \return Return the used space size on a given storage element (as size_t)
  */
@@ -1290,7 +1290,7 @@ size_t simcall_storage_get_used_size (const char* name){
 
 /**
  * \ingroup simix_storage_management
 
 /**
  * \ingroup simix_storage_management
- * \brief Return the list of storages mounted on an host.
+ * \brief Returns the list of storages mounted on an host.
  * \param host A SIMIX host
  * \return a dynar containing all storages mounted on the host
  */
  * \param host A SIMIX host
  * \return a dynar containing all storages mounted on the host
  */
@@ -1299,6 +1299,18 @@ xbt_dynar_t simcall_host_get_storage_list(smx_host_t host)
   return simcall_BODY_host_get_storage_list(host);
 }
 
   return simcall_BODY_host_get_storage_list(host);
 }
 
+/**
+ * \ingroup simix_storage_management
+ * \brief Returns a dict of the properties assigned to a storage element.
+ *
+ * \param storage A storage element
+ * \return The properties of this storage element
+ */
+xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
+{
+  return simcall_BODY_storage_get_properties(storage);
+}
+
 
 #ifdef HAVE_MC
 
 
 #ifdef HAVE_MC
 
index aa0f3eb..8584505 100644 (file)
@@ -192,6 +192,11 @@ static surf_action_t storage_action_execute (void *storage, size_t size, e_surf_
   return (surf_action_t) action;
 }
 
   return (surf_action_t) action;
 }
 
+static xbt_dict_t storage_get_properties(const void *storage)
+{
+  return surf_resource_properties(storage);
+}
+
 static void* storage_create_resource(const char* id, const char* model,
     const char* type_id, const char* content_name, const char* content_type){
   storage_t storage = NULL;
 static void* storage_create_resource(const char* id, const char* model,
     const char* type_id, const char* content_name, const char* content_type){
   storage_t storage = NULL;
@@ -208,6 +213,7 @@ static void* storage_create_resource(const char* id, const char* model,
   storage->size = 0;
   storage->write_actions = xbt_dynar_new(sizeof(char *),NULL);
 
   storage->size = 0;
   storage->write_actions = xbt_dynar_new(sizeof(char *),NULL);
 
+
   storage_type_t storage_type = xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
   double Bread =
       surf_parse_get_bandwidth(xbt_dict_get(storage_type->properties,"Bread"));
   storage_type_t storage_type = xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
   double Bread =
       surf_parse_get_bandwidth(xbt_dict_get(storage_type->properties,"Bread"));
@@ -498,6 +504,8 @@ static void surf_storage_model_init_internal(void)
   surf_storage_model->extension.storage.write = storage_action_write;
   surf_storage_model->extension.storage.ls = storage_action_ls;
 
   surf_storage_model->extension.storage.write = storage_action_write;
   surf_storage_model->extension.storage.ls = storage_action_ls;
 
+  surf_storage_model->extension.storage.get_properties = storage_get_properties;
+
   if (!storage_maxmin_system) {
     storage_maxmin_system = lmm_system_new(storage_selective_update);
   }
   if (!storage_maxmin_system) {
     storage_maxmin_system = lmm_system_new(storage_selective_update);
   }
@@ -681,3 +689,4 @@ void storage_register_callbacks() {
   sg_platf_storage_type_add_cb(storage_parse_storage_type);
   sg_platf_mount_add_cb(storage_parse_mount);
 }
   sg_platf_storage_type_add_cb(storage_parse_storage_type);
   sg_platf_mount_add_cb(storage_parse_mount);
 }
+
index fe8db87..eed61ab 100644 (file)
@@ -39,6 +39,7 @@ typedef struct surf_storage {
   size_t used_size;
   char *type_id;
   xbt_dynar_t write_actions;
   size_t used_size;
   char *type_id;
   xbt_dynar_t write_actions;
+  xbt_dict_t properties;
 } s_storage_t, *storage_t;
 
 typedef enum {
 } s_storage_t, *storage_t;
 
 typedef enum {
index 7380bf6..e10de03 100644 (file)
@@ -20,7 +20,8 @@ int ROUTING_HOST_LEVEL;         //Routing level
 int SURF_CPU_LEVEL;             //Surf cpu level
 int SURF_WKS_LEVEL;             //Surf workstation level
 int SIMIX_HOST_LEVEL;           //Simix level
 int SURF_CPU_LEVEL;             //Surf cpu level
 int SURF_WKS_LEVEL;             //Surf workstation level
 int SIMIX_HOST_LEVEL;           //Simix level
-int MSG_HOST_LEVEL;             //Msg level
+int SIMIX_STORAGE_LEVEL;           //Simix level
+int MSG_HOST_LEVEL;             //Msg host level
 int SD_HOST_LEVEL;              //Simdag level
 int COORD_HOST_LEVEL=0;         //Coordinates level
 int NS3_HOST_LEVEL;             //host node for ns3
 int SD_HOST_LEVEL;              //Simdag level
 int COORD_HOST_LEVEL=0;         //Coordinates level
 int NS3_HOST_LEVEL;             //host node for ns3