Logo AND Algorithmique Numérique Distribuée

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