From b5767df1a819238e36797c4854d4f88d67c4f6db Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Thu, 12 Mar 2020 14:46:09 +0800 Subject: [PATCH] crimson: fix pglog read_log_and_missing issue Currently pglog's read_log_and_missing_crimson's implementation would cause null pointer exception, since at the time, we don't the key to start from Signed-off-by: Xuehan Xu --- src/osd/PGLog.h | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 297e89d9a40ad..401e114ac59d7 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -1627,23 +1627,24 @@ public: std::optional next; - void process_entry(const std::pair &p) { - if (p.first[0] == '_') + void process_entry(crimson::os::FuturizedStore::OmapIteratorRef &p) { + if (p->key()[0] == '_') return; - ceph::bufferlist bl = p.second;//Copy bufferlist before creating iterator + //Copy bufferlist before creating iterator + ceph::bufferlist bl = p->value(); auto bp = bl.cbegin(); - if (p.first == "divergent_priors") { + if (p->key() == "divergent_priors") { decode(divergent_priors, bp); ldpp_dout(dpp, 20) << "read_log_and_missing " << divergent_priors.size() << " divergent_priors" << dendl; ceph_assert("crimson shouldn't have had divergent_priors" == 0); - } else if (p.first == "can_rollback_to") { + } else if (p->key() == "can_rollback_to") { decode(on_disk_can_rollback_to, bp); - } else if (p.first == "rollback_info_trimmed_to") { + } else if (p->key() == "rollback_info_trimmed_to") { decode(on_disk_rollback_info_trimmed_to, bp); - } else if (p.first == "may_include_deletes_in_missing") { + } else if (p->key() == "may_include_deletes_in_missing") { missing.may_include_deletes = true; - } else if (p.first.substr(0, 7) == string("missing")) { + } else if (p->key().substr(0, 7) == string("missing")) { hobject_t oid; pg_missing_item item; decode(oid, bp); @@ -1652,7 +1653,7 @@ public: ceph_assert(missing.may_include_deletes); } missing.add(oid, std::move(item)); - } else if (p.first.substr(0, 4) == string("dup_")) { + } else if (p->key().substr(0, 4) == string("dup_")) { pg_log_dup_t dup; decode(dup, bp); if (!dups.empty()) { @@ -1679,18 +1680,18 @@ public: missing.may_include_deletes = false; auto reader = std::unique_ptr(this); - return seastar::repeat( - [this]() { - return store.omap_get_values(ch, pgmeta_oid, next).then( - [this]( - bool done, crimson::os::FuturizedStore::omap_values_t values) { - for (auto &&p : values) { - process_entry(p); - } - return done ? seastar::stop_iteration::yes - : seastar::stop_iteration::no; - }); - }).then([this, reader{std::move(reader)}]() { + return store.get_omap_iterator(ch, pgmeta_oid).then([this](auto iter) { + return seastar::repeat([this, iter]() mutable { + if (!iter->valid()) { + return seastar::make_ready_future( + seastar::stop_iteration::yes); + } + process_entry(iter); + return iter->next().then([](int) { + return seastar::stop_iteration::no; + }); + }); + }).then([this, reader{std::move(reader)}]() { log = IndexedLog( info.last_update, info.log_tail, -- 2.39.5