Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
unlink can be a remote operation too.
authorsuter <frederic.suter@cc.in2p3.fr>
Tue, 27 May 2014 14:43:41 +0000 (16:43 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Tue, 27 May 2014 15:06:25 +0000 (17:06 +0200)
include/simgrid/simix.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

index 95ee207..303f494 100644 (file)
@@ -501,7 +501,7 @@ XBT_PUBLIC(sg_size_t) simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_
 XBT_PUBLIC(sg_size_t) simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host);
 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* fullpath, smx_host_t host);
 XBT_PUBLIC(int) simcall_file_close(smx_file_t fd, smx_host_t host);
-XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
+XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd, smx_host_t host);
 XBT_PUBLIC(sg_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(sg_size_t) simcall_file_tell(smx_file_t fd);
index 898604d..8bb0ba4 100644 (file)
@@ -236,8 +236,14 @@ int MSG_file_close(msg_file_t fd)
  */
 msg_error_t MSG_file_unlink(msg_file_t fd)
 {
-  msg_file_priv_t priv = MSG_file_priv(fd);
-  int res = simcall_file_unlink(priv->simdata->smx_file);
+  msg_file_priv_t file_priv = MSG_file_priv(fd);
+  /* Find the host where the file is physically located (remote or local)*/
+  msg_storage_t storage_src =
+      (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib,
+                                              file_priv->storageId);
+  msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
+  msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname);
+  int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host);
   return res;
 }
 
@@ -346,6 +352,8 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
     }
     free(file_mount_name);
   }
+  xbt_dict_free(&storage_list);
+
   if(longest_prefix_length>0){
     /* Mount point found, retrieve the host the storage is attached to */
     msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
index b415e14..e9759eb 100644 (file)
@@ -113,7 +113,7 @@ file_read False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, voi
 file_write False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, void*, smx_host_t)
 file_open False (void*, smx_file_t) (fullpath, const char*) (host, void*, smx_host_t)
 file_close False (int) (fd, void*, smx_file_t) (host, void*, smx_host_t)
-file_unlink True (int) (fd, void*, smx_file_t)
+file_unlink True (int) (fd, void*, smx_file_t) (host, void*, smx_host_t)
 file_get_size True (sg_size_t) (fd, void*, smx_file_t)
 file_tell True (sg_size_t) (fd, void*, smx_file_t)
 file_seek True (int) (fd, void*, smx_file_t) (offset, sg_offset_t) (origin, int)
index 3d70165..81a38ee 100644 (file)
@@ -1154,6 +1154,12 @@ static inline smx_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall){
 static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, void* arg){
     simcall->args[0].dp = arg;
 }
+static inline smx_host_t simcall_file_unlink__get__host(smx_simcall_t simcall){
+  return (smx_host_t) simcall->args[1].dp;
+}
+static inline void simcall_file_unlink__set__host(smx_simcall_t simcall, void* arg){
+    simcall->args[1].dp = arg;
+}
 static inline smx_file_t simcall_file_get_size__get__fd(smx_simcall_t simcall){
   return (smx_file_t) simcall->args[0].dp;
 }
index f2652ad..1087205 100644 (file)
     }    
     return self->simcall.result.i;
   }
-  inline static int simcall_BODY_file_unlink(smx_file_t fd) {
+  inline static int simcall_BODY_file_unlink(smx_file_t fd, smx_host_t host) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_FILE_UNLINK;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
     self->simcall.args[0].dp = (void*) fd;
+    self->simcall.args[1].dp = (void*) host;
     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 d93566e..3933834 100644 (file)
@@ -522,7 +522,7 @@ case SIMCALL_FILE_CLOSE:
        break;  
 
 case SIMCALL_FILE_UNLINK:
-      simcall->result.i = SIMIX_pre_file_unlink(simcall , (smx_file_t) simcall->args[0].dp);
+      simcall->result.i = SIMIX_pre_file_unlink(simcall , (smx_file_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp);
       SIMIX_simcall_answer(simcall);
       break;  
 
index c00ac6f..3200ad1 100644 (file)
@@ -187,14 +187,13 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd, smx_host_t h
 
 
 //SIMIX FILE UNLINK
-int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd)
+int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd, smx_host_t host)
 {
-  return SIMIX_file_unlink(simcall->issuer, fd);
+  return SIMIX_file_unlink(simcall->issuer, fd, host);
 }
 
-int SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
+int SIMIX_file_unlink(smx_process_t process, smx_file_t fd, smx_host_t host)
 {
-  smx_host_t host = process->smx_host;
   /* check if the host is active */
   if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
index 325a09a..9750c40 100644 (file)
@@ -26,7 +26,7 @@ void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, s
 void SIMIX_pre_file_write(smx_simcall_t simcall,smx_file_t fd, sg_size_t size, smx_host_t host);
 void SIMIX_pre_file_open(smx_simcall_t simcall, const char* fullpath, smx_host_t host);
 void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd, smx_host_t host);
-int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
+int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd, smx_host_t host);
 sg_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
 sg_size_t SIMIX_pre_file_tell(smx_simcall_t simcall, smx_file_t fd);
 xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd);
@@ -36,7 +36,7 @@ smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t siz
 smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host);
 smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath, smx_host_t host);
 smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd, smx_host_t host);
-int SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
+int SIMIX_file_unlink(smx_process_t process, smx_file_t fd, smx_host_t host);
 sg_size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
 sg_size_t SIMIX_file_tell(smx_process_t process, smx_file_t fd);
 xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd);
index 6924126..ef88967 100644 (file)
@@ -1354,7 +1354,7 @@ smx_file_t simcall_file_open(const char* fullpath, smx_host_t host)
  * \ingroup simix_file_management
  *
  */
-int simcall_file_close(smx_file_t fd,  smx_host_t host)
+int simcall_file_close(smx_file_t fd, smx_host_t host)
 {
   return simcall_BODY_file_close(fd, host);
 }
@@ -1363,9 +1363,9 @@ int simcall_file_close(smx_file_t fd,  smx_host_t host)
  * \ingroup simix_file_management
  *
  */
-int simcall_file_unlink(smx_file_t fd)
+int simcall_file_unlink(smx_file_t fd, smx_host_t host)
 {
-  return simcall_BODY_file_unlink(fd);
+  return simcall_BODY_file_unlink(fd, host);
 }
 
 /**