- write_size = local_disk_->write(size);
- local_disk_->extension<FileSystemDiskExt>()->incr_used_size(write_size);
- current_position_ += write_size;
- size_ = current_position_;
- } else {
- write_size = local_disk_->write(size);
- current_position_ += write_size;
- if (current_position_ > size_)
- size_ = current_position_;
- }
- kernel::actor::simcall([this] {
- std::map<std::string, sg_size_t, std::less<>>* content = local_disk_->extension<FileSystemDiskExt>()->get_content();
-
- content->erase(path_);
- content->insert({path_, size_});
- });
-
- return write_size;
-}
-
-sg_size_t File::write_on_storage(sg_size_t size, bool write_inside)
-{
- sg_size_t write_size = 0;
- /* Find the host where the file is physically located (remote or local)*/
- Host* host = local_storage_->get_host();
-
- if (host && host->get_name() != Host::current()->get_name()) {
- /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
- XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
- Host::current()->sendto(host, size);
- }
-
- XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_storage_->get_cname(), size, size_,
- sg_storage_get_size_used(local_storage_), sg_storage_get_size(local_storage_));
- // If the storage is full before even starting to write
- if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_))
- return 0;
- if (not write_inside) {
- /* Subtract the part of the file that might disappear from the used sized on the storage element */
- local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_ - current_position_);
- write_size = local_storage_->write(size);
- local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
- current_position_ += write_size;
- size_ = current_position_;
- } else {
- write_size = local_storage_->write(size);
- current_position_ += write_size;
- if (current_position_ > size_)
- size_ = current_position_;
- }
- kernel::actor::simcall([this] {
- std::map<std::string, sg_size_t, std::less<>>* content =
- local_storage_->extension<FileSystemStorageExt>()->get_content();
-
- content->erase(path_);
- content->insert({path_, size_});
- });