From: Pierre Veyre Date: Tue, 1 Apr 2014 12:52:35 +0000 (+0200) Subject: Fix MSG_file_rcopy() and MSG_file_rmove() X-Git-Tag: v3_11~177 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/26f60d943e887977ea88e6ef97d7c1dd47acda1c Fix MSG_file_rcopy() and MSG_file_rmove() --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index c5f8f4cdaa..6299fd91fc 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -490,15 +490,14 @@ XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd); XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data); XBT_PUBLIC(sg_size_t) simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_t 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); -XBT_PUBLIC(int) simcall_file_close(smx_file_t fd); +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(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); XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_size_t offset, int origin); XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath); -XBT_PUBLIC(int) simcall_file_rcopy(smx_file_t fd, smx_host_t host, const char* fullpath); /***************************** Storage **********************************/ XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (const char* name); XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (const char* name); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index fdcbf87b6c..51708d0007 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -710,19 +710,6 @@ XBT_PUBLIC(int) surf_workstation_file_move(surf_resource_t workstation, surf_fil */ XBT_PUBLIC(int) surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, sg_size_t offset, int origin); -/** - * @brief Copy a file to another location on a remote host. - * @details [long description] - * - * @param workstation The surf workstation - * @param fd The file descriptor - * @param host_dest The workstation destination - * @param fullpath The new full path - * - * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED - */ -XBT_PUBLIC(int) surf_workstation_file_rcopy(surf_resource_t workstation, surf_file_t fd, surf_resource_t host_dest, const char* fullpath); - /** * @brief [brief description] * @details [long description] diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 86c58c99cb..3b77073b5d 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -191,7 +191,7 @@ msg_file_t MSG_file_open(const char* fullpath, void* data) priv->data = data; priv->fullpath = xbt_strdup(fullpath); priv->simdata = xbt_new0(s_simdata_file_t,1); - priv->simdata->smx_file = simcall_file_open(fullpath); + priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self()); xbt_lib_set(file_lib, fullpath, MSG_FILE_LEVEL, priv); msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, fullpath); __MSG_file_get_info(fd); @@ -217,7 +217,7 @@ void __MSG_file_priv_free(msg_file_priv_t priv) int MSG_file_close(msg_file_t fd) { msg_file_priv_t priv = MSG_file_priv(fd); - int res = simcall_file_close(priv->simdata->smx_file); + int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self()); xbt_lib_unset(file_lib, priv->fullpath, MSG_FILE_LEVEL, 1); return res; } @@ -311,18 +311,19 @@ msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath) msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath) { msg_file_priv_t file_priv = MSG_file_priv(file); + sg_size_t read_size; - /* Find the host source where the file is physically located */ + /* Find the host where the file is physically located and read it */ 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); - const char *host_name_src, *host_name_dest; - host_name_src = storage_priv_src->hostname; + msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname); + read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host); /* Find the real host destination where the file will be physically stored */ xbt_dict_cursor_t cursor = NULL; - char *mount_name, *storage_name, *file_mount_name; + char *mount_name, *storage_name, *file_mount_name, *host_name_dest; msg_storage_t storage_dest; + msg_host_t host_dest; size_t longest_prefix_length = 0; xbt_dict_t storage_list = simcall_host_get_mounted_storage_list(host); @@ -341,42 +342,42 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa 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); - host_name_dest = storage_dest_priv->hostname; + host_name_dest = (char*)storage_dest_priv->hostname; + host_dest = MSG_get_host_by_name(host_name_dest); }else{ XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, SIMIX_host_get_name(host)); return MSG_TASK_CANCELED; } - XBT_INFO("HOST SRC %s HOST DEST %s", host_name_src, host_name_dest); - /* Try to send file calling SIMIX network layer */ + XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname, host_name_dest); + msg_host_t *m_host_list = NULL; + m_host_list = calloc(2, sizeof(msg_host_t)); + + m_host_list[0] = attached_host; + m_host_list[1] = host_dest; + double computation_amount[] = { 0, 0 }; + double communication_amount[] = { 0, (double)read_size, 0, 0 }; + + msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, computation_amount, communication_amount, NULL); + msg_error_t transfer = MSG_parallel_task_execute(task); + MSG_task_destroy(task); + free(m_host_list); + if(transfer != MSG_OK){ + if (transfer == MSG_HOST_FAILURE) + XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest); + if (transfer == MSG_TASK_CANCELED) + XBT_WARN("Transfer error, task has been canceled!"); + + return -1; + } - size_t file_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, MSG_get_host_by_name(host_name_src)); - xbt_ex_t e; - msg_error_t ret = MSG_OK; + /* Create file on remote host, write it and close it */ + smx_file_t smx_file = simcall_file_open(fullpath, host_dest); + simcall_file_write(smx_file, read_size, host_dest); + simcall_file_close(smx_file, host_dest); + return MSG_OK; - TRY { - msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(host_name_dest); - simcall_comm_isend(mailbox, (double) file_size, -1.0, file, sizeof(void *), NULL, NULL, (void*)file, 0); - simcall_comm_irecv(mailbox, file, NULL, NULL, NULL, -1.0); - } - CATCH(e) { - switch (e.category) { - case cancel_error: - ret = MSG_HOST_FAILURE; - break; - case network_error: - ret = MSG_TRANSFER_FAILURE; - break; - case timeout_error: - ret = MSG_TIMEOUT; - break; - default: - RETHROW; - } - xbt_ex_free(e); - } - return ret; } /** @@ -390,9 +391,8 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa */ msg_error_t MSG_file_rmove (msg_file_t file, msg_host_t host, const char* fullpath) { - msg_file_priv_t file_priv = MSG_file_priv(file); - msg_error_t res = simcall_file_rcopy(file_priv->simdata->smx_file, host, fullpath); - simcall_file_unlink(file_priv->simdata->smx_file); + msg_error_t res = MSG_file_rcopy(file, host, fullpath); + MSG_file_unlink(file); return res; } diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index a2737cf64f..e28d7ccb4d 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -110,15 +110,14 @@ sem_acquire_timeout False (void) (sem, void*, smx_sem_t) (timeout, double) sem_get_capacity True (int) (sem, void*, smx_sem_t) file_read False (sg_size_t) (fd, void*, smx_file_t) (size, sg_size_t) (host, void*, smx_host_t) 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*) -file_close False (int) (fd, void*, smx_file_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_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_size_t) (origin, int) file_get_info True (void*, xbt_dynar_t) (fd, void*, smx_file_t) file_move True (int) (fd, void*, smx_file_t) (fullpath, const char*) -file_rcopy True (int) (fd, void*, smx_file_t) (host, void*, smx_host_t) (fullpath, const char*) storage_get_free_size True (sg_size_t) (name, const char*) storage_get_used_size True (sg_size_t) (name, const char*) storage_get_properties True (void*, xbt_dict_t) (storage, void*, smx_storage_t) diff --git a/src/simix/simcalls_generated_args_getter_setter.h b/src/simix/simcalls_generated_args_getter_setter.h index b741de798f..2cd2752f51 100644 --- a/src/simix/simcalls_generated_args_getter_setter.h +++ b/src/simix/simcalls_generated_args_getter_setter.h @@ -1094,12 +1094,24 @@ static inline const char* simcall_file_open__get__fullpath(smx_simcall_t simcall static inline void simcall_file_open__set__fullpath(smx_simcall_t simcall, const char* arg){ simcall->args[0].cc = arg; } +static inline smx_host_t simcall_file_open__get__host(smx_simcall_t simcall){ + return (smx_host_t) simcall->args[1].dp; +} +static inline void simcall_file_open__set__host(smx_simcall_t simcall, void* arg){ + simcall->args[1].dp = arg; +} static inline smx_file_t simcall_file_close__get__fd(smx_simcall_t simcall){ return (smx_file_t) simcall->args[0].dp; } static inline void simcall_file_close__set__fd(smx_simcall_t simcall, void* arg){ simcall->args[0].dp = arg; } +static inline smx_host_t simcall_file_close__get__host(smx_simcall_t simcall){ + return (smx_host_t) simcall->args[1].dp; +} +static inline void simcall_file_close__set__host(smx_simcall_t simcall, void* arg){ + simcall->args[1].dp = arg; +} static inline smx_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall){ return (smx_file_t) simcall->args[0].dp; } @@ -1154,24 +1166,6 @@ static inline const char* simcall_file_move__get__fullpath(smx_simcall_t simcall static inline void simcall_file_move__set__fullpath(smx_simcall_t simcall, const char* arg){ simcall->args[1].cc = arg; } -static inline smx_file_t simcall_file_rcopy__get__fd(smx_simcall_t simcall){ - return (smx_file_t) simcall->args[0].dp; -} -static inline void simcall_file_rcopy__set__fd(smx_simcall_t simcall, void* arg){ - simcall->args[0].dp = arg; -} -static inline smx_host_t simcall_file_rcopy__get__host(smx_simcall_t simcall){ - return (smx_host_t) simcall->args[1].dp; -} -static inline void simcall_file_rcopy__set__host(smx_simcall_t simcall, void* arg){ - simcall->args[1].dp = arg; -} -static inline const char* simcall_file_rcopy__get__fullpath(smx_simcall_t simcall){ - return simcall->args[2].cc; -} -static inline void simcall_file_rcopy__set__fullpath(smx_simcall_t simcall, const char* arg){ - simcall->args[2].cc = arg; -} static inline const char* simcall_storage_get_free_size__get__name(smx_simcall_t simcall){ return simcall->args[0].cc; } diff --git a/src/simix/simcalls_generated_body.c b/src/simix/simcalls_generated_body.c index 82201b6d99..c6e1f254ae 100644 --- a/src/simix/simcalls_generated_body.c +++ b/src/simix/simcalls_generated_body.c @@ -1644,12 +1644,13 @@ } return self->simcall.result.sgsz; } - inline static smx_file_t simcall_BODY_file_open(const char* fullpath) { + inline static smx_file_t simcall_BODY_file_open(const char* fullpath, smx_host_t host) { smx_process_t self = SIMIX_process_self(); self->simcall.call = SIMCALL_FILE_OPEN; memset(&self->simcall.result, 0, sizeof(self->simcall.result)); memset(self->simcall.args, 0, sizeof(self->simcall.args)); self->simcall.args[0].cc = (const char*) fullpath; + 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); @@ -1659,12 +1660,13 @@ } return self->simcall.result.dp; } - inline static int simcall_BODY_file_close(smx_file_t fd) { + inline static int simcall_BODY_file_close(smx_file_t fd, smx_host_t host) { smx_process_t self = SIMIX_process_self(); self->simcall.call = SIMCALL_FILE_CLOSE; 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); @@ -1767,23 +1769,6 @@ } return self->simcall.result.i; } - inline static int simcall_BODY_file_rcopy(smx_file_t fd, smx_host_t host, const char* fullpath) { - smx_process_t self = SIMIX_process_self(); - self->simcall.call = SIMCALL_FILE_RCOPY; - 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; - self->simcall.args[2].cc = (const char*) fullpath; - 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); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_pre(&self->simcall, 0); - } - return self->simcall.result.i; - } inline static sg_size_t simcall_BODY_storage_get_free_size(const char* name) { smx_process_t self = SIMIX_process_self(); self->simcall.call = SIMCALL_STORAGE_GET_FREE_SIZE; diff --git a/src/simix/simcalls_generated_case.c b/src/simix/simcalls_generated_case.c index 61fb5998a7..45ef5a2ae2 100644 --- a/src/simix/simcalls_generated_case.c +++ b/src/simix/simcalls_generated_case.c @@ -510,11 +510,11 @@ case SIMCALL_FILE_WRITE: break; case SIMCALL_FILE_OPEN: - SIMIX_pre_file_open(simcall , simcall->args[0].cc); + SIMIX_pre_file_open(simcall , simcall->args[0].cc, (smx_host_t) simcall->args[1].dp); break; case SIMCALL_FILE_CLOSE: - SIMIX_pre_file_close(simcall , (smx_file_t) simcall->args[0].dp); + SIMIX_pre_file_close(simcall , (smx_file_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp); break; case SIMCALL_FILE_UNLINK: @@ -547,11 +547,6 @@ case SIMCALL_FILE_MOVE: SIMIX_simcall_answer(simcall); break; -case SIMCALL_FILE_RCOPY: - simcall->result.i = SIMIX_pre_file_rcopy(simcall , (smx_file_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp, simcall->args[2].cc); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_STORAGE_GET_FREE_SIZE: simcall->result.sgsz = SIMIX_pre_storage_get_free_size(simcall , simcall->args[0].cc); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls_generated_enum.h b/src/simix/simcalls_generated_enum.h index 96678904e3..5337849bf0 100644 --- a/src/simix/simcalls_generated_enum.h +++ b/src/simix/simcalls_generated_enum.h @@ -117,7 +117,6 @@ SIMCALL_FILE_TELL, SIMCALL_FILE_SEEK, SIMCALL_FILE_GET_INFO, SIMCALL_FILE_MOVE, -SIMCALL_FILE_RCOPY, SIMCALL_STORAGE_GET_FREE_SIZE, SIMCALL_STORAGE_GET_USED_SIZE, SIMCALL_STORAGE_GET_PROPERTIES, diff --git a/src/simix/simcalls_generated_res_getter_setter.h b/src/simix/simcalls_generated_res_getter_setter.h index a20e7ad9a9..defe198cb9 100644 --- a/src/simix/simcalls_generated_res_getter_setter.h +++ b/src/simix/simcalls_generated_res_getter_setter.h @@ -485,12 +485,6 @@ static inline int simcall_file_move__get__result(smx_simcall_t simcall){ static inline void simcall_file_move__set__result(smx_simcall_t simcall, int result){ simcall->result.i = result; } -static inline int simcall_file_rcopy__get__result(smx_simcall_t simcall){ - return simcall->result.i; -} -static inline void simcall_file_rcopy__set__result(smx_simcall_t simcall, int result){ - simcall->result.i = result; -} static inline sg_size_t simcall_storage_get_free_size__get__result(smx_simcall_t simcall){ return simcall->result.sgsz; } diff --git a/src/simix/simcalls_generated_string.c b/src/simix/simcalls_generated_string.c index c75900e350..d409da2de8 100644 --- a/src/simix/simcalls_generated_string.c +++ b/src/simix/simcalls_generated_string.c @@ -117,7 +117,6 @@ [SIMCALL_FILE_SEEK] = "SIMCALL_FILE_SEEK", [SIMCALL_FILE_GET_INFO] = "SIMCALL_FILE_GET_INFO", [SIMCALL_FILE_MOVE] = "SIMCALL_FILE_MOVE", -[SIMCALL_FILE_RCOPY] = "SIMCALL_FILE_RCOPY", [SIMCALL_STORAGE_GET_FREE_SIZE] = "SIMCALL_STORAGE_GET_FREE_SIZE", [SIMCALL_STORAGE_GET_USED_SIZE] = "SIMCALL_STORAGE_GET_USED_SIZE", [SIMCALL_STORAGE_GET_PROPERTIES] = "SIMCALL_STORAGE_GET_PROPERTIES", diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index 8abeb2b721..10b39e9207 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -118,17 +118,16 @@ smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t si } //SIMIX FILE OPEN -void SIMIX_pre_file_open(smx_simcall_t simcall, const char* fullpath) +void SIMIX_pre_file_open(smx_simcall_t simcall, const char* fullpath, smx_host_t host) { - smx_action_t action = SIMIX_file_open(simcall->issuer, fullpath); + smx_action_t action = SIMIX_file_open(simcall->issuer, fullpath, host); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath) +smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath, smx_host_t host) { smx_action_t action; - 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) { @@ -153,17 +152,16 @@ smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath) } //SIMIX FILE CLOSE -void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd) +void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd, smx_host_t host) { - smx_action_t action = SIMIX_file_close(simcall->issuer, fd); + smx_action_t action = SIMIX_file_close(simcall->issuer, fd, host); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd) +smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd, smx_host_t host) { smx_action_t action; - 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) { @@ -266,17 +264,6 @@ int SIMIX_file_move(smx_process_t process, smx_file_t file, const char* fullpath return surf_workstation_file_move(host, file->surf_file, fullpath); } -int SIMIX_pre_file_rcopy(smx_simcall_t simcall, smx_file_t fd, smx_host_t host, const char* fullpath) -{ - return SIMIX_file_rcopy(simcall->issuer, fd, host, fullpath); -} - -int SIMIX_file_rcopy(smx_process_t process, smx_file_t file, smx_host_t host_dest, const char* fullpath) -{ - smx_host_t host = process->smx_host; - return surf_workstation_file_rcopy(host, file->surf_file, host_dest, fullpath); -} - sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name) { return SIMIX_storage_get_free_size(simcall->issuer, name); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index 831d4a1efc..82f14f050d 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -24,26 +24,24 @@ smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data); void SIMIX_storage_destroy(void *s); void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, smx_host_t host); 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); -void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd); +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); 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); int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_size_t offset, int origin); int SIMIX_pre_file_move(smx_simcall_t simcall, smx_file_t fd, const char* fullpath); -int SIMIX_pre_file_rcopy(smx_simcall_t simcall, smx_file_t fd, smx_host_t dest, const char* fullpath); smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host); 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_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd); +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); 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); int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int origin); int SIMIX_file_move(smx_process_t process, smx_file_t fd, const char* fullpath); -int SIMIX_file_rcopy(smx_process_t process, smx_file_t fd, smx_host_t dest, const char* fullpath); sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name); sg_size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name); diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 6eb533891f..42487416a3 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1336,18 +1336,18 @@ sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host) * \ingroup simix_file_management * \brief */ -smx_file_t simcall_file_open(const char* fullpath) +smx_file_t simcall_file_open(const char* fullpath, smx_host_t host) { - return simcall_BODY_file_open(fullpath); + return simcall_BODY_file_open(fullpath, host); } /** * \ingroup simix_file_management * */ -int simcall_file_close(smx_file_t fd) +int simcall_file_close(smx_file_t fd, smx_host_t host) { - return simcall_BODY_file_close(fd); + return simcall_BODY_file_close(fd, host); } /** @@ -1402,16 +1402,6 @@ int simcall_file_move(smx_file_t fd, const char* fullpath) return simcall_BODY_file_move(fd, fullpath); } -/** - * \ingroup simix_file_management - * \brief Copy a file to another location on a remote host. - * - */ -int simcall_file_rcopy(smx_file_t fd, smx_host_t host, const char* fullpath) -{ - return simcall_BODY_file_rcopy(fd, host, fullpath); -} - /** * \ingroup simix_storage_management * \brief Returns the free space size on a given storage element. diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 8a0fea3c35..0cefa0cb30 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -408,10 +408,6 @@ int surf_workstation_file_move(surf_resource_t workstation, surf_file_t fd, cons return get_casted_workstation(workstation)->fileMove(fd, fullpath); } -int surf_workstation_file_rcopy(surf_resource_t workstation, surf_file_t fd, surf_resource_t host_dest, const char* fullpath){ - return get_casted_workstation(workstation)->fileRcopy(fd, host_dest, fullpath); -} - xbt_dynar_t surf_workstation_get_vms(surf_resource_t resource){ return get_casted_workstation(resource)->getVms(); } diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index 5f44530010..ba19f668d3 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -364,99 +364,6 @@ int Workstation::fileMove(surf_file_t fd, const char* fullpath){ } } -int Workstation::fileRcopy(surf_file_t fd, surf_resource_t host_dest, const char* fullpath){ - - XBT_DEBUG("Rcopy file %s on %s to %s",fd->name, host_dest->key, fullpath); - - /* Find the host src where the file is located */ - StoragePtr storage = findStorageOnMountList(fd->mount); - const char* host_name_src = (const char*)storage->p_attach; - - /* Find the real host dest where the file will be stored */ - s_mount_t mnt; - unsigned int cursor; - StoragePtr storage_dest = NULL; - const char* host_name_dest; - char *file_mount_name; - size_t longest_prefix_length = 0; - WorkstationPtr dest_ws, src_ws; - - dest_ws = static_cast(surf_workstation_resource_priv(host_dest)); - - xbt_dynar_foreach(dest_ws->p_storage,cursor,mnt) - { - file_mount_name = (char *) xbt_malloc ((strlen(mnt.name)+1)); - strncpy(file_mount_name,fullpath,strlen(mnt.name)+1); - file_mount_name[strlen(mnt.name)] = '\0'; - - if(!strcmp(file_mount_name,mnt.name) && strlen(mnt.name)>longest_prefix_length) - {/* The current mount name is found in the full path and is bigger than the previous*/ - longest_prefix_length = strlen(mnt.name); - storage_dest = static_cast(mnt.storage); - } - free(file_mount_name); - } - if(longest_prefix_length>0) - { /* Mount point found, retrieve the host the storage is attached to */ - host_name_dest = storage_dest->p_attach; - } - else - { - XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host_dest->key); - return MSG_TASK_CANCELED; - } - - /* Check that there is a route between src and dest workstations */ - xbt_dynar_t route = NULL; - dest_ws = static_cast(surf_workstation_resource_priv(xbt_lib_get_elm_or_null(host_lib, host_name_dest))); - src_ws = static_cast(surf_workstation_resource_priv(xbt_lib_get_elm_or_null(host_lib, host_name_src))); - - routing_get_route_and_latency(src_ws->p_netElm, dest_ws->p_netElm, &route, NULL); - if(!xbt_dynar_length (route)) - { - XBT_WARN("There is no route between %s and %s. Action has been canceled", src_ws->getName(), dest_ws->getName()); - return MSG_TASK_CANCELED; - } - else - {/* There is a route between src and dest, let's copy the file */ - - /* Read the file on the src side */ - src_ws->read(fd, fd->size); - - /* Send a message from src to dest to simulate data transfer */ - surf_network_model->communicate(src_ws->p_netElm, dest_ws->p_netElm, fd->size, .0); - - /* Create the file on the dest side and write data into it*/ - char *mount_name, *path; - path = (char *) xbt_malloc ((strlen(fullpath)-longest_prefix_length+1)); - mount_name = (char *) xbt_malloc ((longest_prefix_length+1)); - - /* deduce mount_name and path from fullpath */ - strncpy(mount_name, fullpath, longest_prefix_length+1); - strncpy(path, fullpath+longest_prefix_length, strlen(fullpath)-longest_prefix_length+1); - path[strlen(fullpath)-longest_prefix_length] = '\0'; - mount_name[longest_prefix_length] = '\0'; - - /* create the file */ - StorageActionPtr open_action = storage_dest->open((const char*)mount_name, (const char*)path); - - surf_file_t surf_file = xbt_new(s_surf_file_t, 1); - surf_file->current_position = 0; - surf_file->mount = mount_name; - surf_file->name = strdup(path); - surf_file->size = 0; - - /* write data and close file*/ - storage_dest->write(surf_file, fd->size); - storage_dest->close(open_action->p_file); - - free(path); - free(mount_name); - XBT_DEBUG("File %s has been copied on %s to %s",fd->name, host_dest->key, fullpath); - return MSG_OK; - } -} - sg_size_t Workstation::getFreeSize(const char* name) { StoragePtr st = findStorageOnMountList(name); diff --git a/src/surf/workstation_interface.hpp b/src/surf/workstation_interface.hpp index da9e455ad6..1be3e4af69 100644 --- a/src/surf/workstation_interface.hpp +++ b/src/surf/workstation_interface.hpp @@ -370,17 +370,6 @@ public: */ virtual int fileMove(surf_file_t fd, const char* fullpath); - /** - * @brief Copy a file to another location on a remote host. - * @details [long description] - * - * @param fd The file descriptor - * @param host_dest The worstation destination - * @param fullpath The new full path - * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED - */ - virtual int fileRcopy(surf_file_t fd, surf_resource_t host_dest, const char* fullpath); - xbt_dynar_t p_storage; RoutingEdgePtr p_netElm; CpuPtr p_cpu;