<host id="alice" speed="1Gf">
<disk id="Disk1" read_bw="200MBps" write_bw="80MBps">
- <prop id="size" value="500GiB"/>
- <prop id="mount" value="/"/>
<prop id="content" value="storage/content/small_content.txt"/>
</disk>
</host>
$ ${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: 12/511987 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] (0@ ) Init: 0/512000 MiB used/free on 'Disk2@bob'
> [ 0.000000] (1@alice) Opened file '/lib/libsimgrid.so.3.6.2'
> [ 0.000000] (1@alice) File Descriptor information:
> Full path: '/lib/libsimgrid.so.3.6.2'
> [162.912320] (1@alice) Move '/lib/libsimgrid.so.3.6.2' (of size 13015548928) from 'alice' to 'bob'
> [666.092709] (0@ ) End: 17/511982 MiB used/free on 'Disk1@alice'
> [666.092709] (0@ ) End: 12452/499547 MiB used/free on 'Disk1@bob'
-> [666.092709] (0@ ) End: 0/0 MiB used/free on 'Disk2@bob'
+> [666.092709] (0@ ) End: 0/512000 MiB used/free on 'Disk2@bob'
> [666.092709] (0@ ) Simulation time 666.093
XBT_INFO("Storage info on %s:", simgrid::s4u::Host::current()->get_cname());
for (auto const& d : disks) {
- const char* mountpoint = d->get_property("mount");
-
// Retrieve disk's information
- XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", d->get_cname(), mountpoint, sg_disk_get_size_used(d),
- sg_disk_get_size_free(d), sg_disk_get_size(d));
+ XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", d->get_cname(), sg_disk_get_mount_point(d),
+ sg_disk_get_size_used(d), sg_disk_get_size_free(d), sg_disk_get_size(d));
}
}
$ ${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 (/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.000000] [s4u_test/INFO] Disk2 (/) Used: 0; Free: 536870912000; Total: 536870912000.
> [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 (/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.005000] [s4u_test/INFO] Disk2 (/) Used: 0; Free: 536870912000; Total: 536870912000.
> [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 (/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] Disk2 (/) Used: 0; Free: 536870912000; Total: 536870912000.
> [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 (/scratch) Used: 36933331; Free: 536833978669; 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] Disk2 (/) Used: 0; Free: 536870912000; Total: 536870912000.
XBT_PUBLIC sg_size_t sg_disk_get_size_free(sg_disk_t d);
XBT_PUBLIC sg_size_t sg_disk_get_size_used(sg_disk_t d);
XBT_PUBLIC sg_size_t sg_disk_get_size(sg_disk_t d);
+XBT_PUBLIC const char* sg_disk_get_mount_point(sg_disk_t d);
XBT_PUBLIC sg_size_t sg_storage_get_size_free(sg_storage_t st);
XBT_PUBLIC sg_size_t sg_storage_get_size_used(sg_storage_t st);
FileSystemDiskExt(const FileSystemDiskExt&) = delete;
FileSystemDiskExt& operator=(const FileSystemDiskExt&) = delete;
std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
- std::map<std::string, sg_size_t>* get_content() { return content_.get(); }
- sg_size_t get_size() { return size_; }
- sg_size_t get_used_size() { return used_size_; }
+ std::map<std::string, sg_size_t>* get_content() const { return content_.get(); }
+ const char* get_mount_point() { return mount_point_.c_str(); }
+ sg_size_t get_size() const { return size_; }
+ sg_size_t get_used_size() const { return used_size_; }
void decr_used_size(sg_size_t size) { used_size_ -= size; }
void incr_used_size(sg_size_t size) { used_size_ += size; }
private:
std::unique_ptr<std::map<std::string, sg_size_t>> content_;
+ std::string mount_point_;
sg_size_t used_size_ = 0;
- sg_size_t size_ = 0;
+ sg_size_t size_ = static_cast<sg_size_t>(500 * 1024) * 1024 * 1024;
};
class XBT_PUBLIC FileSystemStorageExt {
Disk* d = nullptr;
size_t longest_prefix_length = 0;
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);
- mount_point_ = 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();
- d = disk;
- }
- if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
- mount_point_ = fullpath_.substr(0, longest_prefix_length);
- if (mount_point_ == std::string("/"))
- path_ = fullpath_;
- else
- path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
- XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
- } else
- xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+ std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
+ mount_point_ = 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();
+ d = disk;
}
+ if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
+ mount_point_ = fullpath_.substr(0, longest_prefix_length);
+ if (mount_point_ == std::string("/"))
+ path_ = fullpath_;
+ else
+ path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+ XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
+ } else
+ xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
}
local_disk_ = d;
}
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;
- }
+ std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
+ 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;
}
}
FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
{
const char* size_str = ptr->get_property("size");
+ if (size_str)
+ size_ = surf_parse_get_size(size_str, "disk size", ptr->get_name());
+
+ const char* current_mount_str = ptr->get_property("mount");
+ if (current_mount_str)
+ mount_point_ = std::string(current_mount_str);
+ else
+ mount_point_ = std::string("/");
+
const char* content_str = ptr->get_property("content");
- size_ = size_str ? surf_parse_get_size(size_str, "disk size", ptr->get_name()) : 0;
if (content_str)
content_.reset(parse_content(content_str));
}
return d->extension<FileSystemDiskExt>()->get_size();
}
+const char* sg_disk_get_mount_point(sg_disk_t d)
+{
+ return d->extension<FileSystemDiskExt>()->get_mount_point();
+}
+
sg_size_t sg_storage_get_size_free(sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size() - st->extension<FileSystemStorageExt>()->get_used_size();