Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
put MsgActorExt in a namespace
[simgrid.git] / src / msg / msg_io.cpp
1 /* Copyright (c) 2004-2016. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u/host.hpp"
7 #include "src/msg/msg_private.h"
8 #include <numeric>
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, "Logging specific to MSG (io)");
11
12 /** @addtogroup msg_file
13  * (#msg_file_t) and the functions for managing it.
14  *
15  *  \see #msg_file_t
16  */
17
18 /********************************* File **************************************/
19 void __MSG_file_get_info(msg_file_t fd){
20
21   msg_file_priv_t priv = MSG_file_priv(fd);
22   xbt_dynar_t info = simcall_file_get_info(priv->simdata->smx_file);
23   sg_size_t *psize;
24
25   priv->content_type = xbt_dynar_pop_as(info, char *);
26   priv->storage_type = xbt_dynar_pop_as(info, char *);
27   priv->storageId = xbt_dynar_pop_as(info, char *);
28   priv->mount_point = xbt_dynar_pop_as(info, char *);
29   psize = xbt_dynar_pop_as(info, sg_size_t*);
30   priv->size = *psize;
31   xbt_free(psize);
32   xbt_dynar_free_container(&info);
33 }
34
35 static int MSG_host_get_file_descriptor_id(msg_host_t host)
36 {
37   simgrid::MsgHostExt* priv = host->extension<simgrid::MsgHostExt>();
38   if (priv->file_descriptor_table == nullptr) {
39     priv->file_descriptor_table = new std::vector<int>(sg_storage_max_file_descriptors);
40     std::iota(priv->file_descriptor_table->rbegin(), priv->file_descriptor_table->rend(), 0); // Fill with ..., 1, 0.
41   }
42   xbt_assert(!priv->file_descriptor_table->empty(), "Too much files are opened! Some have to be closed.");
43   int desc = priv->file_descriptor_table->back();
44   priv->file_descriptor_table->pop_back();
45   return desc;
46 }
47
48 static void MSG_host_release_file_descriptor_id(msg_host_t host, int id)
49 {
50   host->extension<simgrid::MsgHostExt>()->file_descriptor_table->push_back(id);
51 }
52
53 /** \ingroup msg_file
54  *
55  * \brief Set the user data of a #msg_file_t.
56  *
57  * This functions attach \a data to \a file.
58  */
59 msg_error_t MSG_file_set_data(msg_file_t fd, void *data)
60 {
61   msg_file_priv_t priv = MSG_file_priv(fd);
62   priv->data = data;
63   return MSG_OK;
64 }
65
66 /** \ingroup msg_file
67  *
68  * \brief Return the user data of a #msg_file_t.
69  *
70  * This functions checks whether \a file is a valid pointer and return the user data associated to \a file if possible.
71  */
72 void *MSG_file_get_data(msg_file_t fd)
73 {
74   msg_file_priv_t priv = MSG_file_priv(fd);
75   return priv->data;
76 }
77
78 /** \ingroup msg_file
79  * \brief Display information related to a file descriptor
80  *
81  * \param fd is a the file descriptor
82  */
83 void MSG_file_dump (msg_file_t fd){
84   /* Update the cached information first */
85   __MSG_file_get_info(fd);
86
87   msg_file_priv_t priv = MSG_file_priv(fd);
88   XBT_INFO("File Descriptor information:\n"
89            "\t\tFull path: '%s'\n"
90            "\t\tSize: %llu\n"
91            "\t\tMount point: '%s'\n"
92            "\t\tStorage Id: '%s'\n"
93            "\t\tStorage Type: '%s'\n"
94            "\t\tContent Type: '%s'\n"
95            "\t\tFile Descriptor Id: %d",
96            priv->fullpath, priv->size, priv->mount_point,
97            priv->storageId, priv->storage_type,
98            priv->content_type, priv->desc_id);
99 }
100
101 /** \ingroup msg_file
102  * \brief Read a file (local or remote)
103  *
104  * \param size of the file to read
105  * \param fd is a the file descriptor
106  * \return the number of bytes successfully read or -1 if an error occurred
107  */
108 sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size)
109 {
110   msg_file_priv_t file_priv = MSG_file_priv(fd);
111   sg_size_t read_size;
112
113   if (file_priv->size == 0) /* Nothing to read, return */
114     return 0;
115
116   /* Find the host where the file is physically located and read it */
117   msg_storage_t storage_src = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId));
118   msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
119   msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
120   read_size = simcall_file_read(file_priv->simdata->smx_file, size, attached_host);
121
122   if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
123     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
124     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, read_size);
125     msg_host_t *m_host_list = nullptr;
126     m_host_list = xbt_new0(msg_host_t, 2);
127
128     m_host_list[0] = MSG_host_self();
129     m_host_list[1] = attached_host;
130     double flops_amount[] = { 0, 0};
131     double bytes_amount[] = { 0, 0, static_cast<double>(read_size), 0 };
132
133     msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount,
134                       nullptr);
135     msg_error_t transfer = MSG_parallel_task_execute(task);
136     MSG_task_destroy(task);
137     xbt_free(m_host_list);
138     if(transfer != MSG_OK){
139       if (transfer == MSG_HOST_FAILURE)
140         XBT_WARN("Transfer error, %s remote host just turned off!", attached_host->cname());
141       if (transfer == MSG_TASK_CANCELED)
142         XBT_WARN("Transfer error, task has been canceled!");
143
144       return -1;
145     }
146   }
147   return read_size;
148 }
149
150 /** \ingroup msg_file
151  * \brief Write into a file (local or remote)
152  *
153  * \param size of the file to write
154  * \param fd is a the file descriptor
155  * \return the number of bytes successfully write or -1 if an error occurred
156  */
157 sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
158 {
159   msg_file_priv_t file_priv = MSG_file_priv(fd);
160
161   if (size == 0) /* Nothing to write, return */
162     return 0;
163
164   /* Find the host where the file is physically located (remote or local)*/
165   msg_storage_t storage_src = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId));
166   msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
167   msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
168
169   if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
170     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
171     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size);
172     msg_host_t *m_host_list = nullptr;
173     m_host_list = xbt_new0(msg_host_t, 2);
174
175     m_host_list[0] = MSG_host_self();
176     m_host_list[1] = attached_host;
177     double flops_amount[] = { 0, 0 };
178     double bytes_amount[] = { 0, static_cast<double>(size), 0, 0 };
179
180     msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount,
181                                                nullptr);
182     msg_error_t transfer = MSG_parallel_task_execute(task);
183     MSG_task_destroy(task);
184     free(m_host_list);
185     if(transfer != MSG_OK){
186       if (transfer == MSG_HOST_FAILURE)
187         XBT_WARN("Transfer error, %s remote host just turned off!", attached_host->cname());
188       if (transfer == MSG_TASK_CANCELED)
189         XBT_WARN("Transfer error, task has been canceled!");
190
191       return -1;
192     }
193   }
194   /* Write file on local or remote host */
195   sg_size_t offset = simcall_file_tell(file_priv->simdata->smx_file);
196   sg_size_t write_size = simcall_file_write(file_priv->simdata->smx_file, size, attached_host);
197   file_priv->size = offset+write_size;
198
199   return write_size;
200 }
201
202 /** \ingroup msg_file
203  * \brief Opens the file whose name is the string pointed to by path
204  *
205  * \param fullpath is the file location on the storage
206  * \param data user data to attach to the file
207  *
208  * \return An #msg_file_t associated to the file
209  */
210 msg_file_t MSG_file_open(const char* fullpath, void* data)
211 {
212   char *name;
213   msg_file_priv_t priv = xbt_new(s_msg_file_priv_t, 1);
214   priv->data = data;
215   priv->fullpath = xbt_strdup(fullpath);
216   priv->simdata = xbt_new0(s_simdata_file_t,1);
217   priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
218   priv->desc_id           = MSG_host_get_file_descriptor_id(MSG_host_self());
219
220   name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_self()->cname(), priv->desc_id);
221
222   xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
223   msg_file_t fd = static_cast<msg_file_t>(xbt_lib_get_elm_or_null(file_lib, name));
224   __MSG_file_get_info(fd);
225   xbt_free(name);
226
227   return fd;
228 }
229
230 /** \ingroup msg_file
231  * \brief Close the file
232  *
233  * \param fd is the file to close
234  * \return 0 on success or 1 on error
235  */
236 int MSG_file_close(msg_file_t fd)
237 {
238   char *name;
239   msg_file_priv_t priv = MSG_file_priv(fd);
240   if (priv->data)
241     xbt_free(priv->data);
242
243   int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self());
244   name    = bprintf("%s:%s:%d", priv->fullpath, MSG_host_self()->cname(), priv->desc_id);
245   MSG_host_release_file_descriptor_id(MSG_host_self(), priv->desc_id);
246   xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
247   xbt_free(name);
248   return res;
249 }
250
251 /** \ingroup msg_file
252  * \brief Unlink the file pointed by fd
253  *
254  * \param fd is the file descriptor (#msg_file_t)
255  * \return 0 on success or 1 on error
256  */
257 msg_error_t MSG_file_unlink(msg_file_t fd)
258 {
259   msg_file_priv_t file_priv = MSG_file_priv(fd);
260   /* Find the host where the file is physically located (remote or local)*/
261   msg_storage_t storage_src = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId));
262   msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
263   msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
264   int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host);
265   return static_cast<msg_error_t>(res);
266 }
267
268 /** \ingroup msg_file
269  * \brief Return the size of a file
270  *
271  * \param fd is the file descriptor (#msg_file_t)
272  * \return the size of the file (as a #sg_size_t)
273  */
274 sg_size_t MSG_file_get_size(msg_file_t fd){
275   msg_file_priv_t priv = MSG_file_priv(fd);
276   return simcall_file_get_size(priv->simdata->smx_file);
277 }
278
279 /**
280  * \ingroup msg_file
281  * \brief Set the file position indicator in the msg_file_t by adding offset bytes
282  * to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END).
283  *
284  * \param fd : file object that identifies the stream
285  * \param offset : number of bytes to offset from origin
286  * \param origin : Position used as reference for the offset. It is specified by one of the following constants defined
287  *                 in \<stdio.h\> exclusively to be used as arguments for this function (SEEK_SET = beginning of file,
288  *                 SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
289  * \return If successful, the function returns MSG_OK (=0). Otherwise, it returns MSG_TASK_CANCELED (=8).
290  */
291 msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin)
292 {
293   msg_file_priv_t priv = MSG_file_priv(fd);
294   return static_cast<msg_error_t>(simcall_file_seek(priv->simdata->smx_file, offset, origin));
295 }
296
297 /**
298  * \ingroup msg_file
299  * \brief Returns the current value of the position indicator of the file
300  *
301  * \param fd : file object that identifies the stream
302  * \return On success, the current value of the position indicator is returned.
303  *
304  */
305 sg_size_t MSG_file_tell(msg_file_t fd)
306 {
307   msg_file_priv_t priv = MSG_file_priv(fd);
308   return simcall_file_tell(priv->simdata->smx_file);
309 }
310
311 const char *MSG_file_get_name(msg_file_t fd) {
312   xbt_assert((fd != nullptr), "Invalid parameters");
313   msg_file_priv_t priv = MSG_file_priv(fd);
314   return priv->fullpath;
315 }
316
317 /**
318  * \ingroup msg_file
319  * \brief Move a file to another location on the *same mount point*.
320  *
321  */
322 msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
323 {
324   msg_file_priv_t priv = MSG_file_priv(fd);
325   return static_cast<msg_error_t>(simcall_file_move(priv->simdata->smx_file, fullpath));
326 }
327
328 /**
329  * \ingroup msg_file
330  * \brief Copy a file to another location on a remote host.
331  * \param file : the file to move
332  * \param host : the remote host where the file has to be copied
333  * \param fullpath : the complete path destination on the remote host
334  * \return If successful, the function returns MSG_OK. Otherwise, it returns MSG_TASK_CANCELED.
335  */
336 msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath)
337 {
338   msg_file_priv_t file_priv = MSG_file_priv(file);
339   sg_size_t read_size;
340
341   /* Find the host where the file is physically located and read it */
342   msg_storage_t storage_src = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId));
343   msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
344   msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
345   MSG_file_seek(file, 0, SEEK_SET);
346   read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host);
347
348   /* Find the real host destination where the file will be physically stored */
349   xbt_dict_cursor_t cursor = nullptr;
350   msg_storage_t storage_dest = nullptr;
351   msg_host_t host_dest;
352   size_t longest_prefix_length = 0;
353
354   xbt_dict_t storage_list = host->mountedStoragesAsDict();
355   char *mount_name;
356   char *storage_name;
357   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
358     char* file_mount_name = static_cast<char *>(xbt_malloc ((strlen(mount_name)+1)));
359     strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
360     file_mount_name[strlen(mount_name)] = '\0';
361
362     if(!strcmp(file_mount_name,mount_name) && strlen(mount_name)>longest_prefix_length){
363       /* The current mount name is found in the full path and is bigger than the previous*/
364       longest_prefix_length = strlen(mount_name);
365       storage_dest = (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, storage_name);
366     }
367     xbt_free(file_mount_name);
368   }
369   xbt_dict_free(&storage_list);
370
371   char* host_name_dest = nullptr;
372   if(longest_prefix_length>0){
373     /* Mount point found, retrieve the host the storage is attached to */
374     msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
375     host_name_dest = (char*)storage_dest_priv->hostname;
376     host_dest = MSG_host_by_name(host_name_dest);
377   }else{
378     XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->cname());
379     return MSG_TASK_CANCELED;
380   }
381
382   XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname,
383             host_name_dest);
384   msg_host_t *m_host_list = nullptr;
385   m_host_list = xbt_new0(msg_host_t, 2);
386
387   m_host_list[0] = attached_host;
388   m_host_list[1] = host_dest;
389   double flops_amount[] = { 0, 0 };
390   double bytes_amount[] = { 0, static_cast<double>(read_size), 0, 0 };
391
392   msg_task_t task =
393       MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, nullptr);
394   msg_error_t transfer = MSG_parallel_task_execute(task);
395   MSG_task_destroy(task);
396   xbt_free(m_host_list);
397   if(transfer != MSG_OK){
398     if (transfer == MSG_HOST_FAILURE)
399       XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
400     if (transfer == MSG_TASK_CANCELED)
401       XBT_WARN("Transfer error, task has been canceled!");
402
403     return transfer;
404   }
405
406   /* Create file on remote host, write it and close it */
407   smx_file_t smx_file = simcall_file_open(fullpath, host_dest);
408   simcall_file_write(smx_file, read_size, host_dest);
409   simcall_file_close(smx_file, host_dest);
410   return MSG_OK;
411 }
412
413 /**
414  * \ingroup msg_file
415  * \brief Move a file to another location on a remote host.
416  * \param file : the file to move
417  * \param host : the remote host where the file has to be moved
418  * \param fullpath : the complete path destination on the remote host
419  * \return If successful, the function returns MSG_OK. Otherwise, it returns MSG_TASK_CANCELED.
420  */
421 msg_error_t MSG_file_rmove (msg_file_t file, msg_host_t host, const char* fullpath)
422 {
423   msg_error_t res = MSG_file_rcopy(file, host, fullpath);
424   MSG_file_unlink(file);
425   return res;
426 }
427
428 /**
429  * \brief Destroys a file (internal call only)
430  */
431 void __MSG_file_destroy(msg_file_priv_t file) {
432   xbt_free(file->fullpath);
433   xbt_free(file->simdata);
434   xbt_free(file);
435 }
436
437 /********************************* Storage **************************************/
438 /** @addtogroup msg_storage_management
439  * (#msg_storage_t) and the functions for managing it.
440  */
441
442 msg_storage_t __MSG_storage_create(smx_storage_t storage)
443 {
444   const char *name = SIMIX_storage_get_name(storage);
445   const char *host = SIMIX_storage_get_host(storage);
446   msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
447   storage_private->hostname = host;
448   xbt_lib_set(storage_lib,name,MSG_STORAGE_LEVEL,storage_private);
449   return xbt_lib_get_elm_or_null(storage_lib, name);
450 }
451
452 /**
453  * \brief Destroys a storage (internal call only)
454  */
455 void __MSG_storage_destroy(msg_storage_priv_t storage) {
456   free(storage);
457 }
458
459 /** \ingroup msg_storage_management
460  *
461  * \brief Returns the name of the #msg_storage_t.
462  *
463  * This functions checks whether a storage is a valid pointer or not and return its name.
464  */
465 const char *MSG_storage_get_name(msg_storage_t storage) {
466   xbt_assert((storage != nullptr), "Invalid parameters");
467   return SIMIX_storage_get_name(storage);
468 }
469
470 /** \ingroup msg_storage_management
471  * \brief Returns the free space size of a storage element
472  * \param storage a storage
473  * \return the free space size of the storage element (as a #sg_size_t)
474  */
475 sg_size_t MSG_storage_get_free_size(msg_storage_t storage){
476   return simcall_storage_get_free_size(storage);
477 }
478
479 /** \ingroup msg_storage_management
480  * \brief Returns the used space size of a storage element
481  * \param storage a storage
482  * \return the used space size of the storage element (as a #sg_size_t)
483  */
484 sg_size_t MSG_storage_get_used_size(msg_storage_t storage){
485   return simcall_storage_get_used_size(storage);
486 }
487
488 /** \ingroup msg_storage_management
489  * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this storage
490  * \param storage a storage
491  * \return a dict containing the properties
492  */
493 xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
494 {
495   xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
496   return (simcall_storage_get_properties(storage));
497 }
498
499 /** \ingroup msg_storage_management
500  * \brief Change the value of a given storage property
501  *
502  * \param storage a storage
503  * \param name a property name
504  * \param value what to change the property to
505  */
506 void MSG_storage_set_property_value(msg_storage_t storage, const char* name, char* value)
507 {
508   xbt_dict_set(MSG_storage_get_properties(storage), name, value, nullptr);
509 }
510
511 /** \ingroup m_storage_management
512  * \brief Returns the value of a given storage property
513  *
514  * \param storage a storage
515  * \param name a property name
516  * \return value of a property (or nullptr if property not set)
517  */
518 const char *MSG_storage_get_property_value(msg_storage_t storage, const char *name)
519 {
520   return static_cast<char*>(xbt_dict_get_or_null(MSG_storage_get_properties(storage), name));
521 }
522
523 /** \ingroup msg_storage_management
524  * \brief Finds a msg_storage_t using its name.
525  * \param name the name of a storage
526  * \return the corresponding storage
527  */
528 msg_storage_t MSG_storage_get_by_name(const char *name)
529 {
530   return static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib,name));
531 }
532
533 /** \ingroup msg_storage_management
534  * \brief Returns a dynar containing all the storage elements declared at a given point of time
535  */
536 xbt_dynar_t MSG_storages_as_dynar() {
537   xbt_lib_cursor_t cursor;
538   char *key;
539   void **data;
540   xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr);
541
542   xbt_lib_foreach(storage_lib, cursor, key, data) {
543     if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), MSG_STORAGE_LEVEL) != nullptr) {
544       xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
545       xbt_dynar_push(res, &elm);
546     }
547   }
548   return res;
549 }
550
551 /** \ingroup msg_storage_management
552  *
553  * \brief Set the user data of a #msg_storage_t.
554  * This functions attach \a data to \a storage if possible.
555  */
556 msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data)
557 {
558   msg_storage_priv_t priv = MSG_storage_priv(storage);
559   priv->data = data;
560   return MSG_OK;
561 }
562
563 /** \ingroup m_host_management
564  *
565  * \brief Returns the user data of a #msg_storage_t.
566  *
567  * This functions checks whether \a storage is a valid pointer and returns its associate user data if possible.
568  */
569 void *MSG_storage_get_data(msg_storage_t storage)
570 {
571   xbt_assert((storage != nullptr), "Invalid parameters");
572   msg_storage_priv_t priv = MSG_storage_priv(storage);
573   return priv->data;
574 }
575
576 /** \ingroup msg_storage_management
577  *
578  * \brief Returns the content (file list) of a #msg_storage_t.
579  * \param storage a storage
580  * \return The content of this storage element as a dict (full path file => size)
581  */
582 xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
583 {
584   return SIMIX_storage_get_content(storage);
585 }
586
587 /** \ingroup msg_storage_management
588  *
589  * \brief Returns the size of a #msg_storage_t.
590  * \param storage a storage
591  * \return The size of the storage
592  */
593 sg_size_t MSG_storage_get_size(msg_storage_t storage)
594 {
595   return SIMIX_storage_get_size(storage);
596 }
597
598 /** \ingroup msg_storage_management
599  *
600  * \brief Returns the host name the storage is attached to
601  *
602  * This functions checks whether a storage is a valid pointer or not and return its name.
603  */
604 const char *MSG_storage_get_host(msg_storage_t storage) {
605   xbt_assert((storage != nullptr), "Invalid parameters");
606   msg_storage_priv_t priv = MSG_storage_priv(storage);
607   return priv->hostname;
608 }