From 7c4b3cc7fa4d466e2b7483fa0b69bfd73c8dda9b Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 14 Jan 2022 06:53:17 +0000 Subject: [PATCH] crimson/os/seastore: implement FuturizedStore::flush Signed-off-by: Samuel Just --- src/crimson/os/seastore/journal.cc | 8 ++++++++ src/crimson/os/seastore/journal.h | 12 ++++++++++++ src/crimson/os/seastore/seastore.cc | 14 ++++++++++++++ src/crimson/os/seastore/seastore.h | 4 ++++ src/crimson/os/seastore/transaction_manager.cc | 13 +++++++++++++ src/crimson/os/seastore/transaction_manager.h | 9 +++++++++ 6 files changed, 60 insertions(+) diff --git a/src/crimson/os/seastore/journal.cc b/src/crimson/os/seastore/journal.cc index c1fc6e5d89164..8e25cb58cf60a 100644 --- a/src/crimson/os/seastore/journal.cc +++ b/src/crimson/os/seastore/journal.cc @@ -605,6 +605,14 @@ Journal::RecordSubmitter::submit( return do_submit(std::move(record), handle); } +seastar::future<> Journal::RecordSubmitter::flush(OrderingHandle &handle) +{ + return handle.enter(write_pipeline->device_submission + ).then([this, &handle] { + return handle.enter(write_pipeline->finalize); + }); +} + void Journal::RecordSubmitter::update_state() { if (num_outstanding_io == 0) { diff --git a/src/crimson/os/seastore/journal.h b/src/crimson/os/seastore/journal.h index d6f18cceab296..75666f0573a88 100644 --- a/src/crimson/os/seastore/journal.h +++ b/src/crimson/os/seastore/journal.h @@ -99,6 +99,17 @@ public: return record_submitter.submit(std::move(record), handle); } + /** + * flush + * + * Wait for all outstanding IOs on handle to commit. + * Note, flush() machinery must go through the same pipeline + * stages and locks as submit_record. + */ + seastar::future<> flush(OrderingHandle &handle) { + return record_submitter.flush(handle); + } + /** * Read deltas and pass to delta_handler * @@ -392,6 +403,7 @@ private: using submit_ret = Journal::submit_record_ret; submit_ret submit(record_t&&, OrderingHandle&); + seastar::future<> flush(OrderingHandle &handle); private: void update_state(); diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index eb166b1ad3258..1a89fa79a44a4 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -925,6 +925,20 @@ seastar::future<> SeaStore::do_transaction( }); } + +seastar::future<> SeaStore::flush(CollectionRef ch) +{ + return seastar::do_with( + get_dummy_ordering_handle(), + [this, ch](auto &handle) { + return handle.take_collection_lock( + static_cast(*ch).ordering_lock + ).then([this, &handle] { + return transaction_manager->flush(handle); + }); + }); +} + SeaStore::tm_ret SeaStore::_do_transaction_step( internal_context_t &ctx, CollectionRef &col, diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index d1c325432d7ff..93e34c28801e3 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -139,6 +139,10 @@ public: CollectionRef ch, ceph::os::Transaction&& txn) final; + /* Note, flush() machinery must go through the same pipeline + * stages and locks as do_transaction. */ + seastar::future<> flush(CollectionRef ch) final; + seastar::future get_omap_iterator( CollectionRef ch, const ghobject_t& oid) final; diff --git a/src/crimson/os/seastore/transaction_manager.cc b/src/crimson/os/seastore/transaction_manager.cc index 624ae4c0d5fd5..c9dc00e4ead72 100644 --- a/src/crimson/os/seastore/transaction_manager.cc +++ b/src/crimson/os/seastore/transaction_manager.cc @@ -321,6 +321,19 @@ TransactionManager::submit_transaction_direct( }); } +seastar::future<> TransactionManager::flush(OrderingHandle &handle) +{ + return handle.enter(write_pipeline.reserve_projected_usage + ).then([this, &handle] { + return handle.enter(write_pipeline.ool_writes); + }).then([this, &handle] { + return handle.enter(write_pipeline.prepare); + }).then([this, &handle] { + handle.maybe_release_collection_lock(); + return journal->flush(handle); + }); +} + TransactionManager::get_next_dirty_extents_ret TransactionManager::get_next_dirty_extents( Transaction &t, diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h index cb3cdec8d19d4..82c825c284ca6 100644 --- a/src/crimson/os/seastore/transaction_manager.h +++ b/src/crimson/os/seastore/transaction_manager.h @@ -374,6 +374,15 @@ public: submit_transaction_direct_ret submit_transaction_direct( Transaction &t) final; + /** + * flush + * + * Block until all outstanding IOs on handle are committed. + * Note, flush() machinery must go through the same pipeline + * stages and locks as submit_transaction. + */ + seastar::future<> flush(OrderingHandle &handle); + using SegmentCleaner::ExtentCallbackInterface::get_next_dirty_extents_ret; get_next_dirty_extents_ret get_next_dirty_extents( Transaction &t, -- 2.39.5