Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
enable remote copy and move for disks
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 11 Sep 2019 13:16:53 +0000 (15:16 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 11 Sep 2019 13:16:53 +0000 (15:16 +0200)
* need to have a local disk on both sides. it amounts to reading on
one side, sending the read data and writing it on the other side.
* seemless remote accesses for read and write are no longer available.
* simplify the s4u-file-remote test (remote operations with storage is
still tested in teshsuite by an old MSG test)

examples/platforms/hosts_with_disks.xml
examples/s4u/io-file-remote/s4u-io-file-remote.cpp
examples/s4u/io-file-remote/s4u-io-file-remote.tesh
examples/s4u/io-file-remote/s4u-io-file-remote_d.xml
examples/s4u/io-file-system/s4u-io-file-system.cpp
examples/s4u/io-file-system/s4u-io-file-system.tesh
include/simgrid/s4u/Disk.hpp
src/kernel/resource/DiskImpl.hpp
src/plugins/file_system/s4u_FileSystem.cpp
src/s4u/s4u_Disk.cpp
src/surf/sg_platf.cpp

index 8a25f01..cdc7148 100644 (file)
@@ -5,14 +5,18 @@
     <host id="bob" speed="1Gf">
       <disk id="Disk1" read_bw="100MBps" write_bw="40MBps">
         <prop id="size" value="500GiB"/>
-        <prop id="mount" value="/home"/>
+        <prop id="mount" value="/scratch"/>
         <prop id="content" value="storage/content/storage_content.txt"/>
       </disk>
       <disk id="Disk2" read_bw="200MBps" write_bw="80MBps"/>
     </host>
 
     <host id="alice" speed="1Gf">
-      <disk id="Disk1" read_bw="200MBps" write_bw="80MBps"/>
+      <disk id="Disk1" read_bw="200MBps" write_bw="80MBps">
+        <prop id="size" value="500GiB"/>
+        <prop id="mount" value="c:"/>
+        <prop id="content" value="storage/content/win_storage_content.txt"/>
+      </disk>
     </host>
 
     <link id="link1" bandwidth="125MBps" latency="150us" />
index b4e6350..d1dda93 100644 (file)
@@ -17,31 +17,18 @@ static int host(int argc, char* argv[])
   const char* filename = file.get_path();
   XBT_INFO("Opened file '%s'", filename);
   file.dump();
-
-  XBT_INFO("Try to read %llu from '%s'", file.size(), filename);
-  sg_size_t read = file.read(file.size());
-  XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu", read, filename, file.tell());
-  XBT_INFO("Seek back to the beginning of the stream...");
-  file.seek(0, SEEK_SET);
-  XBT_INFO("Offset is now at: %llu", file.tell());
-
-  if (argc > 5) {
-    simgrid::s4u::File remoteFile(argv[2], nullptr);
-    filename = remoteFile.get_path();
-    XBT_INFO("Opened file '%s'", filename);
-    XBT_INFO("Try to write %llu MiB to '%s'", remoteFile.size() / 1024, filename);
-    sg_size_t write = remoteFile.write(remoteFile.size() * 1024);
-    XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
-
-    if (std::stoi(argv[5]) != 0) {
-      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, remoteFile.size(),
-               simgrid::s4u::Host::current()->get_cname(), argv[3]);
-      remoteFile.remote_move(simgrid::s4u::Host::by_name(argv[3]), argv[4]);
-    } else {
-      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, remoteFile.size(),
-               simgrid::s4u::Host::current()->get_cname(), argv[3]);
-      remoteFile.remote_copy(simgrid::s4u::Host::by_name(argv[3]), argv[4]);
-    }
+  XBT_INFO("Try to write %llu MiB to '%s'", file.size() / 1024, filename);
+  sg_size_t write = file.write(file.size() * 1024);
+  XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
+
+  if (std::stoi(argv[4]) != 0) {
+    XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
+             simgrid::s4u::Host::current()->get_cname(), argv[2]);
+    file.remote_move(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
+  } else {
+    XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
+             simgrid::s4u::Host::current()->get_cname(), argv[2]);
+    file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
   }
 
   return 0;
