Logo AND Algorithmique Numérique Distribuée

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