]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: fix pglog read_log_and_missing issue 33943/head
authorXuehan Xu <xxhdx1985126@163.com>
Thu, 12 Mar 2020 06:46:09 +0000 (14:46 +0800)
committerXuehan Xu <xxhdx1985126@163.com>
Fri, 27 Mar 2020 03:08:41 +0000 (11:08 +0800)
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 <xxhdx1985126@163.com>
src/osd/PGLog.h

index 297e89d9a40ad0e3c822e9fa6455498ba45f66bb..401e114ac59d7e931135d668998942fc954fadd1 100644 (file)
@@ -1627,23 +1627,24 @@ public:
 
     std::optional<std::string> next;
 
-    void process_entry(const std::pair<std::string, ceph::bufferlist> &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<FuturizedStoreLogReader>(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>(
+                     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,