]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: Avoid accessing destroyed references in finish_degraded_object 30291/head
authorTao Ning <ningtao@sangfor.com.cn>
Wed, 14 Aug 2019 13:07:46 +0000 (21:07 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 10 Sep 2019 12:01:23 +0000 (20:01 +0800)
As follows:
for (auto i = callbacks_for_degraded_object.begin(); i != callbacks_for_degraded_object.end();) {
    finish_degraded_object((i++)->first);
}

void PrimaryLogPG::finish_degraded_object(const hobject_t oid)
{
  if (callbacks_for_degraded_object.count(oid)) {
    contexts.swap(callbacks_for_degraded_object[oid]);
    callbacks_for_degraded_object.erase(oid);   // Release
  }

  map<hobject_t, snapid_t>::iterator i = objects_blocked_on_degraded_snap.find(
    oid.get_head());  // Access
  ...
}

Fixes: https://tracker.ceph.com/issues/41250
Signed-off-by: Tao Ning <ningtao@sangfor.com.cn>
(cherry picked from commit 86d55c1a0ddb48efc0c1934728d27f22cf49dfa1)

Conflicts: src/osd/PGBackend.h: `PrimaryLogPG` derives from
`PGBackend::Listener` in mimic, and it's `PGBackend::Listener` 's only
derived class. so we need to update `PGBackend::Listener` accordingly.

src/osd/PGBackend.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index f8317a9da94ab105dd027ad59704b28f622cb8c0..cb4dcc46471e45b99563cea050a171946b978a50 100644 (file)
@@ -106,7 +106,7 @@ typedef ceph::shared_ptr<const OSDMap> OSDMapRef;
        const hobject_t oid) = 0;
 
      virtual void failed_push(const list<pg_shard_t> &from, const hobject_t &soid) = 0;
-     virtual void finish_degraded_object(const hobject_t& oid) = 0;
+     virtual void finish_degraded_object(const hobject_t oid) = 0;
      virtual void primary_failed(const hobject_t &soid) = 0;
      virtual bool primary_error(const hobject_t& soid, eversion_t v) = 0;
      virtual void cancel_pull(const hobject_t &soid) = 0;
index 0a0c2967fe0b1419780e34ee067c97cbc7bb05e6..6c2fe17ff451c0e2e2aaf0c3b16a688627f682a9 100644 (file)
@@ -11418,7 +11418,7 @@ void PrimaryLogPG::remove_missing_object(const hobject_t &soid,
   assert(r == 0);
 }
 
-void PrimaryLogPG::finish_degraded_object(const hobject_t& oid)
+void PrimaryLogPG::finish_degraded_object(const hobject_t oid)
 {
   dout(10) << __func__ << " " << oid << dendl;
   if (callbacks_for_degraded_object.count(oid)) {
index 24ee09067acade1437a419fe436c535bd997ada5..6c411d407b5e5e4f134f006377ef5581952c06bd 100644 (file)
@@ -1096,7 +1096,7 @@ protected:
                                  PGBackend::RecoveryHandle *h,
                                  bool *work_started);
 
-  void finish_degraded_object(const hobject_t& oid);
+  void finish_degraded_object(const hobject_t oid);
 
   // Cancels/resets pulls from peer
   void check_recovery_sources(const OSDMapRef& map) override ;