From: Kefu Chai Date: Wed, 4 Nov 2020 09:50:15 +0000 (+0800) Subject: crimson/osd: let OmapIterator mutators return future<> X-Git-Tag: v16.1.0~688^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=02334cd0e49d1fda7daff58e2f3b31a4dca3bf07;p=ceph.git crimson/osd: let OmapIterator mutators return future<> instead of returning future where the int represents an errno which is not checked by any callers, we should just return a future<>, we could erroratorize it later on, but returning an int is not the right way to handle this, and it is not consistent with how we handle other errors elsewhere in crimson. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 8fe779161be5..56bf63fb8f5c 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -501,33 +501,45 @@ seastar::future AlienStore::get_omap_iterator( //TODO: each iterator op needs one submit, this is not efficient, // needs further optimization. -seastar::future AlienStore::AlienOmapIterator::seek_to_first() +seastar::future<> AlienStore::AlienOmapIterator::seek_to_first() { return store->tp->submit([=] { return iter->seek_to_first(); + }).then([] (int r) { + assert(r == 0); + return seastar::now(); }); } -seastar::future AlienStore::AlienOmapIterator::upper_bound( +seastar::future<> AlienStore::AlienOmapIterator::upper_bound( const std::string& after) { return store->tp->submit([this, after] { return iter->upper_bound(after); + }).then([] (int r) { + assert(r == 0); + return seastar::now(); }); } -seastar::future AlienStore::AlienOmapIterator::lower_bound( +seastar::future<> AlienStore::AlienOmapIterator::lower_bound( const std::string& to) { return store->tp->submit([this, to] { return iter->lower_bound(to); + }).then([] (int r) { + assert(r == 0); + return seastar::now(); }); } -seastar::future AlienStore::AlienOmapIterator::next() +seastar::future<> AlienStore::AlienOmapIterator::next() { return store->tp->submit([this] { return iter->next(); + }).then([] (int r) { + assert(r == 0); + return seastar::now(); }); } diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index 55d0cda55834..9238c4df548b 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -25,11 +25,11 @@ public: public: AlienOmapIterator(ObjectMap::ObjectMapIterator& it, AlienStore* store) : iter(it), store(store) {} - seastar::future seek_to_first(); - seastar::future upper_bound(const std::string& after); - seastar::future lower_bound(const std::string& to); + seastar::future<> seek_to_first(); + seastar::future<> upper_bound(const std::string& after); + seastar::future<> lower_bound(const std::string& to); bool valid() const; - seastar::future next(); + seastar::future<> next(); std::string key(); seastar::future tail_key(); ceph::buffer::list value(); diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index 03d59d77cfd2..645a75340b08 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -802,22 +802,22 @@ CyanStore::stat( return seastar::make_ready_future(std::move(st)); } -seastar::future CyanStore::CyanOmapIterator::seek_to_first() +seastar::future<> CyanStore::CyanOmapIterator::seek_to_first() { iter = obj->omap.begin(); - return seastar::make_ready_future(0); + return seastar::make_ready_future<>(); } -seastar::future CyanStore::CyanOmapIterator::upper_bound(const std::string& after) +seastar::future<> CyanStore::CyanOmapIterator::upper_bound(const std::string& after) { iter = obj->omap.upper_bound(after); - return seastar::make_ready_future(0); + return seastar::make_ready_future<>(); } -seastar::future CyanStore::CyanOmapIterator::lower_bound(const std::string &to) +seastar::future<> CyanStore::CyanOmapIterator::lower_bound(const std::string &to) { iter = obj->omap.lower_bound(to); - return seastar::make_ready_future(0); + return seastar::make_ready_future<>(); } bool CyanStore::CyanOmapIterator::valid() const @@ -825,10 +825,10 @@ bool CyanStore::CyanOmapIterator::valid() const return iter != obj->omap.end(); } -seastar::future CyanStore::CyanOmapIterator::next() +seastar::future<> CyanStore::CyanOmapIterator::next() { ++iter; - return seastar::make_ready_future(0); + return seastar::make_ready_future<>(); } } diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 2c773211af1b..0dc9ddef271e 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -42,15 +42,15 @@ public: CyanOmapIterator(ObjectRef obj) : obj(obj) { iter = obj->omap.begin(); } - virtual seastar::future seek_to_first(); - virtual seastar::future upper_bound(const std::string &after); - virtual seastar::future lower_bound(const std::string &to); + virtual seastar::future<> seek_to_first(); + virtual seastar::future<> upper_bound(const std::string &after); + virtual seastar::future<> lower_bound(const std::string &to); virtual bool valid() const; - virtual seastar::future next(); + virtual seastar::future<> next(); virtual std::string key() { return iter->first; } - virtual seastar::future tail_key() { + virtual seastar::future tail_key(){ return seastar::make_ready_future((++obj->omap.end())->first); } virtual ceph::buffer::list value() { diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index dd41f9c04934..d7f3d585426b 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -28,20 +28,20 @@ class FuturizedStore { public: class OmapIterator { public: - virtual seastar::future seek_to_first() { - return seastar::make_ready_future(0); + virtual seastar::future<> seek_to_first() { + return seastar::make_ready_future<>(); } - virtual seastar::future upper_bound(const std::string &after) { - return seastar::make_ready_future(0); + virtual seastar::future<> upper_bound(const std::string &after) { + return seastar::make_ready_future<>(); } - virtual seastar::future lower_bound(const std::string &to) { - return seastar::make_ready_future(0); + virtual seastar::future<> lower_bound(const std::string &to) { + return seastar::make_ready_future<>(); } virtual bool valid() const { return false; } - virtual seastar::future next() { - return seastar::make_ready_future(0); + virtual seastar::future<> next() { + return seastar::make_ready_future<>(); } virtual std::string key() { return {}; diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc index 03ffda209b6e..0040ea209502 100644 --- a/src/crimson/osd/replicated_recovery_backend.cc +++ b/src/crimson/osd/replicated_recovery_backend.cc @@ -529,7 +529,7 @@ ReplicatedRecoveryBackend::read_omap_for_push_op( return seastar::make_ready_future<>(); } return omap_iter->lower_bound(progress.omap_recovered_to).then( - [omap_iter, &new_progress, &max_len, push_op](int ret) { + [omap_iter, &new_progress, &max_len, push_op] { return seastar::repeat([omap_iter, &new_progress, &max_len, push_op] { if (!omap_iter->valid()) { new_progress.omap_complete = true; @@ -552,7 +552,7 @@ ReplicatedRecoveryBackend::read_omap_for_push_op( } else { max_len = 0; } - return omap_iter->next().then([](int r) { + return omap_iter->next().then([] { return seastar::stop_iteration::no; }); }); diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index cea890a4c691..4dbc351476b2 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -1747,7 +1747,7 @@ public: seastar::stop_iteration::yes); } process_entry(iter); - return iter->next().then([](int) { + return iter->next().then([] { return seastar::stop_iteration::no; }); });