diff --git a/reactor.cc b/reactor.cc index fcca98f1b7..676b70d481 100644 --- a/reactor.cc +++ b/reactor.cc @@ -189,6 +189,15 @@ reactor::open_file_dma(sstring name) { }); } +future<> +reactor::flush(file& f) { + return _thread_pool.submit>([&f] { + return wrap_syscall(::fsync(f._fd)); + }).then([] (syscall_result sr) { + assert(sr.result != -1); + return make_ready_future<>(); + }); +} void reactor::run() { std::vector> current_tasks; diff --git a/reactor.hh b/reactor.hh index 2bd3fecb3e..6e4a6a9222 100644 --- a/reactor.hh +++ b/reactor.hh @@ -423,6 +423,7 @@ public: future write_all(pollable_fd_state& fd, const void* buffer, size_t size); future open_file_dma(sstring name); + future<> flush(file& f); void run(); @@ -603,7 +604,9 @@ public: return the_reactor.write_dma(*this, pos, std::move(iov)); } - future<> flush(); + future<> flush() { + return the_reactor.flush(*this); + } friend class reactor; };