Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Finally succeed to bring back all the needed information from SURF to
authorsuter <frederic.suter@cc.in2p3.fr>
Thu, 11 Jul 2013 09:12:42 +0000 (11:12 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Thu, 11 Jul 2013 09:20:42 +0000 (11:20 +0200)
MSG in one simcall. Dynars are my friends ;)

include/msg/datatypes.h
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 c142420..53a3c8c 100644 (file)
@@ -102,10 +102,19 @@ typedef struct msg_vm {
 /* ******************************** File ************************************ */
 typedef struct simdata_file *simdata_file_t;
 
+typedef struct s_file_info {
+  size_t size;
+  char* mount_point;
+  char* storageId;
+  char* storage_type;
+  char* content_type;
+} s_file_info_t, *msg_file_info_t;
+
 typedef struct msg_file {
   char *fullname;               /**< @brief file full name (path+name)*/
   simdata_file_t simdata;       /**< @brief simulator data  */
   void *data;                   /**< @brief user data */
+  msg_file_info_t info;
 } s_msg_file_t;
 
 /** @brief File datatype.
index bc4cc50..154af25 100644 (file)
@@ -89,6 +89,7 @@ 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);
 /************************** 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 5308e81..1c72dbe 100644 (file)
@@ -480,6 +480,7 @@ XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
 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);
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
index 2909fa4..b1aab86 100644 (file)
@@ -283,6 +283,7 @@ typedef struct surf_workstation_model_extension_public {
   int(*unlink) (void *workstation, surf_file_t fd);
   surf_action_t(*ls) (void *workstation, const char* mount, const char *path);
   size_t (*get_size) (void *workstation, surf_file_t fd);
+  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);
index 6c8817e..c443d83 100644 (file)
@@ -18,7 +18,16 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg,
  */
 
 /********************************* File **************************************/
-
+void __MSG_file_get_info(msg_file_t fd){
+  xbt_dynar_t info = simcall_file_get_info(fd->simdata->smx_file);
+  fd->info->content_type = xbt_dynar_pop_as(info, char *);
+  fd->info->storage_type = xbt_dynar_pop_as(info, char *);
+  fd->info->storageId = xbt_dynar_pop_as(info, char *);
+  fd->info->mount_point = xbt_dynar_pop_as(info, char *);
+  fd->info->size = xbt_dynar_pop_as(info, size_t);
+
+  xbt_dynar_free_container(&info);
+}
 /** \ingroup msg_file_management
  * \brief Display information related to a file descriptor
  *
@@ -26,13 +35,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg,
  */
 
 void MSG_file_dump (msg_file_t fd){
-   THROW_UNIMPLEMENTED;
+//   THROW_UNIMPLEMENTED;
   /* Update the cached information first */
-//  fd->info = __MSG_file_get_info(fd);
-//  XBT_INFO("File Descriptor information:\n\t\tFull name: '%s'"
-//      "\n\t\tSize: %zu\n\t\tMount point: '%s'\n\t\t Storage Id: '%s'"
-//      "\n\t\t Content Type: '%s'", fd->fullname, fd->info->size, NULL,NULL,NULL);
-//      fd->info->mount_point, fd->info->storageId, fd->info->content_type);
+  __MSG_file_get_info(fd);
+  XBT_INFO("File Descriptor information:\n\t\tFull name: '%s'"
+      "\n\t\tSize: %zu\n\t\tMount point: '%s'\n\t\tStorage Id: '%s'"
+      "\n\t\tStorage Type: '%s'\n\t\tContent Type: '%s'",
+      fd->fullname, fd->info->size, fd->info->mount_point, fd->info->storageId,
+      fd->info->storage_type, fd->info->content_type);
 }
 
 /** \ingroup msg_file_management
@@ -72,6 +82,7 @@ msg_file_t MSG_file_open(const char* mount, const char* fullname)
   msg_file_t file = xbt_new(s_msg_file_t,1);
   file->fullname = xbt_strdup(fullname);
   file->simdata = xbt_new0(s_simdata_file_t,1);
+  file->info = xbt_new0(s_file_info_t,1);
   file->simdata->smx_file = simcall_file_open(mount, fullname);
   return file;
 }
@@ -87,6 +98,7 @@ int MSG_file_close(msg_file_t fd)
   int res = simcall_file_close(fd->simdata->smx_file);
   free(fd->fullname);
   xbt_free(fd->simdata);
+  xbt_free(fd->info);
   xbt_free(fd);
   return res;
 }
index 7ebb6f1..78be8b0 100644 (file)
@@ -239,6 +239,18 @@ size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd)
       fd->surf_file);
 }
 
+xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd)
+{
+  return SIMIX_file_get_info(simcall->issuer, fd);
+}
+
+xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd)
+{
+  smx_host_t host = process->smx_host;
+  return  surf_workstation_model->extension.workstation.get_info(host,
+      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);
index 82b4471..d52cc64 100644 (file)
@@ -19,6 +19,7 @@ int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
 void SIMIX_pre_file_ls(smx_simcall_t simcall,
                        const char* mount, const char* path);
 size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
+xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd);
 
 smx_action_t SIMIX_file_read(smx_process_t process, size_t size,
                              smx_file_t fd);
@@ -31,6 +32,7 @@ int SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
 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);
+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);
index f1fc983..fe5c8fa 100644 (file)
@@ -354,6 +354,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_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_ASR_GET_PROPERTIES, asr_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(name)) sep 
 
index 56c1f0f..15b9899 100644 (file)
@@ -1236,6 +1236,15 @@ size_t simcall_file_get_size (smx_file_t fd){
 }
 
 /**
+ * \ingroup simix_file_management
+ *
+ */
+xbt_dynar_t simcall_file_get_info(smx_file_t fd)
+{
+  return simcall_BODY_file_get_info(fd);
+}
+
+/**
  * \ingroup simix_storage_management
  * \brief Return the free size on a given storage element.
  * \param storage A SIMIX storage
index d0a7265..8a18c5c 100644 (file)
@@ -22,18 +22,10 @@ typedef struct s_mount {
   char *name;
 } s_mount_t, *mount_t;
 
-typedef struct s_file_info {
-  size_t size;
-  char* mount_point;
-  char* storageId;
-  char* content_type;
-} s_file_info_t, *surf_file_info_t;
-
 typedef struct surf_file {
   char *name;
   char *mount;
   size_t size;
-  surf_file_info_t info;
 } s_surf_file_t;
 
 typedef struct surf_storage {
index 9b4e959..3f5610a 100644 (file)
@@ -449,6 +449,19 @@ static size_t ws_file_get_size(void *workstation, surf_file_t fd)
   return fd->size;
 }
 
+static xbt_dynar_t ws_file_get_info(void *workstation, surf_file_t fd)
+{
+  storage_t st = find_storage_on_mount_list(workstation, fd->mount);
+  xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
+  xbt_dynar_push_as(info, void *, &(fd->size));
+  xbt_dynar_push_as(info, void *, fd->mount);
+  xbt_dynar_push_as(info, void *, st->generic_resource.name);
+  xbt_dynar_push_as(info, void *, st->type_id);
+  xbt_dynar_push_as(info, void *, st->content_type);
+
+  return info;
+}
+
 static size_t ws_storage_get_free_size(void *workstation, surf_storage_t storage)
 {
   return storage->size - storage->used_size;
@@ -522,6 +535,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.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_storage_list = ws_get_storage_list;
 }