> [ 0.000000] (1:host@alice) Open file 'c:\Windows\setupact.log'
> [ 0.000000] (2:host@bob) Open file '/home/doc/simgrid/examples/platforms/nancy.xml'
> [ 0.000000] (3:host@carl) Open file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [ 0.000000] (1:host@alice) Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
-> [ 0.000000] (2:host@bob) Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36933331 / 536870912000
-> [ 0.000000] (3:host@carl) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36933331 / 536870912000
> [ 0.000000] (4:host@denise) File Descriptor information:
> Full path: '/home/doc/simgrid/examples/platforms/g5k.xml'
> Size: 17028
> Storage Type: 'single_SSD'
> File Descriptor Id: 0
> [ 0.000000] (4:host@denise) Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
+> [ 0.000000] (1:host@alice) Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
+> [ 0.000000] (2:host@bob) Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36933331 / 536870912000
+> [ 0.000000] (3:host@carl) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36933331 / 536870912000
> [ 0.000000] (4:host@denise) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13221994 / 536870912000
> [ 0.000040] (2:host@bob) Have read 4028 from '/home/doc/simgrid/examples/platforms/nancy.xml'
> [ 0.000085] (4:host@denise) Have read 17028 from '/home/doc/simgrid/examples/platforms/g5k.xml'
> [ 0.000000] (0@ ) Init: 12 MiB used on 'Disk1'
> [ 0.000000] (0@ ) Init: 2280 MiB used on 'Disk2'
> [ 0.000000] (1@alice) Opened file 'c:\Windows\setupact.log'
-> [ 0.000000] (2@ bob) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
-> [ 0.000000] (3@ carl) Opened file '/scratch/lib/libsimgrid.so.3.6.2'
-> [ 0.000000] (4@ dave) Opened file 'c:\Windows\bootstat.dat'
> [ 0.000000] (1@alice) File Descriptor information:
> Full path: 'c:\Windows\setupact.log'
> Size: 101663
> Storage Id: 'Disk2'
> Storage Type: 'SATA-II_HDD'
> 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] (2@ bob) File Descriptor information:
> Full path: '/scratch/lib/libsimgrid.so.3.6.2'
> Size: 12710497
> Storage Id: 'Disk1'
> Storage Type: 'SATA-II_HDD'
> 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
> 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
> Storage Id: 'Disk2'
> Storage Type: 'SATA-II_HDD'
> File Descriptor Id: 0
-> [ 0.000000] (1@alice) Try to read 101663 from 'c:\Windows\setupact.log'
-> [ 0.000000] (2@ bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
-> [ 0.000000] (3@ carl) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'
> [ 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 begining of the stream...
class HostImpl;
class StorageImpl;
class StorageType;
- class FileImpl;
}
namespace trace_mgr {
class trace;
public:
File(std::string fullpath, void* userdata);
File(std::string fullpath, sg_host_t host, void* userdata);
- ~File();
+ ~File() = default;
/** Retrieves the path to the file */
- const char* getPath() { return path_.c_str(); }
+ const char* getPath() { return fullpath_.c_str(); }
/** Simulates a local read action. Returns the size of data actually read */
sg_size_t read(sg_size_t size);
/** Remove a file from disk */
int unlink();
- std::string mount_point;
- Storage* localStorage;
int desc_id = 0;
+ Storage* localStorage;
+ std::string mount_point_;
private:
- simgrid::surf::FileImpl* pimpl_ = nullptr;
+ sg_size_t size_;
std::string path_;
- void* userdata_ = nullptr;
+ std::string fullpath_;
+ sg_size_t current_position_ = SEEK_SET;
+ void* userdata_ = nullptr;
};
}
} // namespace simgrid::s4u
"\t\tStorage Id: '%s'\n"
"\t\tStorage Type: '%s'\n"
"\t\tFile Descriptor Id: %d",
- fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->localStorage->getCname(),
+ fd->getPath(), fd->size(), fd->mount_point_.c_str(), fd->localStorage->getCname(),
fd->localStorage->getType(), fd->desc_id);
}
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/Storage.hpp"
#include "simgrid/simix.hpp"
-#include "src/surf/FileImpl.hpp"
#include "src/surf/HostImpl.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
-File::File(std::string fullpath, sg_host_t host, void* userdata) : path_(fullpath), userdata_(userdata)
+File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath), userdata_(userdata)
{
// this cannot fail because we get a xbt_die if the mountpoint does not exist
Storage* st = nullptr;
size_t longest_prefix_length = 0;
- std::string path;
XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->getCname());
for (auto const& mnt : host->getMountedStorages()) {
XBT_DEBUG("See '%s'", mnt.first.c_str());
- mount_point = fullpath.substr(0, mnt.first.length());
+ mount_point_ = fullpath.substr(0, mnt.first.length());
- if (mount_point == mnt.first && mnt.first.length() > longest_prefix_length) {
+ if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
longest_prefix_length = mnt.first.length();
st = mnt.second;
}
}
if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
- mount_point = fullpath.substr(0, longest_prefix_length);
- path = fullpath.substr(longest_prefix_length, fullpath.length());
+ mount_point_ = fullpath.substr(0, longest_prefix_length);
+ path_ = fullpath.substr(longest_prefix_length, fullpath.length());
} else
xbt_die("Can't find mount point for '%s' on '%s'", fullpath.c_str(), host->getCname());
- pimpl_ =
- simgrid::simix::kernelImmediate([this, st, path] { return new simgrid::surf::FileImpl(st, path, mount_point); });
localStorage = st;
-}
-File::~File()
-{
- simgrid::simix::kernelImmediate([this] { delete pimpl_; });
+ XBT_DEBUG("\tOpen file '%s'", path_.c_str());
+ std::map<std::string, sg_size_t>* content = localStorage->getContent();
+ // if file does not exist create an empty file
+ auto sz = content->find(path_);
+ if (sz != content->end()) {
+ size_ = sz->second;
+ } else {
+ size_ = 0;
+ content->insert({path_, size_});
+ XBT_DEBUG("File '%s' was not found, file created.", path_.c_str());
+ }
}
sg_size_t File::read(sg_size_t size)
{
XBT_DEBUG("READ %s on disk '%s'", getPath(), localStorage->getCname());
// 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 = localStorage->read(std::min(size, this->size() - this->tell()));
- pimpl_->incrPosition(read_size);
+ sg_size_t read_size = localStorage->read(std::min(size, size_ - current_position_));
+ current_position_ += read_size;
return read_size;
}
sg_size_t File::write(sg_size_t size)
{
- XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->getCname(), size, this->size());
+ XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->getCname(), size, size_);
// If the storage is full before even starting to write
if (localStorage->getSizeUsed() >= localStorage->getSize())
return 0;
/* Substract the part of the file that might disappear from the used sized on the storage element */
- localStorage->decrUsedSize(this->size() - this->tell());
+ localStorage->decrUsedSize(size_ - current_position_);
sg_size_t write_size = localStorage->write(size);
- pimpl_->incrPosition(write_size);
- pimpl_->setSize(this->tell());
+ current_position_ += write_size;
+ size_ = current_position_;
- localStorage->getContent()->erase(pimpl_->getName());
- localStorage->getContent()->insert({pimpl_->getName(), this->size()});
+ localStorage->getContent()->erase(path_);
+ localStorage->getContent()->insert({path_, size_});
return write_size;
}
sg_size_t File::size()
{
- return simgrid::simix::kernelImmediate([this] { return pimpl_->size(); });
+ return size_;
}
-void File::seek(sg_offset_t pos)
+void File::seek(sg_offset_t offset)
{
- simgrid::simix::kernelImmediate([this, pos] { pimpl_->seek(pos, SEEK_SET); });
+ current_position_ = offset;
}
-void File::seek(sg_offset_t pos, int origin)
+void File::seek(sg_offset_t offset, int origin)
{
- simgrid::simix::kernelImmediate([this, pos, origin] { pimpl_->seek(pos, origin); });
+ switch (origin) {
+ case SEEK_SET:
+ current_position_ = offset;
+ break;
+ case SEEK_CUR:
+ current_position_ += offset;
+ break;
+ case SEEK_END:
+ current_position_ = size_ + offset;
+ break;
+ default:
+ break;
+ }
}
sg_size_t File::tell()
{
- return simgrid::simix::kernelImmediate([this] { return pimpl_->tell(); });
+ return current_position_;
}
void File::move(std::string fullpath)
{
- simgrid::simix::kernelImmediate([this, fullpath] { pimpl_->move(fullpath); });
+ /* 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())) {
+ std::map<std::string, sg_size_t>* content = localStorage->getContent();
+ auto sz = content->find(path_);
+ if (sz != content->end()) { // src file exists
+ sg_size_t new_size = sz->second;
+ content->erase(path_);
+ std::string path = fullpath.substr(mount_point_.length(), fullpath.length());
+ content->insert({path.c_str(), new_size});
+ XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath.c_str(), new_size);
+ } else {
+ XBT_WARN("File %s doesn't exist", path_.c_str());
+ }
+ } else {
+ XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath.c_str(), mount_point_.c_str());
+ }
}
int File::unlink()
{
- return simgrid::simix::kernelImmediate([this] { return pimpl_->unlink(); });
+ /* Check if the file is on local storage */
+ if (localStorage->getContent()->find(path_) == localStorage->getContent()->end()) {
+ XBT_WARN("File %s is not on disk %s. Impossible to unlink", path_.c_str(), localStorage->getCname());
+ return -1;
+ } else {
+ XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), localStorage->getCname());
+ localStorage->decrUsedSize(size_);
+
+ // Remove the file from storage
+ localStorage->getContent()->erase(fullpath_);
+
+ return 0;
+ }
}
}} // namespace simgrid::s4u
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/Storage.hpp"
-#include "src/surf/FileImpl.hpp"
#include "src/surf/HostImpl.hpp"
#include "src/surf/StorageImpl.hpp"
#include "surf/surf.hpp"
+++ /dev/null
-/* Copyright (c) 2017. The SimGrid Team.
- * All rights reserved. */
-
-/* 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. */
-
-#include "src/surf/FileImpl.hpp"
-#include "src/surf/StorageImpl.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_file, surf, "Logging specific to the SURF file module");
-namespace simgrid {
-namespace surf {
-
-FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_(path), mount_point_(mount)
-{
- XBT_DEBUG("\tOpen file '%s'", path.c_str());
- location_ = st->getImpl();
- std::map<std::string, sg_size_t>* content = location_->getContent();
- // if file does not exist create an empty file
- auto sz = content->find(path);
- if (sz != content->end()) {
- size_ = sz->second;
- } else {
- size_ = 0;
- content->insert({path, size_});
- XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
- }
-}
-
-int FileImpl::seek(sg_offset_t offset, int origin)
-{
- switch (origin) {
- case SEEK_SET:
- current_position_ = offset;
- return 0;
- case SEEK_CUR:
- current_position_ += offset;
- return 0;
- case SEEK_END:
- current_position_ = size_ + offset;
- return 0;
- default:
- return -1;
- }
-}
-
-int FileImpl::unlink()
-{
- /* Check if the file is on this storage */
- if (location_->getContent()->find(path_) == location_->getContent()->end()) {
- XBT_WARN("File %s is not on disk %s. Impossible to unlink", getCname(), location_->getCname());
- return -1;
- } else {
- XBT_DEBUG("UNLINK %s on disk '%s'", getCname(), location_->getCname());
- location_->usedSize_ -= size_;
-
- // Remove the file from storage
- location_->getContent()->erase(path_);
-
- return 0;
- }
-}
-
-void FileImpl::move(std::string fullpath)
-{
- /* Check if the new full path is on the same mount point */
- if (not strncmp(mount_point_.c_str(), fullpath.c_str(), mount_point_.size())) {
- std::map<std::string, sg_size_t>* content = location_->getContent();
- auto sz = content->find(path_);
- if (sz != content->end()) { // src file exists
- sg_size_t new_size = sz->second;
- content->erase(path_);
- std::string path = fullpath.substr(mount_point_.length(), fullpath.length());
- content->insert({path.c_str(), new_size});
- XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath.c_str(), new_size);
- } else {
- XBT_WARN("File %s doesn't exist", path_.c_str());
- }
- } else {
- XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath.c_str(), mount_point_.c_str());
- }
-}
-}
-}
+++ /dev/null
-/* Copyright (c) 2017. The SimGrid Team.
- * All rights reserved. */
-
-/* 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. */
-
-#ifndef SRC_SURF_FILEIMPL_HPP_
-#define SRC_SURF_FILEIMPL_HPP_
-
-#include "surf/surf.hpp"
-#include <string>
-
-namespace simgrid {
-namespace surf {
-
-class FileImpl {
-public:
- FileImpl(sg_storage_t st, std::string path, std::string mount);
- ~FileImpl() = default;
-
- const std::string& getName() const { return path_; }
- const char* getCname() const { return path_.c_str(); }
- const char* mount() { return mount_point_.c_str(); }
- sg_size_t size() { return size_; }
- void setSize(sg_size_t size) { size_ = size; }
- void setPosition(sg_size_t size) { current_position_ = size; }
- void incrPosition(sg_size_t incr) { current_position_ += incr; }
- sg_size_t tell() { return current_position_; }
- int seek(sg_offset_t offset, int origin);
- int unlink();
- void move(std::string fullpath);
-
-private:
- StorageImpl* location_;
- std::string path_;
- std::string mount_point_;
- sg_size_t size_;
- sg_size_t current_position_ = SEEK_SET;
-};
-}
-}
-#endif /* SRC_SURF_FILEIMPL_HPP_ */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/surf/FileImpl.hpp"
#include <string>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
#include <xbt/base.h>
-#include "FileImpl.hpp"
#include "StorageImpl.hpp"
#ifndef STORAGE_N11_HPP_
XBT_LOG_CONNECT(surf_cpu_cas);
XBT_LOG_CONNECT(surf_cpu_ti);
XBT_LOG_CONNECT(surf_energy);
- XBT_LOG_CONNECT(surf_file);
XBT_LOG_CONNECT(surf_kernel);
XBT_LOG_CONNECT(surf_lagrange);
XBT_LOG_CONNECT(surf_lagrange_dichotomy);
src/surf/xml/simgrid_dtd.c
src/surf/xml/surfxml_sax_cb.cpp
- src/surf/FileImpl.hpp
src/surf/StorageImpl.hpp
src/surf/storage_n11.hpp
src/surf/surf_interface.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
src/surf/fair_bottleneck.cpp
- src/surf/FileImpl.cpp
src/surf/instr_routing.cpp
src/surf/instr_surf.cpp
src/surf/lagrange.cpp