@@ -54,18 +41,20 @@ int main(int argc, char** argv)
   e.load_platform(argv[1]);
   e.register_function("host", host);
   e.load_deployment(argv[2]);
-  std::vector<simgrid::s4u::Storage*> allStorages = e.get_all_storages();
+  std::vector<simgrid::s4u::Host*> all_hosts = e.get_all_hosts();
 
-  for (auto const& s : allStorages) {
-    XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s) / INMEGA,
-             sg_storage_get_size_free(s) / INMEGA, s->get_cname());
+  for (auto const& h : all_hosts) {
+    for (auto const& d : h->get_disks())
+      XBT_INFO("Init: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
+               sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
   }
 
   e.run();
 
-  for (auto const& s : allStorages) {
-    XBT_INFO("End: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s) / INMEGA,
-             sg_storage_get_size_free(s) / INMEGA, s->get_cname());
+  for (auto const& h : all_hosts) {
+    for (auto const& d : h->get_disks())
+      XBT_INFO("End: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
+               sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
   }
 
   XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
index 1f5c26c..e202cc3 100644 (file)
@@ -1,64 +1,32 @@
 #!/usr/bin/env tesh
 
-$ ${bindir:=.}/s4u-io-file-remote ${platfdir}/storage/remote_io.xml s4u-io-file-remote_d.xml "--log=root.fmt:[%10.6r]%e(%i@%5h)%e%m%n"
-> [  0.000000] (0@     ) Init: 12/476824 MiB used/free on 'Disk1'
-> [  0.000000] (0@     ) Init: 2280/474556 MiB used/free on 'Disk2'
-> [  0.000000] (1@alice) Opened file 'c:\Windows\setupact.log'
+$ ${bindir:=.}/s4u-io-file-remote ${platfdir}/hosts_with_disks.xml s4u-io-file-remote_d.xml "--log=root.fmt:[%10.6r]%e(%i@%5h)%e%m%n"
+> [  0.000000] (0@     ) Init: 2280/509719 MiB used/free on 'Disk1@alice'
+> [  0.000000] (0@     ) Init: 35/511964 MiB used/free on 'Disk1@bob'
+> [  0.000000] (0@     ) Init: 0/0 MiB used/free on 'Disk2@bob'
+> [  0.000000] (1@alice) Opened file 'c:\Windows\Professional.xml'
 > [  0.000000] (1@alice) File Descriptor information:
->              Full path: 'c:\Windows\setupact.log'
->              Size: 101663
+>              Full path: 'c:\Windows\Professional.xml'
+>              Size: 31881
 >              Mount point: 'c:'
->              Storage Id: 'Disk2'
->              Storage Type: 'SATA-II_HDD'
+>              Disk Id: 'Disk1'
+>              Host Id: 'alice'
 >              File Descriptor Id: 0
-> [  0.000000] (1@alice) Try to read 101663 from 'c:\Windows\setupact.log'
-> [  0.000000] (2@  bob) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
+> [  0.000000] (1@alice) Try to write 31 MiB to 'c:\Windows\Professional.xml'
+> [  0.000000] (2@  bob) Opened file '/scratch/doc/simgrid/examples/platforms/g5k.xml'
 > [  0.000000] (2@  bob) File Descriptor information:
->              Full path: '/scratch/lib/libsimgrid.so.3.6.2'
->              Size: 12710497
+>              Full path: '/scratch/doc/simgrid/examples/platforms/g5k.xml'
+>              Size: 17028
 >              Mount point: '/scratch'
->              Storage Id: 'Disk1'
->              Storage Type: 'SATA-II_HDD'
+>              Disk Id: 'Disk1'
+>              Host Id: 'bob'
 >              File Descriptor Id: 0
-> [  0.000000] (2@  bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
-> [  0.000000] (3@ carl) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
-> [  0.000000] (3@ carl) File Descriptor information:
->              Full path: '/scratch/lib/libsimgrid.so.3.6.2'
->              Size: 12710497
->              Mount point: '/scratch'
->              Storage Id: 'Disk1'
->              Storage Type: 'SATA-II_HDD'
->              File Descriptor Id: 0
-> [  0.000000] (3@ carl) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
-> [  0.000000] (4@ dave) Opened file 'c:\Windows\bootstat.dat'
-> [  0.000000] (4@ dave) File Descriptor information:
->              Full path: 'c:\Windows\bootstat.dat'
->              Size: 67584
->              Mount point: 'c:'
->              Storage Id: 'Disk2'
->              Storage Type: 'SATA-II_HDD'
->              File Descriptor Id: 0
-> [  0.000000] (4@ dave) Try to read 67584 from 'c:\Windows\bootstat.dat'
-> [  0.001469] (4@ dave) Have read 67584 from 'c:\Windows\bootstat.dat'. Offset is now at: 67584
-> [  0.001469] (4@ dave) Seek back to the beginning of the stream...
-> [  0.001469] (4@ dave) Offset is now at: 0
-> [  0.001469] (4@ dave) Opened file 'c:\Windows\Professional.xml'
-> [  0.001469] (4@ dave) Try to write 31 MiB to 'c:\Windows\Professional.xml'
-> [  0.003741] (1@alice) Have read 101663 from 'c:\Windows\setupact.log'. Offset is now at: 101663
-> [  0.003741] (1@alice) Seek back to the beginning of the stream...
-> [  0.003741] (1@alice) Offset is now at: 0
-> [  0.276315] (3@ carl) Have read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'. Offset is now at: 12710497
-> [  0.276315] (3@ carl) Seek back to the beginning of the stream...
-> [  0.276315] (3@ carl) Offset is now at: 0
-> [  0.387036] (2@  bob) Have read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'. Offset is now at: 12710497
-> [  0.387036] (2@  bob) Seek back to the beginning of the stream...
-> [  0.387036] (2@  bob) Offset is now at: 0
-> [  0.387036] (2@  bob) Opened file '/scratch/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.387036] (2@  bob) Try to write 16 MiB to '/scratch/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.528211] (4@ dave) Have written 32646144 bytes to 'c:\Windows\Professional.xml'.
-> [  0.528211] (4@ dave) Move 'c:\Windows\Professional.xml' (of size 32646144) from 'dave' to 'carl'
-> [  0.819921] (2@  bob) Have written 17436672 bytes to '/scratch/doc/simgrid/examples/platforms/g5k.xml'.
-> [  0.819921] (2@  bob) Copy '/scratch/doc/simgrid/examples/platforms/g5k.xml' (of size 17436672) from 'bob' to 'alice'
-> [  1.843969] (0@     ) End: 60/476776 MiB used/free on 'Disk1'
-> [  1.843969] (0@     ) End: 2297/474539 MiB used/free on 'Disk2'
-> [  1.843969] (0@     ) Simulation time 1.84397
+> [  0.000000] (2@  bob) Try to write 16 MiB to '/scratch/doc/simgrid/examples/platforms/g5k.xml'
+> [  0.408077] (1@alice) Have written 32646144 bytes to 'c:\Windows\Professional.xml'.
+> [  0.408077] (1@alice) Move 'c:\Windows\Professional.xml' (of size 32646144) from 'alice' to 'bob'
+> [  0.435917] (2@  bob) Have written 17436672 bytes to '/scratch/doc/simgrid/examples/platforms/g5k.xml'.
+> [  0.435917] (2@  bob) Copy '/scratch/doc/simgrid/examples/platforms/g5k.xml' (of size 17436672) from 'bob' to 'alice'
+> [  1.823119] (0@     ) End: 2297/509702 MiB used/free on 'Disk1@alice'
+> [  1.823119] (0@     ) End: 82/511917 MiB used/free on 'Disk1@bob'
+> [  1.823119] (0@     ) End: 0/0 MiB used/free on 'Disk2@bob'
+> [  1.823119] (0@     ) Simulation time 1.82312
index 3b3f1ab..13caee2 100644 (file)
@@ -2,23 +2,15 @@
 <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
 <platform version="4.1">
   <actor host="alice" function="host">
-    <argument value = "c:\Windows\setupact.log"/>
+    <argument value = "c:\Windows\Professional.xml"/>
+    <argument value = "bob"/>
+    <argument value = "/scratch/mailbox/Professional.xml"/>
+    <argument value = "1"/>
   </actor>
   <actor host="bob" function="host">
-    <argument value = "/scratch/lib/libsimgrid.so.3.6.2"/>
     <argument value = "/scratch/doc/simgrid/examples/platforms/g5k.xml"/>
     <argument value = "alice"/>
     <argument value = "c:\Windows\Platforms\g5k.xml"/>
     <argument value = "0"/>
   </actor>
-  <actor host="carl" function="host">
-    <argument value = "/scratch/lib/libsimgrid.so.3.6.2"/>
-  </actor>
-  <actor host="dave" function="host">
-    <argument value = "c:\Windows\bootstat.dat"/>
-    <argument value = "c:\Windows\Professional.xml"/>
-    <argument value = "carl"/>
-    <argument value = "/scratch/mailbox/Professional.xml"/>
-    <argument value = "1"/>
-  </actor>
 </platform>
index 0542fbf..1650c51 100644 (file)
@@ -33,11 +33,11 @@ public:
     show_info(disks);
 
     // Open an non-existing file to create it
-    std::string filename     = "/home/tmp/data.txt";
+    std::string filename     = "/scratch/tmp/data.txt";
     simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
 
     sg_size_t write = file->write(200000); // Write 200,000 bytes
-    XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename.c_str());
+    XBT_INFO("Create a %llu bytes file named '%s' on /scratch", write, filename.c_str());
 
     // check that sizes have changed
     show_info(disks);
@@ -53,7 +53,7 @@ public:
     XBT_INFO("Write %llu bytes on %s", write, filename.c_str());
 
     // Now rename file from ./tmp/data.txt to ./tmp/simgrid.readme
-    std::string newpath = "/home/tmp/simgrid.readme";
+    std::string newpath = "/scratch/tmp/simgrid.readme";
     XBT_INFO("Move '%s' to '%s'", file->get_path(), newpath.c_str());
     file->move(newpath);
 
@@ -69,7 +69,7 @@ public:
     show_info(disks);
 
     // Reopen the file and then unlink it
-    file = new simgrid::s4u::File("/home/tmp/simgrid.readme", nullptr);
+    file = new simgrid::s4u::File("/scratch/tmp/simgrid.readme", nullptr);
     XBT_INFO("Unlink file: '%s'", file->get_path());
     file->unlink();
     delete file; // Unlinking the file on "disk" does not free the object
index 8f6229f..1374ff3 100644 (file)
@@ -2,20 +2,20 @@
 
 $ ${bindir:=.}/s4u-io-file-system ${platfdir}/hosts_with_disks.xml
 > [bob:host:(1) 0.000000] [s4u_test/INFO] Storage info on bob:
-> [bob:host:(1) 0.000000] [s4u_test/INFO]     Disk1 (/home) Used: 36933331; Free: 536833978669; Total: 536870912000.
+> [bob:host:(1) 0.000000] [s4u_test/INFO]     Disk1 (/scratch) Used: 36933331; Free: 536833978669; Total: 536870912000.
 > [bob:host:(1) 0.000000] [s4u_test/INFO]     Disk2 ((null)) Used: 0; Free: 0; Total: 0.
-> [bob:host:(1) 0.005000] [s4u_test/INFO] Create a 200000 bytes file named '/home/tmp/data.txt' on /sd1
+> [bob:host:(1) 0.005000] [s4u_test/INFO] Create a 200000 bytes file named '/scratch/tmp/data.txt' on /scratch
 > [bob:host:(1) 0.005000] [s4u_test/INFO] Storage info on bob:
-> [bob:host:(1) 0.005000] [s4u_test/INFO]     Disk1 (/home) Used: 37133331; Free: 536833778669; Total: 536870912000.
+> [bob:host:(1) 0.005000] [s4u_test/INFO]     Disk1 (/scratch) Used: 37133331; Free: 536833778669; Total: 536870912000.
 > [bob:host:(1) 0.005000] [s4u_test/INFO]     Disk2 ((null)) Used: 0; Free: 0; Total: 0.
-> [bob:host:(1) 0.007000] [s4u_test/INFO] Read 200000 bytes on /home/tmp/data.txt
-> [bob:host:(1) 0.009500] [s4u_test/INFO] Write 100000 bytes on /home/tmp/data.txt
-> [bob:host:(1) 0.009500] [s4u_test/INFO] Move '/home/tmp/data.txt' to '/home/tmp/simgrid.readme'
+> [bob:host:(1) 0.007000] [s4u_test/INFO] Read 200000 bytes on /scratch/tmp/data.txt
+> [bob:host:(1) 0.009500] [s4u_test/INFO] Write 100000 bytes on /scratch/tmp/data.txt
+> [bob:host:(1) 0.009500] [s4u_test/INFO] Move '/scratch/tmp/data.txt' to '/scratch/tmp/simgrid.readme'
 > [bob:host:(1) 0.009500] [s4u_test/INFO] User data attached to the file: 777
 > [bob:host:(1) 0.009500] [s4u_test/INFO] Storage info on bob:
-> [bob:host:(1) 0.009500] [s4u_test/INFO]     Disk1 (/home) Used: 37233331; Free: 536833678669; Total: 536870912000.
+> [bob:host:(1) 0.009500] [s4u_test/INFO]     Disk1 (/scratch) Used: 37233331; Free: 536833678669; Total: 536870912000.
 > [bob:host:(1) 0.009500] [s4u_test/INFO]     Disk2 ((null)) Used: 0; Free: 0; Total: 0.
-> [bob:host:(1) 0.009500] [s4u_test/INFO] Unlink file: '/home/tmp/simgrid.readme'
+> [bob:host:(1) 0.009500] [s4u_test/INFO] Unlink file: '/scratch/tmp/simgrid.readme'
 > [bob:host:(1) 0.009500] [s4u_test/INFO] Storage info on bob:
-> [bob:host:(1) 0.009500] [s4u_test/INFO]     Disk1 (/home) Used: 36933331; Free: 536833978669; Total: 536870912000.
+> [bob:host:(1) 0.009500] [s4u_test/INFO]     Disk1 (/scratch) Used: 36933331; Free: 536833978669; Total: 536870912000.
 > [bob:host:(1) 0.009500] [s4u_test/INFO]     Disk2 ((null)) Used: 0; Free: 0; Total: 0.
index 03d82c5..7715095 100644 (file)
@@ -52,6 +52,7 @@ public:
   const std::unordered_map<std::string, std::string>* get_properties() const;
   const char* get_property(const std::string& key) const;
   void set_property(const std::string&, const std::string& value);
+  Host* get_host();
 
   void set_data(void* data) { userdata_ = data; }
   void* get_data() { return userdata_; }
index 79abb67..80ae7a6 100644 (file)
@@ -49,6 +49,7 @@ public:
  ************/
 class DiskImpl : public Resource, public surf::PropertyHolder {
   bool currently_destroying_ = false;
+  s4u::Host* host_           = nullptr;
 
 public:
   DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
@@ -68,6 +69,9 @@ public:
   void turn_on() override;
   void turn_off() override;
 
+  s4u::Host* get_host() { return host_; }
+  void set_host(s4u::Host* host) { host_ = host; }
+
   void destroy(); // Must be called instead of the destructor
   virtual DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) = 0;
   virtual DiskAction* read(sg_size_t size)                           = 0;
index 25893f4..e9aeb84 100644 (file)
@@ -90,8 +90,10 @@ File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpa
   std::map<std::string, sg_size_t>* content;
   if (local_storage_)
     content = local_storage_->extension<FileSystemStorageExt>()->get_content();
-  else
+
+  if (local_disk_)
     content = local_disk_->extension<FileSystemDiskExt>()->get_content();
+
   // if file does not exist create an empty file
   auto sz = content->find(path_);
   if (sz != content->end()) {
@@ -110,14 +112,25 @@ File::~File()
 
 void File::dump()
 {
-  XBT_INFO("File Descriptor information:\n"
-           "\t\tFull path: '%s'\n"
-           "\t\tSize: %llu\n"
-           "\t\tMount point: '%s'\n"
-           "\t\tStorage Id: '%s'\n"
-           "\t\tStorage Type: '%s'\n"
-           "\t\tFile Descriptor Id: %d",
-           get_path(), size_, mount_point_.c_str(), local_storage_->get_cname(), local_storage_->get_type(), desc_id);
+  if (local_storage_)
+    XBT_INFO("File Descriptor information:\n"
+             "\t\tFull path: '%s'\n"
+             "\t\tSize: %llu\n"
+             "\t\tMount point: '%s'\n"
+             "\t\tStorage Id: '%s'\n"
+             "\t\tStorage Type: '%s'\n"
+             "\t\tFile Descriptor Id: %d",
+             get_path(), size_, mount_point_.c_str(), local_storage_->get_cname(), local_storage_->get_type(), desc_id);
+  if (local_disk_)
+    XBT_INFO("File Descriptor information:\n"
+             "\t\tFull path: '%s'\n"
+             "\t\tSize: %llu\n"
+             "\t\tMount point: '%s'\n"
+             "\t\tDisk Id: '%s'\n"
+             "\t\tHost Id: '%s'\n"
+             "\t\tFile Descriptor Id: %d",
+             get_path(), size_, mount_point_.c_str(), local_disk_->get_cname(), local_disk_->get_host()->get_cname(),
+             desc_id);
 }
 
 sg_size_t File::read(sg_size_t size)
@@ -299,8 +312,10 @@ int File::unlink()
     return -1;
   } else {
     XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), name);
+
     if (local_storage_)
       local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_);
