Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 25 Sep 2013 09:50:05 +0000 (11:50 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 25 Sep 2013 09:50:05 +0000 (11:50 +0200)
include/msg/msg.h
include/simgrid/platf.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_host.c
src/msg/msg_io.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/surf/storage.c
src/surf/storage_private.h

index a748f1e..e848f89 100644 (file)
@@ -142,6 +142,7 @@ XBT_PUBLIC(msg_host_t) MSG_get_host_by_name(const char *name);
 XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar(void);
 XBT_PUBLIC(int) MSG_get_host_number(void);
 XBT_PUBLIC(xbt_dynar_t) MSG_host_get_storage_list(msg_host_t host);
+XBT_PUBLIC(xbt_dynar_t) MSG_host_get_storage_content(msg_host_t host);
 /************************** Process handling *********************************/
 XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name,
                                            xbt_main_func_t code,
index 9017c61..b9ed1eb 100644 (file)
@@ -80,8 +80,6 @@ static inline char* sg_storage_name(sg_storage_t storage) {
   return storage->key;
 }
 
-
-
 /*
  * Platform creation functions. Instead of passing 123 arguments to the creation functions
  * (one for each possible XML attribute), we pass structures containing them all. It removes the
index 1c095a8..272829e 100644 (file)
@@ -264,8 +264,6 @@ XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
 XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
 XBT_PUBLIC(xbt_dynar_t) SIMIX_host_get_storage_list(smx_host_t host);
-XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_host_t host);
-
 /********************************* Process ************************************/
 XBT_PUBLIC(int) SIMIX_process_count(void);
 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
@@ -498,7 +496,7 @@ 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);
 XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
-
+XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_host_t host);
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
 /************************** AS router simcalls ***************************/
index 5e767d2..49c1000 100644 (file)
@@ -238,7 +238,7 @@ typedef struct surf_storage_model_extension_public {
   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 *storage);
-  xbt_dict_t(*get_content) (void *storage);
+  xbt_dict_t(*get_content) (const void *storage);
 } s_surf_model_extension_storage_t;
 
      /** \ingroup SURF_models
index 7b49fe7..682b07e 100644 (file)
@@ -341,10 +341,31 @@ double MSG_get_host_consumed_energy(msg_host_t host) {
 /** \ingroup m_host_management
  * \brief Return the list of mounted storages on an host.
  * \param host a host
- * \return a dynar containing all mounted storages on the host
+ * \return a dynar containing all storages mounted on the host
  */
 xbt_dynar_t MSG_host_get_storage_list(msg_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters");
   return (simcall_host_get_storage_list(host));
 }
+
+/** \ingroup msg_host_management
+ * \brief Return the content of mounted storages on an host.
+ * \param host a host
+ * \return a dynar containing content (as a dict) of all storages mounted on the host
+ */
+xbt_dynar_t MSG_host_get_storage_content(msg_host_t host)
+{
+  xbt_assert((host != NULL), "Invalid parameters");
+  xbt_dynar_t contents = xbt_dynar_new(sizeof(void *),NULL);
+  msg_storage_t storage;
+  char* storage_name;
+  unsigned int i;
+  xbt_dynar_t storage_list = simcall_host_get_storage_list(host);
+  xbt_dynar_foreach(storage_list, i, storage_name){
+       storage = xbt_lib_get_elm_or_null(storage_lib,storage_name);
+//     xbt_dict_t content = SIMIX_storage_get_content(storage);
+//     xbt_dynar_push(contents, &content);
+  }
+  return contents;
+}
index 24147ac..dbd31e8 100644 (file)
@@ -191,7 +191,7 @@ xbt_dict_t MSG_file_ls(const char *mount, const char *path)
 msg_storage_t __MSG_storage_create(smx_storage_t storage)
 {
   const char *name = SIMIX_storage_get_name(storage);
-  xbt_lib_set(storage_lib,name,MSG_HOST_LEVEL,storage);
+  xbt_lib_set(storage_lib,name,MSG_STORAGE_LEVEL,storage);
   return xbt_lib_get_elm_or_null(storage_lib, name);
 }
 
