From 754a245d597c122f56ff0e39b50d778d2de58eab Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 24 Aug 2014 11:04:59 +0300 Subject: [PATCH] Implement file::flush() --- reactor.cc | 9 +++++++++ reactor.hh | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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; };