+
     if (local_disk_)
       local_disk_->extension<FileSystemDiskExt>()->decr_used_size(size_);
 
@@ -314,45 +329,87 @@ int File::unlink()
 int File::remote_copy(sg_host_t host, const char* fullpath)
 {
   /* Find the host where the file is physically located and read it */
-  Storage* storage_src = local_storage_;
-  Host* src_host       = storage_src->get_host();
+  Host* src_host;
+  if (local_storage_) {
+    src_host = local_storage_->get_host();
+    XBT_DEBUG("READ %s on disk '%s'", get_path(), local_storage_->get_cname());
+  }
+
+  if (local_disk_) {
+    src_host = local_disk_->get_host();
+    XBT_DEBUG("READ %s on disk '%s'", get_path(), local_disk_->get_cname());
+  }
+
   seek(0, SEEK_SET);
-  XBT_DEBUG("READ %s on disk '%s'", get_path(), local_storage_->get_cname());
   // if the current position is close to the end of the file, we may not be able to read the requested size
-  sg_size_t read_size = local_storage_->read(size_);
+  sg_size_t read_size = 0;
+  if (local_storage_)
+    read_size = local_storage_->read(size_);
+  if (local_disk_)
+    read_size = local_disk_->read(size_);
+
   current_position_ += read_size;
 
-  /* Find the host that owns the storage where the file has to be copied */
-  Storage* storage_dest = nullptr;
-  Host* dst_host;
-  size_t longest_prefix_length = 0;
-
-  for (auto const& elm : host->get_mounted_storages()) {
-    std::string mount_point = std::string(fullpath).substr(0, elm.first.size());
-    if (mount_point == elm.first && elm.first.length() > longest_prefix_length) {
-      /* The current mount name is found in the full path and is bigger than the previous*/
-      longest_prefix_length = elm.first.length();
-      storage_dest          = elm.second;
+  Host* dst_host = host;
+  if (local_storage_) {
+    /* Find the host that owns the storage where the file has to be copied */
+    Storage* storage_dest        = nullptr;
+    size_t longest_prefix_length = 0;
+
+    for (auto const& elm : host->get_mounted_storages()) {
+      std::string mount_point = std::string(fullpath).substr(0, elm.first.size());
+      if (mount_point == elm.first && elm.first.length() > longest_prefix_length) {
+        /* The current mount name is found in the full path and is bigger than the previous*/
+        longest_prefix_length = elm.first.length();
+        storage_dest          = elm.second;
+      }
+    }
+
+    if (storage_dest != nullptr) {
+      /* Mount point found, retrieve the host the storage is attached to */
+      dst_host = storage_dest->get_host();
+    } else {
+      XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->get_cname());
+      return -1;
     }
   }
 
-  if (storage_dest != nullptr) {
-    /* Mount point found, retrieve the host the storage is attached to */
-    dst_host = storage_dest->get_host();
-  } else {
-    XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->get_cname());
-    return -1;
+  if (local_disk_) {
+    size_t longest_prefix_length = 0;
+    Disk* dst_disk               = nullptr;
+
+    for (auto const& disk : host->get_disks()) {
+      const char* current_mount_str = disk->get_property("mount");
+      if (current_mount_str) {
+        std::string current_mount = std::string(current_mount_str);
+        std::string mount_point   = std::string(fullpath).substr(0, current_mount.length());
+        if (mount_point == current_mount && current_mount.length() > longest_prefix_length) {
+          /* The current mount name is found in the full path and is bigger than the previous*/
+          longest_prefix_length = current_mount.length();
+          dst_disk              = disk;
+        }
+      }
+    }
+
+    if (dst_disk == nullptr) {
+      XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->get_cname());
+      return -1;
+    }
   }
 
   XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->get_cname(),
-            storage_dest->get_host()->get_cname());
+            dst_host->get_cname());
   src_host->send_to(dst_host, read_size);
 
   /* Create file on remote host, write it and close it */
   File* fd = new File(fullpath, dst_host, nullptr);
