From 8182da70a35e7ebdae9c48c02cedeec4e95635a9 Mon Sep 17 00:00:00 2001 From: suter Date: Tue, 27 May 2014 16:43:41 +0200 Subject: [PATCH] unlink can be a remote operation too. --- include/simgrid/simix.h | 2 +- src/msg/msg_io.c | 12 ++++++++++-- src/simix/simcalls.in | 2 +- src/simix/simcalls_generated_args_getter_setter.h | 6 ++++++ src/simix/simcalls_generated_body.c | 3 ++- src/simix/simcalls_generated_case.c | 2 +- src/simix/smx_io.c | 7 +++---- src/simix/smx_io_private.h | 4 ++-- src/simix/smx_user.c | 6 +++--- 9 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 95ee207081..303f49499c 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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); diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 898604db09..8bb0ba4b9f 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -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); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index b415e1413e..e9759eb246 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -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) diff --git a/src/simix/simcalls_generated_args_getter_setter.h b/src/simix/simcalls_generated_args_getter_setter.h index 3d7016512a..81a38eed70 100644 --- a/src/simix/simcalls_generated_args_getter_setter.h +++ b/src/simix/simcalls_generated_args_getter_setter.h @@ -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; } diff --git a/src/simix/simcalls_generated_body.c b/src/simix/simcalls_generated_body.c index f2652ad860..1087205862 100644 --- a/src/simix/simcalls_generated_body.c +++ b/src/simix/simcalls_generated_body.c @@ -1696,12 +1696,13 @@ } 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); diff --git a/src/simix/simcalls_generated_case.c b/src/simix/simcalls_generated_case.c index d93566e7a7..39338341f4 100644 --- a/src/simix/simcalls_generated_case.c +++ b/src/simix/simcalls_generated_case.c @@ -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; diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index c00ac6fd78..3200ad1352 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -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", diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index 325a09ab4c..9750c403a3 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -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); diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 6924126788..ef889679ff 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -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); } /** -- 2.20.1