X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/74d54dcc14450f01fffceeaeb38d1cb961c5d8b0..87116782db3154fb79cd353db446bd226cf15976:/src/msg/msg_io.c diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 2cf7bb5cd4..d762d71a1c 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2014. The SimGrid Team. +/* Copyright (c) 2004-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -18,6 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, * \see #msg_file_t */ + /********************************* 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\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->content_type); + priv->content_type, priv->desc_id); } /** \ingroup msg_file_management @@ -100,7 +102,7 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) /* 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); - msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname); + msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname); read_size = simcall_file_read(file_priv->simdata->smx_file, size, attached_host); if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){ @@ -111,10 +113,10 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) m_host_list[0] = MSG_host_self(); m_host_list[1] = attached_host; - double computation_amount[] = { 0, 0 }; - double communication_amount[] = { 0, 0, (double)read_size, 0 }; + double flops_amount[] = { 0, 0 }; + double bytes_amount[] = { 0, 0, (double)read_size, 0 }; - msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, computation_amount, communication_amount, NULL); + msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount, NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -145,7 +147,7 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) /* 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); + msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname); if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){ /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */ @@ -155,10 +157,10 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) m_host_list[0] = MSG_host_self(); m_host_list[1] = attached_host; - double computation_amount[] = { 0, 0 }; - double communication_amount[] = { 0, (double)size, 0, 0 }; + double flops_amount[] = { 0, 0 }; + double bytes_amount[] = { 0, (double)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_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -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()); - 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); + 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()); - 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; @@ -237,7 +246,7 @@ msg_error_t MSG_file_unlink(msg_file_t fd) (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); + msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname); int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host); return res; } @@ -323,7 +332,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa /* 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); - msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname); + msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname); MSG_file_seek(file, 0, SEEK_SET); read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host); @@ -353,7 +362,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa /* 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 = (char*)storage_dest_priv->hostname; - host_dest = MSG_get_host_by_name(host_name_dest); + host_dest = MSG_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)); @@ -366,10 +375,10 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa 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 }; + double flops_amount[] = { 0, 0 }; + double bytes_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_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -492,6 +501,19 @@ void MSG_storage_set_property_value(msg_storage_t storage, const char *name, cha xbt_dict_set(MSG_storage_get_properties(storage), name, value,free_ctn); } +/** \ingroup m_storage_management + * \brief Returns the value of a given storage property + * + * \param storage a storage + * \param name a property name + * \return value of a property (or NULL if property not set) + */ +const char *MSG_storage_get_property_value(msg_storage_t storage, const char *name) +{ + return xbt_dict_get_or_null(MSG_storage_get_properties(storage), name); +} + + /** \ingroup msg_storage_management * \brief Finds a msg_storage_t using its name. * \param name the name of a storage @@ -535,7 +557,7 @@ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data) return MSG_OK; } -/** \ingroup msg_host_management +/** \ingroup m_host_management * * \brief Returns the user data of a #msg_storage_t. *