-  sg_size_t write_size = fd->local_storage_->write(read_size);
-  fd->local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
-  (*(fd->local_storage_->extension<FileSystemStorageExt>()->get_content()))[path_] = size_;
+  if (local_storage_) {
+    sg_size_t write_size = fd->local_storage_->write(read_size);
+    fd->local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
+    (*(fd->local_storage_->extension<FileSystemStorageExt>()->get_content()))[path_] = size_;
+  }
+  if (local_disk_)
+    fd->write(read_size);
   delete fd;
   return 0;
 }
index c9477e4..562e742 100644 (file)
@@ -20,6 +20,11 @@ xbt::signal<void(Disk&)> Disk::on_creation;
 xbt::signal<void(Disk const&)> Disk::on_destruction;
 xbt::signal<void(Disk const&)> Disk::on_state_change;
 
+Host* Disk::get_host()
+{
+  return pimpl_->get_host();
+}
+
 const std::unordered_map<std::string, std::string>* Disk::get_properties() const
 {
   return pimpl_->get_properties();
index 8a080b8..d172827 100644 (file)
@@ -82,6 +82,8 @@ void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
   mount_list.clear();
 
   host->pimpl_->disks_ = std::move(args->disks);
+  for (auto d : host->pimpl_->disks_)
+    d->set_host(host);
 
   /* Change from the defaults */
   if (args->state_trace)