{
simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount());
XBT_DEBUG("READ %s on disk '%s'", fd->cname(), st->cname());
- return st->read(fd, size);
+ if (fd->tell() + size > fd->size()) {
+ if (fd->tell() > fd->size()) {
+ size = 0;
+ } else {
+ size = fd->size() - fd->tell();
+ }
+ fd->setPosition(fd->size());
+ } else
+ fd->incrPosition(size);
+
+ return st->read(size);
}
Action* HostImpl::write(surf_file_t fd, sg_size_t size)
{
simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount());
- XBT_DEBUG("WRITE %s on disk '%s'", fd->cname(), st->cname());
- return st->write(fd, size);
+ XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", fd->cname(), st->cname(), size, fd->size());
+
+ StorageAction* action = st->write(size);
+ action->file_ = fd;
+ /* Substract the part of the file that might disappear from the used sized on the storage element */
+ st->usedSize_ -= (fd->size() - fd->tell());
+ // If the storage is full before even starting to write
+ if (st->usedSize_ >= st->size_) {
+ action->setState(Action::State::failed);
+ }
+ return action;
}
}
/**
* @brief Read a file
*
- * @param fd The file descriptor to read
* @param size The size in bytes to read
* @return The StorageAction corresponding to the reading
*/
- virtual StorageAction* read(surf_file_t fd, sg_size_t size) = 0;
+ virtual StorageAction* read(sg_size_t size) = 0;
/**
* @brief Write a file
*
- * @param fd The file descriptor to write
* @param size The size in bytes to write
* @return The StorageAction corresponding to the writing
*/
- virtual StorageAction* write(surf_file_t fd, sg_size_t size) = 0;
+ virtual StorageAction* write(sg_size_t size) = 0;
/**
* @brief Get the content of the current Storage
simgrid::s4u::Storage::onCreation(this->piface_);
}
-StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size)
+StorageAction* StorageN11::read(sg_size_t size)
{
- if (fd->tell() + size > fd->size()) {
- if (fd->tell() > fd->size()) {
- size = 0;
- } else {
- size = fd->size() - fd->tell();
- }
- fd->setPosition(fd->size());
- }
- else
- fd->incrPosition(size);
-
- StorageAction* action = new StorageN11Action(model(), size, isOff(), this, READ);
- return action;
+ return new StorageN11Action(model(), size, isOff(), this, READ);
}
-StorageAction *StorageN11::write(surf_file_t fd, sg_size_t size)
+StorageAction* StorageN11::write(sg_size_t size)
{
- XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'", fd->cname(), size, fd->size());
-
- StorageAction* action = new StorageN11Action(model(), size, isOff(), this, WRITE);
- action->file_ = fd;
- /* Substract the part of the file that might disappear from the used sized on the storage element */
- usedSize_ -= (fd->size() - fd->tell());
- // If the storage is full before even starting to write
- if(usedSize_==size_) {
- action->setState(Action::State::failed);
- }
- return action;
+ return new StorageN11Action(model(), size, isOff(), this, WRITE);
}
/**********
virtual ~StorageN11() = default;
StorageAction *open(const char* mount, const char* path);
StorageAction *ls(const char *path);
- StorageAction* read(surf_file_t fd, sg_size_t size);
- StorageAction* write(surf_file_t fd, sg_size_t size);
+ StorageAction* read(sg_size_t size);
+ StorageAction* write(sg_size_t size);
void rename(const char *src, const char *dest);
};