From: Martin Quinson Date: Sun, 27 Sep 2015 11:26:59 +0000 (+0200) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3_12~117 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3eff5f3bd55e74ac1831dae9e89c31a32a909819?hp=8695eb4cf63ff136fb246e39305887f3c7c334a8 Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/examples/msg/io/io.tesh b/examples/msg/io/io.tesh index 01b3c6a289..cfe5ef3cb9 100644 --- a/examples/msg/io/io.tesh +++ b/examples/msg/io/io.tesh @@ -12,6 +12,7 @@ $ ${bindir:=.}/io/file ${srcdir:=.}/examples/platforms/storage/storage.xml "--lo > Storage Id: 'Disk4' > Storage Type: 'single_SSD' > Content Type: 'txt_unix' +> File Descriptor Id: 0 > [ 0.000000] (1:0@denise) Open file '/home/doc/simgrid/examples/platforms/g5k.xml' > [ 0.000000] (2:1@alice) Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000 > [ 0.000000] (3:2@carl) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36946053 / 536870912000 diff --git a/examples/msg/io/remote.tesh b/examples/msg/io/remote.tesh index e3ca838fc8..f07cafd1a1 100644 --- a/examples/msg/io/remote.tesh +++ b/examples/msg/io/remote.tesh @@ -14,6 +14,7 @@ $ ${bindir:=.}/io/remote$EXEEXT ${srcdir:=.}/examples/platforms/storage/remote_i > Storage Id: 'Disk2' > Storage Type: 'SATA-II_HDD' > Content Type: 'txt_windows' +> File Descriptor Id: 0 > [ 0.000000] (2@ bob) File Descriptor information: > Full path: '/scratch/lib/libsimgrid.so.3.6.2' > Size: 12710497 @@ -21,6 +22,7 @@ $ ${bindir:=.}/io/remote$EXEEXT ${srcdir:=.}/examples/platforms/storage/remote_i > Storage Id: 'Disk1' > Storage Type: 'SATA-II_HDD' > Content Type: 'txt_unix' +> File Descriptor Id: 0 > [ 0.000000] (3@ carl) File Descriptor information: > Full path: '/scratch/lib/libsimgrid.so.3.6.2' > Size: 12710497 @@ -28,6 +30,7 @@ $ ${bindir:=.}/io/remote$EXEEXT ${srcdir:=.}/examples/platforms/storage/remote_i > Storage Id: 'Disk1' > Storage Type: 'SATA-II_HDD' > Content Type: 'txt_unix' +> File Descriptor Id: 0 > [ 0.000000] (4@ dave) File Descriptor information: > Full path: 'c:\Windows\bootstat.dat' > Size: 67584 @@ -35,6 +38,7 @@ $ ${bindir:=.}/io/remote$EXEEXT ${srcdir:=.}/examples/platforms/storage/remote_i > Storage Id: 'Disk2' > Storage Type: 'SATA-II_HDD' > Content Type: 'txt_windows' +> File Descriptor Id: 0 > [ 0.000000] (1@alice) Try to read 101663 from 'c:\Windows\setupact.log' > [ 0.000000] (2@ bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2' > [ 0.000000] (3@ carl) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2' diff --git a/examples/msg/io/storage.tesh b/examples/msg/io/storage.tesh index 00412a4092..662489eec7 100644 --- a/examples/msg/io/storage.tesh +++ b/examples/msg/io/storage.tesh @@ -18,6 +18,7 @@ $ ${bindir:=.}/io/storage$EXEEXT ${srcdir:=.}/examples/platforms/storage/storage > Storage Id: 'Disk4' > Storage Type: 'single_SSD' > Content Type: 'txt_unix' +> File Descriptor Id: 0 > [ 0.003333] (1:(null)@denise) Free size: 536857490006 bytes > [ 0.003333] (1:(null)@denise) Used size: 13421994 bytes > [ 0.004333] (1:(null)@denise) Read 200000 bytes on /home/tmp/data.txt @@ -29,6 +30,7 @@ $ ${bindir:=.}/io/storage$EXEEXT ${srcdir:=.}/examples/platforms/storage/storage > Storage Id: 'Disk4' > Storage Type: 'single_SSD' > Content Type: 'txt_unix' +> File Descriptor Id: 0 > [ 0.006000] (1:(null)@denise) *** Move '/tmp/data.txt' into '/tmp/simgrid.readme' > [ 0.006000] (1:(null)@denise) User data attached to the file: 777 > [ 0.006000] (1:(null)@denise) *** Get/set data for storage element: Disk4 *** diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index 6296f2b26d..b0f56b5670 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -52,6 +52,7 @@ typedef struct s_msg_host_priv { 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 */ @@ -102,6 +103,7 @@ typedef struct msg_file_priv { 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; diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index 31823c3b25..136a2ec47f 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -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->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; @@ -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_dynar_free(&priv->file_descriptor_table); #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; } + +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); +} diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index ca3ed093b3..d762d71a1c 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -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 @@ -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; diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 3740c6c24a..03d1671651 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -66,6 +66,9 @@ typedef struct simdata_file { 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 */ diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 8fc1edec8b..42fef37138 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -433,7 +433,11 @@ StorageAction *StorageN11::close(surf_file_t fd) StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size) { if(fd->current_position + size > fd->size){ - size = fd->size - fd->current_position; + if (fd->current_position > fd->size){ + size = 0; + } else { + size = fd->size - fd->current_position; + } fd->current_position = fd->size; } else