/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
size_t longest_prefix_length = 0;
XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->get_cname());
size_t longest_prefix_length = 0;
XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->get_cname());
XBT_DEBUG("See '%s'", mnt.first.c_str());
mount_point_ = fullpath.substr(0, mnt.first.length());
XBT_DEBUG("See '%s'", mnt.first.c_str());
mount_point_ = fullpath.substr(0, mnt.first.length());
// assign a file descriptor id to the newly opened File
FileDescriptorHostExt* ext = host->extension<simgrid::s4u::FileDescriptorHostExt>();
// assign a file descriptor id to the newly opened File
FileDescriptorHostExt* ext = host->extension<simgrid::s4u::FileDescriptorHostExt>();
ext->file_descriptor_table->pop_back();
XBT_DEBUG("\tOpen file '%s'", path_.c_str());
ext->file_descriptor_table->pop_back();
XBT_DEBUG("\tOpen file '%s'", path_.c_str());
// if file does not exist create an empty file
auto sz = content->find(path_);
if (sz != content->end()) {
// if file does not exist create an empty file
auto sz = content->find(path_);
if (sz != content->end()) {
"\t\tStorage Id: '%s'\n"
"\t\tStorage Type: '%s'\n"
"\t\tFile Descriptor Id: %d",
"\t\tStorage Id: '%s'\n"
"\t\tStorage Type: '%s'\n"
"\t\tFile Descriptor Id: %d",
- getPath(), size_, mount_point_.c_str(), localStorage->get_cname(), localStorage->getType(), desc_id);
+ get_path(), size_, mount_point_.c_str(), local_storage_->get_cname(), local_storage_->get_type(), desc_id);
- Host* host = localStorage->getHost();
- XBT_DEBUG("READ %s on disk '%s'", getPath(), localStorage->get_cname());
+ Host* host = local_storage_->get_host();
+ XBT_DEBUG("READ %s on disk '%s'", get_path(), local_storage_->get_cname());
current_position_ += read_size;
if (strcmp(host->get_cname(), Host::current()->get_cname())) {
current_position_ += read_size;
if (strcmp(host->get_cname(), Host::current()->get_cname())) {
- * \param size of the file to write
- * \param fd is a the file descriptor
- * \return the number of bytes successfully write or -1 if an error occurred
+ * @param size of the file to write
+ * @return the number of bytes successfully write or -1 if an error occurred
if (strcmp(host->get_cname(), Host::current()->get_cname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
if (strcmp(host->get_cname(), Host::current()->get_cname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
}
this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
}
- XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->get_cname(), size, size_);
+ XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", get_path(), local_storage_->get_cname(), size, size_);
- sg_size_t write_size = localStorage->write(size);
- localStorage->extension<FileSystemStorageExt>()->incrUsedSize(write_size);
+ sg_size_t write_size = local_storage_->write(size);
+ local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
{
/* Check if the new full path is on the same mount point */
if (not strncmp(mount_point_.c_str(), fullpath.c_str(), mount_point_.length())) {
{
/* Check if the new full path is on the same mount point */
if (not strncmp(mount_point_.c_str(), fullpath.c_str(), mount_point_.length())) {
auto sz = content->find(path_);
if (sz != content->end()) { // src file exists
sg_size_t new_size = sz->second;
auto sz = content->find(path_);
if (sz != content->end()) { // src file exists
sg_size_t new_size = sz->second;
- XBT_WARN("File %s is not on disk %s. Impossible to unlink", path_.c_str(), localStorage->get_cname());
+ XBT_WARN("File %s is not on disk %s. Impossible to unlink", path_.c_str(), local_storage_->get_cname());
- XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), localStorage->get_cname());
- localStorage->extension<FileSystemStorageExt>()->decrUsedSize(size_);
+ XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), local_storage_->get_cname());
+ local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_);
current_position_ += read_size;
/* Find the host that owns the storage where the file has to be copied */
current_position_ += read_size;
/* Find the host that owns the storage where the file has to be copied */
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*/
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*/
if (storage_dest != nullptr) {
/* Mount point found, retrieve the host the storage is attached to */
if (storage_dest != nullptr) {
/* Mount point found, retrieve the host the storage is attached to */
} else {
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(),
} else {
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(),
Host* m_host_list[] = {src_host, dst_host};
double* flops_amount = new double[2]{0, 0};
double* bytes_amount = new double[4]{0, static_cast<double>(read_size), 0, 0};
Host* m_host_list[] = {src_host, dst_host};
double* flops_amount = new double[2]{0, 0};
double* bytes_amount = new double[4]{0, static_cast<double>(read_size), 0, 0};
/* Create file on remote host, write it and close it */
File* fd = new File(fullpath, dst_host, nullptr);
/* Create file on remote host, write it and close it */
File* fd = new File(fullpath, dst_host, nullptr);
- sg_size_t write_size = fd->localStorage->write(read_size);
- fd->localStorage->extension<FileSystemStorageExt>()->incrUsedSize(write_size);
- (*(fd->localStorage->extension<FileSystemStorageExt>()->getContent()))[path_] = size_;
+ 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_;
xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename.c_str(), line.c_str());
sg_size_t size = std::stoull(tokens.at(1));
xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename.c_str(), line.c_str());
sg_size_t size = std::stoull(tokens.at(1));
-static void onStorageDestruction(simgrid::s4u::Storage& st)
-{
- delete st.extension<FileSystemStorageExt>();
-}
-
-static void onHostCreation(simgrid::s4u::Host& host)
+static void on_host_creation(simgrid::s4u::Host& host)
/* **************************** Public interface *************************** */
void sg_storage_file_system_init()
{
/* **************************** Public interface *************************** */
void sg_storage_file_system_init()
{
+ sg_storage_max_file_descriptors = 1024;
+ simgrid::config::bind_flag(sg_storage_max_file_descriptors, "storage/max_file_descriptors",
+ "Maximum number of concurrently opened files per host. Default is 1024");
+
if (not FileSystemStorageExt::EXTENSION_ID.valid()) {
FileSystemStorageExt::EXTENSION_ID = simgrid::s4u::Storage::extension_create<FileSystemStorageExt>();
if (not FileSystemStorageExt::EXTENSION_ID.valid()) {
FileSystemStorageExt::EXTENSION_ID = simgrid::s4u::Storage::extension_create<FileSystemStorageExt>();
}
if (not FileDescriptorHostExt::EXTENSION_ID.valid()) {
FileDescriptorHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<FileDescriptorHostExt>();
}
if (not FileDescriptorHostExt::EXTENSION_ID.valid()) {
FileDescriptorHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<FileDescriptorHostExt>();
const char* sg_file_get_name(sg_file_t fd)
{
xbt_assert((fd != nullptr), "Invalid file descriptor");
const char* sg_file_get_name(sg_file_t fd)
{
xbt_assert((fd != nullptr), "Invalid file descriptor");
- * \param fd : file object that identifies the stream
- * \param offset : number of bytes to offset from origin
- * \param origin : Position used as reference for the offset. It is specified by one of the following constants defined
+ * @param fd : file object that identifies the stream
+ * @param offset : number of bytes to offset from origin
+ * @param origin : Position used as reference for the offset. It is specified by one of the following constants defined
* in \<stdio.h\> exclusively to be used as arguments for this function (SEEK_SET = beginning of file,
* SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
*/
* in \<stdio.h\> exclusively to be used as arguments for this function (SEEK_SET = beginning of file,
* SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
*/
- * \brief Copy a file to another location on a remote host.
- * \param file : the file to move
- * \param host : the remote host where the file has to be copied
- * \param fullpath : the complete path destination on the remote host
- * \return If successful, the function returns 0. Otherwise, it returns -1.
+ * @brief Copy a file to another location on a remote host.
+ * @param file : the file to move
+ * @param host : the remote host where the file has to be copied
+ * @param fullpath : the complete path destination on the remote host
+ * @return If successful, the function returns 0. Otherwise, it returns -1.
- * \brief Move a file to another location on a remote host.
- * \param file : the file to move
- * \param host : the remote host where the file has to be moved
- * \param fullpath : the complete path destination on the remote host
- * \return If successful, the function returns 0. Otherwise, it returns -1.
+ * @brief Move a file to another location on a remote host.
+ * @param file : the file to move
+ * @param host : the remote host where the file has to be moved
+ * @param fullpath : the complete path destination on the remote host
+ * @return If successful, the function returns 0. Otherwise, it returns -1.
// Note: ::operator delete is ok here (no destructor called) since the dict elements are of POD type sg_size_t.
xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete);
// Note: ::operator delete is ok here (no destructor called) since the dict elements are of POD type sg_size_t.
xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete);
{
xbt_assert((host != nullptr), "Invalid parameters");
xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr);
{
xbt_assert((host != nullptr), "Invalid parameters");
xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr);
xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second), nullptr);
return contents;
xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second), nullptr);
return contents;