Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change the way we identify opened files. The same process on the same
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 25 Sep 2015 14:14:32 +0000 (16:14 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 25 Sep 2015 17:21:35 +0000 (19:21 +0200)
machine can open the same file several times (yes, yes, it can), which
wasn't supported correctly.

Now each host has a dynar of 1024 descriptor ids (integers). When
opening a file, a process gets (i.e., pops) an available id for that
host, that it releases (i.e., push back) on close.

MSG_file_dump now shows this id.

include/simgrid/msg.h
src/msg/msg_host.c
src/msg/msg_io.c
src/msg/msg_private.h

index 6296f2b..b0f56b5 100644 (file)
@@ -52,6 +52,7 @@ typedef struct s_msg_host_priv {
   int        is_migrating;
 
   xbt_dict_t affinity_mask_db;
   int        is_migrating;
 
   xbt_dict_t affinity_mask_db;
+  xbt_dynar_t file_descriptor_table;
 
 #ifdef MSG_USE_DEPRECATED
   msg_mailbox_t *mailboxes;     /**< the channels  */
 
 #ifdef MSG_USE_DEPRECATED
   msg_mailbox_t *mailboxes;     /**< the channels  */
@@ -102,6 +103,7 @@ typedef struct msg_file_priv  {
   char* storageId;
   char* storage_type;
   char* content_type;
   char* storageId;
   char* storage_type;
   char* content_type;
+  int desc_id;
   void *data;
   simdata_file_t simdata;
 } s_msg_file_priv_t, *msg_file_priv_t;
   void *data;
   simdata_file_t simdata;
 } s_msg_file_priv_t, *msg_file_priv_t;
index 31823c3..136a2ec 100644 (file)
@@ -54,6 +54,10 @@ msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our paramete
 
   priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);
 
 
   priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);
 
+  priv->file_descriptor_table = xbt_dynar_new(sizeof(int), NULL);
+  for (int i=1023; i>=0;i--)
+    xbt_dynar_push_as(priv->file_descriptor_table, int, i);
+
   sg_host_msg_set(host,priv);
   
   return host;
   sg_host_msg_set(host,priv);
   
   return host;
@@ -153,7 +157,7 @@ void __MSG_host_priv_free(msg_host_priv_t priv)
     XBT_WARN("dp_objs: %u pending task?", size);
   xbt_dict_free(&priv->dp_objs);
   xbt_dict_free(&priv->affinity_mask_db);
     XBT_WARN("dp_objs: %u pending task?", size);
   xbt_dict_free(&priv->dp_objs);
   xbt_dict_free(&priv->affinity_mask_db);
-
+  xbt_dynar_free(&priv->file_descriptor_table);
 #ifdef MSG_USE_DEPRECATED
   free(priv->mailboxes);
 #endif
 #ifdef MSG_USE_DEPRECATED
   free(priv->mailboxes);
 #endif
@@ -475,3 +479,15 @@ xbt_dict_t MSG_host_get_storage_content(msg_host_t host)
   xbt_dict_free(&storage_list);
   return contents;
 }
   xbt_dict_free(&storage_list);
   return contents;
 }
+
+int __MSG_host_get_file_descriptor_id(msg_host_t host){
+  msg_host_priv_t priv = sg_host_msg(host);
+  xbt_assert(!xbt_dynar_is_empty(priv->file_descriptor_table),
+    "Too much files are opened! Some have to be closed.");
+  return xbt_dynar_pop_as(priv->file_descriptor_table, int);
+}
+
+void __MSG_host_release_file_descriptor_id(msg_host_t host, int id){
+  msg_host_priv_t priv = sg_host_msg(host);
+  xbt_dynar_push_as(priv->file_descriptor_table, int, id);
+}
index ca3ed09..d762d71 100644 (file)
@@ -18,6 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg,
  *  \see #msg_file_t
  */
 
  *  \see #msg_file_t
  */
 
+
 /********************************* File **************************************/
 void __MSG_file_get_info(msg_file_t fd){
 
 /********************************* File **************************************/
 void __MSG_file_get_info(msg_file_t fd){
 
@@ -79,10 +80,11 @@ void MSG_file_dump (msg_file_t fd){
            "\t\tMount point: '%s'\n"
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tMount point: '%s'\n"
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
-           "\t\tContent Type: '%s'",
+           "\t\tContent Type: '%s'\n"
+           "\t\tFile Descriptor Id: %d",
            priv->fullpath, priv->size, priv->mount_point,
            priv->storageId, priv->storage_type,
            priv->fullpath, priv->size, priv->mount_point,
            priv->storageId, priv->storage_type,
-           priv->content_type);
+           priv->content_type, priv->desc_id);
 }
 
 /** \ingroup msg_file_management
 }
 
 /** \ingroup msg_file_management
@@ -195,11 +197,16 @@ msg_file_t MSG_file_open(const char* fullpath, void* data)
   priv->fullpath = xbt_strdup(fullpath);
   priv->simdata = xbt_new0(s_simdata_file_t,1);
   priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
   priv->fullpath = xbt_strdup(fullpath);
   priv->simdata = xbt_new0(s_simdata_file_t,1);
   priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
-  name = bprintf("%s:%i:%s",MSG_host_get_name(MSG_host_self()),MSG_process_self_PID(),fullpath);
+  priv->desc_id = __MSG_host_get_file_descriptor_id(MSG_host_self());
+
+  name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()),
+                             priv->desc_id);
+
   xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
   msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, name);
   __MSG_file_get_info(fd);
   xbt_free(name);
   xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
   msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, name);
   __MSG_file_get_info(fd);
   xbt_free(name);
+
   return fd;
 }
 
   return fd;
 }
 
@@ -217,7 +224,9 @@ int MSG_file_close(msg_file_t fd)
     xbt_free(priv->data);
 
   int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self());
     xbt_free(priv->data);
 
   int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self());
-  name = bprintf("%s:%i:%s",MSG_host_get_name(MSG_host_self()),MSG_process_self_PID(),priv->fullpath);
+  name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()),
+                             priv->desc_id);
+  __MSG_host_release_file_descriptor_id(MSG_host_self(), priv->desc_id);
   xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
   xbt_free(name);
   return res;
   xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
   xbt_free(name);
   return res;
index 3740c6c..03d1671 100644 (file)
@@ -66,6 +66,9 @@ typedef struct simdata_file {
   smx_file_t smx_file;
 } s_simdata_file_t;
 
   smx_file_t smx_file;
 } s_simdata_file_t;
 
+int __MSG_host_get_file_descriptor_id(msg_host_t host);
+void __MSG_host_release_file_descriptor_id(msg_host_t host, int id);
+
 /*************** Begin GPU ***************/
 typedef struct simdata_gpu_task {
   double flops_amount;    /* Computation size */
 /*************** Begin GPU ***************/
 typedef struct simdata_gpu_task {
   double flops_amount;    /* Computation size */