From 276c02b416ee2bceb0b40afb454fb4b0aacc2bb3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 29 Sep 2016 17:05:53 -0400 Subject: [PATCH] os/bluestore/BlueFS: release completed aios Signed-off-by: Sage Weil --- src/os/bluestore/BlueFS.cc | 21 ++++++++++++++++++++- src/os/bluestore/BlueFS.h | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 15c23e9996ee..4f8a8a44960f 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1344,8 +1344,11 @@ int BlueFS::_flush_and_sync_log(std::unique_lock& l, } // drop lock while we wait for io + list completed_ios; + _claim_completed_aios(log_writer, &completed_ios); l.unlock(); wait_for_aio(log_writer); + completed_ios.clear(); flush_bdev(); l.lock(); @@ -1541,8 +1544,9 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length) for (unsigned i = 0; i < MAX_BDEV; ++i) { if (bdev[i]) { assert(h->iocv[i]); - if (h->iocv[i]->has_aios()) + if (h->iocv[i]->has_aios()) { bdev[i]->aio_submit(h->iocv[i]); + } } } dout(20) << __func__ << " h " << h << " pos now 0x" @@ -1550,6 +1554,18 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length) return 0; } +// we need to retire old completed aios so they don't stick around in +// memory indefinitely (along with their bufferlist refs). +void BlueFS::_claim_completed_aios(FileWriter *h, list *ls) +{ + for (auto p : h->iocv) { + if (p) { + ls->splice(ls->end(), p->running_aios); + } + } + dout(10) << __func__ << " got " << ls->size() << " aios" << dendl; +} + void BlueFS::wait_for_aio(FileWriter *h) { // NOTE: this is safe to call without a lock, as long as our reference is @@ -1635,8 +1651,11 @@ int BlueFS::_fsync(FileWriter *h, std::unique_lock& l) if (r < 0) return r; uint64_t old_dirty_seq = h->file->dirty_seq; + list completed_ios; + _claim_completed_aios(h, &completed_ios); lock.unlock(); wait_for_aio(h); + completed_ios.clear(); lock.lock(); if (old_dirty_seq) { uint64_t s = log_seq; diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index e3862a584fc2..92260c505961 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -248,9 +248,11 @@ private: int _allocate(uint8_t bdev, uint64_t len, vector *ev); int _flush_range(FileWriter *h, uint64_t offset, uint64_t length); int _flush(FileWriter *h, bool force); - void wait_for_aio(FileWriter *h); // safe to call without a lock int _fsync(FileWriter *h, std::unique_lock& l); + void _claim_completed_aios(FileWriter *h, list *ls); + void wait_for_aio(FileWriter *h); // safe to call without a lock + int _flush_and_sync_log(std::unique_lock& l, uint64_t want_seq = 0, uint64_t jump_to = 0); -- 2.47.3