X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7ef49c428ab0209965a09a36ab28b59789aaa4b5..0342cac8cbf7d74cf6efa11b33abd8cb6d87cc3c:/src/surf/HostImpl.cpp?ds=sidebyside diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index f14700b3d3..160224e35d 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -116,25 +116,37 @@ void HostImpl::getAttachedStorageList(std::vector* storages) storages->push_back(s.second->piface_.getName()); } -Action* HostImpl::close(surf_file_t fd) -{ - simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount()); - XBT_DEBUG("CLOSE %s on disk '%s'", fd->cname(), st->cname()); - return st->close(fd); -} - Action* HostImpl::read(surf_file_t fd, sg_size_t size) { 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; } }