From: Frederic Suter Date: Tue, 21 Nov 2017 22:55:30 +0000 (+0100) Subject: further split File and Storage X-Git-Tag: v3.18~272^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3f38d568f0b8155a643e15a3171177060ee15c3c?ds=sidebyside further split File and Storage --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index e2cdeab06b..c59cd236a5 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -80,7 +80,7 @@ typedef simgrid::kernel::context::Context* smx_context_t; typedef simgrid::simix::ActorImpl* smx_actor_t; typedef simgrid::simix::MutexImpl* smx_mutex_t; typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t; -typedef simgrid::surf::FileImpl* surf_file_t; +typedef simgrid::surf::StorageImpl* surf_storage_t; #else @@ -100,7 +100,7 @@ typedef struct s_smx_context* smx_context_t; typedef struct s_smx_actor* smx_actor_t; typedef struct s_smx_mutex* smx_mutex_t; typedef struct s_smx_mailbox* smx_mailbox_t; -typedef struct s_surf_file* surf_file_t; +typedef struct s_surf_storage* surf_storage_t; #endif diff --git a/include/simgrid/s4u/File.hpp b/include/simgrid/s4u/File.hpp index 14b370b451..1429d2cf37 100644 --- a/include/simgrid/s4u/File.hpp +++ b/include/simgrid/s4u/File.hpp @@ -64,7 +64,7 @@ public: int desc_id = 0; private: - surf_file_t pimpl_ = nullptr; + simgrid::surf::FileImpl* pimpl_ = nullptr; std::string path_; void* userdata_ = nullptr; }; diff --git a/include/simgrid/s4u/Storage.hpp b/include/simgrid/s4u/Storage.hpp index b8d328ef7c..c009740e9d 100644 --- a/include/simgrid/s4u/Storage.hpp +++ b/include/simgrid/s4u/Storage.hpp @@ -38,6 +38,7 @@ public: sg_size_t getSize(); /** Retrieve the total amount of space of this storage element */ sg_size_t getSizeFree(); sg_size_t getSizeUsed(); + void decrUsedSize(sg_size_t size); std::map* getProperties(); const char* getProperty(std::string key); @@ -47,6 +48,8 @@ public: void setUserdata(void* data) { userdata_ = data; } void* getUserdata() { return userdata_; } + sg_size_t read(sg_size_t size); + sg_size_t write(sg_size_t size); surf::StorageImpl* getImpl() { return pimpl_; } /* The signals */ diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 8d2729174a..7d9245dd67 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -284,9 +284,9 @@ XBT_PUBLIC(void) SIMIX_sem_destroy(smx_sem_t sem); XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem); XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration); -/***************************** File **********************************/ -XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size); -XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size); +/***************************** Storage **********************************/ +XBT_PUBLIC(sg_size_t) simcall_storage_read(surf_storage_t st, sg_size_t size); +XBT_PUBLIC(sg_size_t) simcall_storage_write(surf_storage_t fd, sg_size_t size); /************************** MC simcalls **********************************/ XBT_PUBLIC(int) simcall_mc_random(int min, int max); diff --git a/src/kernel/activity/SynchroIo.cpp b/src/kernel/activity/SynchroIo.cpp index 65ac052ee2..9001cf9c57 100644 --- a/src/kernel/activity/SynchroIo.cpp +++ b/src/kernel/activity/SynchroIo.cpp @@ -23,14 +23,14 @@ void simgrid::kernel::activity::IoImpl::post() { for (smx_simcall_t const& simcall : simcalls) { switch (simcall->call) { - case SIMCALL_FILE_WRITE: - simcall_file_write__set__result(simcall, surf_io->getCost()); - break; - case SIMCALL_FILE_READ: - simcall_file_read__set__result(simcall, surf_io->getCost()); - break; - default: - break; + case SIMCALL_STORAGE_WRITE: + simcall_storage_write__set__result(simcall, surf_io->getCost()); + break; + case SIMCALL_STORAGE_READ: + simcall_storage_read__set__result(simcall, surf_io->getCost()); + break; + default: + break; } } diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index f9fa944dde..8c90137942 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -55,12 +55,30 @@ File::~File() sg_size_t File::read(sg_size_t size) { - return simcall_file_read(pimpl_, size); + XBT_DEBUG("READ %s on disk '%s'", getPath(), onStorage->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 = onStorage->read(std::min(size, this->size() - this->tell())); + pimpl_->incrPosition(read_size); + return read_size; } sg_size_t File::write(sg_size_t size) { - return simcall_file_write(pimpl_, size); + XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), onStorage->getCname(), size, this->size()); + // If the storage is full before even starting to write + if (onStorage->getSizeUsed() >= onStorage->getSize()) + return 0; + /* Substract the part of the file that might disappear from the used sized on the storage element */ + onStorage->decrUsedSize(this->size() - this->tell()); + + sg_size_t write_size = onStorage->write(size); + pimpl_->incrPosition(write_size); + pimpl_->setSize(this->tell()); + + onStorage->getContent()->erase(pimpl_->getName()); + onStorage->getContent()->insert({pimpl_->getName(), this->size()}); + + return write_size; } sg_size_t File::size() diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 6dd8fe9dcb..5cb09af9e0 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -3,10 +3,10 @@ /* 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 "../surf/StorageImpl.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/Storage.hpp" #include "simgrid/simix.hpp" +#include "src/surf/StorageImpl.hpp" #include namespace simgrid { @@ -60,6 +60,11 @@ sg_size_t Storage::getSizeUsed() return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); }); } +void Storage::decrUsedSize(sg_size_t size) +{ + simgrid::simix::kernelImmediate([this, size] { pimpl_->usedSize_ -= size; }); +} + sg_size_t Storage::getSize() { return pimpl_->getSize(); @@ -85,6 +90,16 @@ std::map* Storage::getContent() return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); }); } +sg_size_t Storage::read(sg_size_t size) +{ + return simcall_storage_read(pimpl_, size); +} + +sg_size_t Storage::write(sg_size_t size) +{ + return simcall_storage_write(pimpl_, size); +} + /************* * Callbacks * *************/ diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 568bce1617..6af48805e9 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -505,9 +505,7 @@ void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex) * \ingroup simix_synchro_management * */ -void simcall_cond_wait_timeout(smx_cond_t cond, - smx_mutex_t mutex, - double timeout) +void simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout) { xbt_assert(std::isfinite(timeout), "timeout is not finite!"); simcall_BODY_cond_wait_timeout(cond, mutex, timeout); @@ -541,22 +539,14 @@ void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout) simcall_BODY_sem_acquire_timeout(sem, timeout); } -/** - * \ingroup simix_file_management - * - */ -sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size) +sg_size_t simcall_storage_read(surf_storage_t st, sg_size_t size) { - return simcall_BODY_file_read(fd, size); + return simcall_BODY_storage_read(st, size); } -/** - * \ingroup simix_file_management - * - */ -sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size) +sg_size_t simcall_storage_write(surf_storage_t st, sg_size_t size) { - return simcall_BODY_file_write(fd, size); + return simcall_BODY_storage_write(st, size); } void simcall_run_kernel(std::function const& code) diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 3201a9e4f6..020056e3f0 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -1195,76 +1195,76 @@ static inline void simcall_sem_acquire_timeout__set__timeout(smx_simcall_t simca simgrid::simix::marshal(simcall->args[1], arg); } -static inline surf_file_t simcall_file_read__get__fd(smx_simcall_t simcall) +static inline surf_storage_t simcall_storage_read__get__st(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline surf_file_t simcall_file_read__getraw__fd(smx_simcall_t simcall) +static inline surf_storage_t simcall_storage_read__getraw__st(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_read__set__fd(smx_simcall_t simcall, surf_file_t arg) +static inline void simcall_storage_read__set__st(smx_simcall_t simcall, surf_storage_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } -static inline sg_size_t simcall_file_read__get__size(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_read__get__size(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[1]); } -static inline sg_size_t simcall_file_read__getraw__size(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_read__getraw__size(smx_simcall_t simcall) { return simgrid::simix::unmarshal_raw(simcall->args[1]); } -static inline void simcall_file_read__set__size(smx_simcall_t simcall, sg_size_t arg) +static inline void simcall_storage_read__set__size(smx_simcall_t simcall, sg_size_t arg) { simgrid::simix::marshal(simcall->args[1], arg); } -static inline sg_size_t simcall_file_read__get__result(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_read__get__result(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->result); } -static inline sg_size_t simcall_file_read__getraw__result(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_read__getraw__result(smx_simcall_t simcall) { return simgrid::simix::unmarshal_raw(simcall->result); } -static inline void simcall_file_read__set__result(smx_simcall_t simcall, sg_size_t result) +static inline void simcall_storage_read__set__result(smx_simcall_t simcall, sg_size_t result) { simgrid::simix::marshal(simcall->result, result); } -static inline surf_file_t simcall_file_write__get__fd(smx_simcall_t simcall) +static inline surf_storage_t simcall_storage_write__get__st(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline surf_file_t simcall_file_write__getraw__fd(smx_simcall_t simcall) +static inline surf_storage_t simcall_storage_write__getraw__st(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_write__set__fd(smx_simcall_t simcall, surf_file_t arg) +static inline void simcall_storage_write__set__st(smx_simcall_t simcall, surf_storage_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } -static inline sg_size_t simcall_file_write__get__size(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_write__get__size(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[1]); } -static inline sg_size_t simcall_file_write__getraw__size(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_write__getraw__size(smx_simcall_t simcall) { return simgrid::simix::unmarshal_raw(simcall->args[1]); } -static inline void simcall_file_write__set__size(smx_simcall_t simcall, sg_size_t arg) +static inline void simcall_storage_write__set__size(smx_simcall_t simcall, sg_size_t arg) { simgrid::simix::marshal(simcall->args[1], arg); } -static inline sg_size_t simcall_file_write__get__result(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_write__get__result(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->result); } -static inline sg_size_t simcall_file_write__getraw__result(smx_simcall_t simcall) +static inline sg_size_t simcall_storage_write__getraw__result(smx_simcall_t simcall) { return simgrid::simix::unmarshal_raw(simcall->result); } -static inline void simcall_file_write__set__result(smx_simcall_t simcall, sg_size_t result) +static inline void simcall_storage_write__set__result(smx_simcall_t simcall, sg_size_t result) { simgrid::simix::marshal(simcall->result, result); } @@ -1381,6 +1381,6 @@ XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t con XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout); XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem); XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout); -XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size); -XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size); +XBT_PRIVATE void simcall_HANDLER_storage_read(smx_simcall_t simcall, surf_storage_t st, sg_size_t size); +XBT_PRIVATE void simcall_HANDLER_storage_write(smx_simcall_t simcall, surf_storage_t st, sg_size_t size); XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max); \ No newline at end of file diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index f9422519d0..dd9b622781 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -232,18 +232,18 @@ inline static void simcall_BODY_sem_acquire_timeout(smx_sem_t sem, double timeou return simcall(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout); } -inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size) +inline static sg_size_t simcall_BODY_storage_read(surf_storage_t st, sg_size_t size) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size); - return simcall(SIMCALL_FILE_READ, fd, size); + simcall_HANDLER_storage_read(&SIMIX_process_self()->simcall, st, size); + return simcall(SIMCALL_STORAGE_READ, st, size); } -inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size) +inline static sg_size_t simcall_BODY_storage_write(surf_storage_t st, sg_size_t size) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size); - return simcall(SIMCALL_FILE_WRITE, fd, size); + simcall_HANDLER_storage_write(&SIMIX_process_self()->simcall, st, size); + return simcall(SIMCALL_STORAGE_WRITE, st, size); } inline static int simcall_BODY_mc_random(int min, int max) diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 8e44e9752a..e2a7c49e97 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -47,10 +47,11 @@ typedef enum { SIMCALL_COND_BROADCAST, SIMCALL_SEM_ACQUIRE, SIMCALL_SEM_ACQUIRE_TIMEOUT, - SIMCALL_FILE_READ, - SIMCALL_FILE_WRITE, + SIMCALL_STORAGE_READ, + SIMCALL_STORAGE_WRITE, SIMCALL_MC_RANDOM, SIMCALL_SET_CATEGORY, SIMCALL_RUN_KERNEL, - SIMCALL_RUN_BLOCKING, NUM_SIMCALLS + SIMCALL_RUN_BLOCKING, + NUM_SIMCALLS } e_smx_simcall_t; diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 13531f7a2c..1d6a4a6ddc 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -53,8 +53,8 @@ const char* simcall_names[] = { "SIMCALL_COND_BROADCAST", "SIMCALL_SEM_ACQUIRE", "SIMCALL_SEM_ACQUIRE_TIMEOUT", - "SIMCALL_FILE_READ", - "SIMCALL_FILE_WRITE", + "SIMCALL_STORAGE_READ", + "SIMCALL_STORAGE_WRITE", "SIMCALL_MC_RANDOM", "SIMCALL_SET_CATEGORY", "SIMCALL_RUN_KERNEL", @@ -197,12 +197,14 @@ case SIMCALL_SEM_ACQUIRE_TIMEOUT: simcall_HANDLER_sem_acquire_timeout(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); break; -case SIMCALL_FILE_READ: - simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); +case SIMCALL_STORAGE_READ: + simcall_HANDLER_storage_read(simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1])); break; -case SIMCALL_FILE_WRITE: - simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); +case SIMCALL_STORAGE_WRITE: + simcall_HANDLER_storage_write(simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1])); break; case SIMCALL_MC_RANDOM: diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 83970631aa..99e748f348 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -70,8 +70,8 @@ void cond_broadcast(smx_cond_t cond) [[nohandler]]; void sem_acquire(smx_sem_t sem) [[block]]; void sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]]; -sg_size_t file_read(surf_file_t fd, sg_size_t size) [[block]]; -sg_size_t file_write(surf_file_t fd, sg_size_t size) [[block]]; +sg_size_t storage_read(surf_storage_t st, sg_size_t size) [[block]]; +sg_size_t storage_write(surf_storage_t st, sg_size_t size) [[block]]; int mc_random(int min, int max); void set_category(boost::intrusive_ptr synchro, const char* category) [[nohandler]]; diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index dc044778f3..1f35bf2e57 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -21,18 +21,17 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)"); -//SIMIX FILE READ -void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size) +void simcall_HANDLER_storage_read(smx_simcall_t simcall, surf_storage_t st, sg_size_t size) { - smx_activity_t synchro = SIMIX_file_read(fd, size); + smx_activity_t synchro = SIMIX_storage_read(st, size); synchro->simcalls.push_back(simcall); simcall->issuer->waiting_synchro = synchro; } -smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size) +smx_activity_t SIMIX_storage_read(surf_storage_t st, sg_size_t size) { simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl(); - synchro->surf_io = file->read(size); + synchro->surf_io = st->read(size); synchro->surf_io->setData(synchro); XBT_DEBUG("Create io synchro %p", synchro); @@ -40,18 +39,17 @@ smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size) return synchro; } -//SIMIX FILE WRITE -void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size) +void simcall_HANDLER_storage_write(smx_simcall_t simcall, surf_storage_t st, sg_size_t size) { - smx_activity_t synchro = SIMIX_file_write(fd, size); + smx_activity_t synchro = SIMIX_storage_write(st, size); synchro->simcalls.push_back(simcall); simcall->issuer->waiting_synchro = synchro; } -smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size) +smx_activity_t SIMIX_storage_write(surf_storage_t st, sg_size_t size) { simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl(); - synchro->surf_io = file->write(size); + synchro->surf_io = st->write(size); synchro->surf_io->setData(synchro); XBT_DEBUG("Create io synchro %p", synchro); diff --git a/src/simix/smx_io_private.hpp b/src/simix/smx_io_private.hpp index 05846b7350..79581a8ac8 100644 --- a/src/simix/smx_io_private.hpp +++ b/src/simix/smx_io_private.hpp @@ -11,8 +11,8 @@ #include "popping_private.hpp" #include "simgrid/simix.h" -XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size); -XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size); +XBT_PRIVATE smx_activity_t SIMIX_storage_read(surf_storage_t fd, sg_size_t size); +XBT_PRIVATE smx_activity_t SIMIX_storage_write(surf_storage_t fd, sg_size_t size); XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro); XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro); diff --git a/src/surf/FileImpl.cpp b/src/surf/FileImpl.cpp index d190065cb0..4a85e3de8e 100644 --- a/src/surf/FileImpl.cpp +++ b/src/surf/FileImpl.cpp @@ -27,37 +27,6 @@ FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_ } } -Action* FileImpl::read(sg_size_t size) -{ - XBT_DEBUG("READ %s on disk '%s'", getCname(), location_->getCname()); - if (current_position_ + size > size_) { - if (current_position_ > size_) { - size = 0; - } else { - size = size_ - current_position_; - } - current_position_ = size_; - } else - current_position_ += size; - - return location_->read(size); -} - -Action* FileImpl::write(sg_size_t size) -{ - XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getCname(), location_->getCname(), size, size_); - - StorageAction* action = location_->write(size); - action->file_ = this; - /* Substract the part of the file that might disappear from the used sized on the storage element */ - location_->usedSize_ -= (size_ - current_position_); - // If the storage is full before even starting to write - if (location_->usedSize_ >= location_->getSize()) { - action->setState(Action::State::failed); - } - return action; -} - int FileImpl::seek(sg_offset_t offset, int origin) { switch (origin) { diff --git a/src/surf/FileImpl.hpp b/src/surf/FileImpl.hpp index acb8f27bd5..b7acf366a4 100644 --- a/src/surf/FileImpl.hpp +++ b/src/surf/FileImpl.hpp @@ -29,8 +29,6 @@ public: int seek(sg_offset_t offset, int origin); int unlink(); void move(std::string fullpath); - Action* read(sg_size_t size); - Action* write(sg_size_t size); private: StorageImpl* location_; diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index b5f52e1f93..2c45054911 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -205,7 +205,6 @@ public: e_surf_action_storage_type_t type_; StorageImpl* storage_; - FileImpl* file_ = nullptr; }; class StorageType { diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 722968594a..2bbfd748bb 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -86,11 +86,6 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) action->updateRemains(current_progress); if (action->type_ == WRITE) { action->storage_->usedSize_ += current_progress; - action->file_->incrPosition(current_progress); - action->file_->setSize(action->file_->tell()); - - action->storage_->getContent()->erase(action->file_->getCname()); - action->storage_->getContent()->insert({action->file_->getCname(), action->file_->size()}); } if (action->getMaxDuration() > NO_MAX_DURATION)