]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: make sure pg meta is valid when loading pg
authorXuehan Xu <xxhdx1985126@163.com>
Thu, 12 Mar 2020 05:53:39 +0000 (13:53 +0800)
committerXuehan Xu <xxhdx1985126@163.com>
Fri, 27 Mar 2020 03:08:30 +0000 (11:08 +0800)
currently, PGMeta instances are all local variables in method,
which would lead to daggling reference/pointer problems when using
seastar::futures.

Signed-off-by: Xuehan Xu <xxhdx1985126@163.com>
src/crimson/osd/osd.cc
src/crimson/osd/pg.cc

index 01f938535774100ca66fd3c5de07515796c2d2c2..8e6ae3ea8fbf4f8f6eac103840e829e85acf9d66 100644 (file)
@@ -549,13 +549,15 @@ seastar::future<Ref<PG>> OSD::make_pg(cached_map_t create_map,
 
 seastar::future<Ref<PG>> OSD::load_pg(spg_t pgid)
 {
-  return PGMeta{store.get(), pgid}.get_epoch().then([this](epoch_t e) {
+  return seastar::do_with(PGMeta(store.get(), pgid), [this, pgid] (auto& pg_meta) {
+    return pg_meta.get_epoch();
+  }).then([this](epoch_t e) {
     return get_map(e);
   }).then([pgid, this] (auto&& create_map) {
     return make_pg(std::move(create_map), pgid, false);
-  }).then([this, pgid](Ref<PG> pg) {
+  }).then([this](Ref<PG> pg) {
     return pg->read_state(store.get()).then([pg] {
-      return seastar::make_ready_future<Ref<PG>>(std::move(pg));
+       return seastar::make_ready_future<Ref<PG>>(std::move(pg));
     });
   }).handle_exception([pgid](auto ep) {
     logger().info("pg {} saw exception on load {}", pgid, ep);
index fcef9c45aa19281808227f501cba0c5615720510..62d5adfd0ff1d0490d18985960d290660954c96f 100644 (file)
@@ -364,8 +364,9 @@ void PG::init(
 
 seastar::future<> PG::read_state(crimson::os::FuturizedStore* store)
 {
-  return PGMeta{store, pgid}.load(
-  ).then([this, store](pg_info_t pg_info, PastIntervals past_intervals) {
+  return seastar::do_with(PGMeta(store, pgid), [this, store] (auto& pg_meta) {
+    return pg_meta.load();
+  }).then([this, store](pg_info_t pg_info, PastIntervals past_intervals) {
     return peering_state.init_from_disk_state(
        std::move(pg_info),
        std::move(past_intervals),