From 4752c649dca82264c6f54abbddf066fc6ab4f341 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 10 Jul 2017 10:08:47 +0200 Subject: [PATCH] closing a file is a noop. No need to deep down the stack --- include/simgrid/simix.h | 1 - src/kernel/activity/SynchroIo.cpp | 4 ---- src/s4u/s4u_file.cpp | 2 +- src/simix/libsmx.cpp | 9 -------- src/simix/popping_accessors.h | 37 ------------------------------- src/simix/popping_bodies.cpp | 7 ------ src/simix/popping_enum.h | 1 - src/simix/popping_generated.cpp | 6 ----- src/simix/simcalls.in | 1 - src/simix/smx_io.cpp | 22 ------------------ src/surf/HostImpl.cpp | 7 ------ src/surf/HostImpl.hpp | 8 ------- src/surf/StorageImpl.hpp | 8 ------- src/surf/storage_n11.cpp | 9 +------- src/surf/storage_n11.hpp | 1 - 15 files changed, 2 insertions(+), 121 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 287817dea3..8c57c13cc4 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -292,7 +292,6 @@ XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem); XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host); XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host); XBT_PUBLIC(surf_file_t) simcall_file_open(const char* mount, const char* path, sg_storage_t st); -XBT_PUBLIC(int) simcall_file_close(surf_file_t fd, sg_host_t host); /************************** 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 cccfbce23e..d09bd1ddeb 100644 --- a/src/kernel/activity/SynchroIo.cpp +++ b/src/kernel/activity/SynchroIo.cpp @@ -30,10 +30,6 @@ void simgrid::kernel::activity::IoImpl::post() simcall_file_open__set__result(simcall, tmp); break; } - case SIMCALL_FILE_CLOSE: - delete simcall_file_close__get__fd(simcall); - simcall_file_close__set__result(simcall, 0); - break; case SIMCALL_FILE_WRITE: simcall_file_write__set__result(simcall, surf_io->getCost()); break; diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index 37b4f3ae48..4ebf68f9ff 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -50,7 +50,7 @@ File::File(const char* fullpath, sg_host_t host, void* userdata) : path_(fullpat File::~File() { - simcall_file_close(pimpl_, host_); + simgrid::simix::kernelImmediate([this] { delete pimpl_; }); } sg_size_t File::read(sg_size_t size) diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index c05655a657..a8b1a010cc 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -632,15 +632,6 @@ surf_file_t simcall_file_open(const char* mount, const char* path, sg_storage_t return simcall_BODY_file_open(mount, path, st); } -/** - * \ingroup simix_file_management - * - */ -int simcall_file_close(surf_file_t fd, sg_host_t host) -{ - return simcall_BODY_file_close(fd, host); -} - void simcall_run_kernel(std::function const& code) { simcall_BODY_run_kernel(&code); diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 541c4712f5..71c0857eee 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -1601,42 +1601,6 @@ static inline void simcall_file_open__set__result(smx_simcall_t simcall, surf_fi simgrid::simix::marshal(simcall->result, result); } -static inline surf_file_t simcall_file_close__get__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline surf_file_t simcall_file_close__getraw__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_file_close__set__fd(smx_simcall_t simcall, surf_file_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_host_t simcall_file_close__get__host(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline sg_host_t simcall_file_close__getraw__host(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_file_close__set__host(smx_simcall_t simcall, sg_host_t arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} -static inline int simcall_file_close__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline int simcall_file_close__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_file_close__set__result(smx_simcall_t simcall, int result){ - simgrid::simix::marshal(simcall->result, result); -} - static inline int simcall_mc_random__get__min(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1777,5 +1741,4 @@ XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_ XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host); XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host); XBT_PRIVATE void simcall_HANDLER_file_open(smx_simcall_t simcall, const char* mount, const char* path, sg_storage_t st); -XBT_PRIVATE void simcall_HANDLER_file_close(smx_simcall_t simcall, surf_file_t fd, sg_host_t host); 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 fb5b80dcdc..3d8785c61d 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -336,13 +336,6 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) { return simcall(SIMCALL_FILE_OPEN, mount, path, st); } - inline static int simcall_BODY_file_close(surf_file_t fd, sg_host_t host) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_file_close(&SIMIX_process_self()->simcall, fd, host); - return simcall(SIMCALL_FILE_CLOSE, fd, host); - } - inline static int simcall_BODY_mc_random(int min, int max) { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall, min, max); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 262f662fc9..4317f36191 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -61,7 +61,6 @@ typedef enum { SIMCALL_FILE_READ, SIMCALL_FILE_WRITE, SIMCALL_FILE_OPEN, - SIMCALL_FILE_CLOSE, SIMCALL_MC_RANDOM, SIMCALL_SET_CATEGORY, SIMCALL_RUN_KERNEL, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index da1b8b47c7..d9ee96208d 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -67,7 +67,6 @@ const char* simcall_names[] = { "SIMCALL_FILE_READ", "SIMCALL_FILE_WRITE", "SIMCALL_FILE_OPEN", - "SIMCALL_FILE_CLOSE", "SIMCALL_MC_RANDOM", "SIMCALL_SET_CATEGORY", "SIMCALL_RUN_KERNEL", @@ -331,11 +330,6 @@ case SIMCALL_FILE_OPEN: simgrid::simix::unmarshal(simcall->args[2])); break; -case SIMCALL_FILE_CLOSE: - simcall_HANDLER_file_close(simcall, simgrid::simix::unmarshal(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1])); - break; - case SIMCALL_MC_RANDOM: simgrid::simix::marshal(simcall->result, simcall_HANDLER_mc_random(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]))); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index f015038774..109f207406 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -84,7 +84,6 @@ int sem_get_capacity(smx_sem_t sem); sg_size_t file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]]; sg_size_t file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]]; surf_file_t file_open(const char* mount, const char* path, sg_storage_t st) [[block]]; -int file_close(surf_file_t fd, sg_host_t host) [[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 5bc58f7017..0287a64218 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -89,28 +89,6 @@ smx_activity_t SIMIX_file_open(const char* mount, const char* path, sg_storage_t return synchro; } -//SIMIX FILE CLOSE -void simcall_HANDLER_file_close(smx_simcall_t simcall, surf_file_t fd, sg_host_t host) -{ - smx_activity_t synchro = SIMIX_file_close(fd, host); - synchro->simcalls.push_back(simcall); - simcall->issuer->waiting_synchro = synchro; -} - -smx_activity_t SIMIX_file_close(surf_file_t file, sg_host_t host) -{ - if (host->isOff()) - THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname()); - - simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl(); - synchro->host = host; - synchro->surf_io = host->pimpl_->close(file); - synchro->surf_io->setData(synchro); - XBT_DEBUG("Create io synchro %p", synchro); - - return synchro; -} - void SIMIX_io_destroy(smx_activity_t synchro) { simgrid::kernel::activity::IoImplPtr io = boost::static_pointer_cast(synchro); diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index f14700b3d3..f2012bf066 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -116,13 +116,6 @@ 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()); diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index c8c36cdc15..73d033c5f8 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -72,14 +72,6 @@ public: /** @brief Get the xbt_dynar_t of storages attached to the Host */ virtual void getAttachedStorageList(std::vector* storages); - /** - * @brief Close a file - * - * @param fd The file descriptor to close - * @return The StorageAction corresponding to the closing - */ - virtual Action* close(surf_file_t fd); - /** * @brief Read a file * diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index 69f0026970..8a1d515beb 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -119,14 +119,6 @@ public: */ virtual StorageAction* open(const char* mount, const char* path) = 0; - /** - * @brief Close a file - * - * @param fd The file descriptor to close - * @return The StorageAction corresponding to the closing - */ - virtual StorageAction* close(surf_file_t fd) = 0; - /** * @brief Read a file * diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index a370475170..e430af2649 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -158,13 +158,6 @@ StorageAction *StorageN11::open(const char* mount, const char* path) return action; } -StorageAction *StorageN11::close(surf_file_t fd) -{ - XBT_DEBUG("\tClose file '%s' size '%llu'", fd->cname(), fd->size()); - StorageAction* action = new StorageN11Action(model(), 0, isOff(), this, CLOSE); - return action; -} - StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size) { if (fd->tell() + size > fd->size()) { @@ -211,7 +204,7 @@ StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, Stora lmm_expand(model->getMaxminSystem(), storage->constraint(), getVariable(), 1.0); switch(type) { case OPEN: - case CLOSE: + break; case READ: lmm_expand(model->getMaxminSystem(), storage->constraintRead_, getVariable(), 1.0); break; diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 4ee60a53a2..bb7e0eeab4 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -45,7 +45,6 @@ public: const char* type_id, char* content_name, sg_size_t size, char* attach); virtual ~StorageN11() = default; StorageAction *open(const char* mount, const char* path); - StorageAction *close(surf_file_t fd); 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); -- 2.20.1