@@ -210,6 +210,7 @@ void __MSG_storage_destroy(msg_storage_priv_t storage) {
  * This functions checks whether a storage is a valid pointer or not and return its name.
  */
 const char *MSG_storage_get_name(msg_storage_t storage) {
+  xbt_assert((storage != NULL), "Invalid parameters");
   return SIMIX_storage_get_name(storage);
 }
 
@@ -261,7 +262,7 @@ void MSG_storage_set_property_value(msg_storage_t storage, const char *name, cha
  */
 msg_storage_t MSG_storage_get_by_name(const char *name)
 {
-  return (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib,name);
+  return (msg_storage_t) xbt_lib_get_or_null(storage_lib,name, MSG_STORAGE_LEVEL);
 }
 
 /** \ingroup msg_storage_management
@@ -315,7 +316,7 @@ void *MSG_storage_get_data(msg_storage_t storage)
  * \brief Returns the content (file list) of a #msg_storage_t.
  * \param storage a storage
  */
-xbt_dict_t MSG_storage_get_content(msg_storage_t storage){
-
+xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
+{
        return SIMIX_storage_get_content(storage);
 }
index 1c16b3b..9d7d19e 100644 (file)
@@ -21,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix,
  * \param storage the SURF storage to encapsulate
  * \param data some user data (may be NULL)
  */
-smx_host_t SIMIX_storage_create(const char *name, void *storage, void *data)
+smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data)
 {
   smx_storage_priv_t smx_storage = xbt_new0(s_smx_storage_priv_t, 1);
 
@@ -319,9 +319,12 @@ xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage){
   return surf_storage_model->extension.storage.get_properties(storage);
 }
 
+const char* SIMIX_pre_storage_get_name(smx_simcall_t simcall, smx_storage_t storage){
+   return SIMIX_storage_get_name(storage);
+}
+
 const char* SIMIX_storage_get_name(smx_storage_t storage){
   xbt_assert((storage != NULL), "Invalid parameters");
-
   return sg_storage_name(storage);
 }
 
index 7914bc8..8a9dcc3 100644 (file)
@@ -58,6 +58,8 @@ void* SIMIX_pre_storage_get_data(smx_simcall_t, smx_storage_t);
 xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage);
 xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage);
 
+const char* SIMIX_pre_storage_get_name(smx_simcall_t simcall, 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);
index 21a9c63..7ca79b1 100644 (file)
@@ -197,19 +197,18 @@ static xbt_dict_t storage_get_properties(const void *storage)
   return surf_resource_properties(surf_storage_resource_priv(storage));
 }
 
-static xbt_dict_t storage_get_content(void *storage)
+static xbt_dict_t storage_get_content(const void *storage)
 {
   /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
   /* surf_action_t action = storage_action_execute(storage,0, LS); */
   xbt_dict_t content_dict = xbt_dict_new();
-
   xbt_dict_cursor_t cursor = NULL;
   char *file;
   size_t size;
 
-  xbt_dict_foreach(((storage_t)storage)->content,cursor,file,size)
+  xbt_dict_foreach(((storage_t)storage)->content, cursor, file, size){
     xbt_dict_set(content_dict,file,&size,NULL);
-
+  }
   return content_dict;
 }
 
index eed61ab..e965b43 100644 (file)
@@ -33,7 +33,7 @@ typedef struct surf_storage {
   lmm_constraint_t constraint;          /* Constraint for maximum bandwidth from connection */
   lmm_constraint_t constraint_write;    /* Constraint for maximum write bandwidth*/
   lmm_constraint_t constraint_read;     /* Constraint for maximum write bandwidth*/
-  xbt_dict_t content; /* char * -> s_surf_file_t */
+  xbt_dict_t content;
   char* content_type;
   size_t size;
   size_t used_size;