From 198b156ce6153c0f390ceadb3ea237ade16d135f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Dec 2015 10:16:19 -0500 Subject: [PATCH] os/bluestore/BlueFS: wait for flush aios to complete before returning This makes all the IOs effectively synchronous (while holding the lock), which isn't great, but at least it's correct. We can contemplate async later.. Signed-off-by: Sage Weil --- src/os/bluestore/BlueFS.cc | 13 +++++++++++++ src/os/bluestore/BlueFS.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index ad2c1dd34aac5..3b9fe80ad63ef 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -986,9 +986,22 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length) } } dout(20) << __func__ << " h " << h << " pos now " << h->pos << dendl; + _flush_wait(h); return 0; } +void BlueFS::_flush_wait(FileWriter *h) +{ + dout(10) << __func__ << " " << h << dendl; + utime_t start = ceph_clock_now(NULL); + for (auto p : h->iocv) { + p->aio_wait(); + } + utime_t end = ceph_clock_now(NULL); + utime_t dur = end - start; + dout(10) << __func__ << " " << h << " done in " << dur << dendl; +} + int BlueFS::_flush(FileWriter *h, bool force) { uint64_t length = h->buffer.length(); diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 85b6638b9a22f..11d101c3e9c07 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -193,6 +193,7 @@ private: int _allocate(unsigned bdev, uint64_t len, vector *ev); int _flush_range(FileWriter *h, uint64_t offset, uint64_t length); int _flush(FileWriter *h, bool force); + void _flush_wait(FileWriter *h); void _fsync(FileWriter *h); int _flush_log(); -- 2.39.5