]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: Avoid accessing destroyed references in finish_degraded_object 29994/head
authorTao Ning <ningtao@sangfor.com.cn>
Wed, 14 Aug 2019 13:07:46 +0000 (21:07 +0800)
committerNathan Cutler <ncutler@suse.com>
Wed, 2 Oct 2019 08:58:15 +0000 (10:58 +0200)
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/PrimaryLogPG.h
- retained "override" in nautilus
- PrimaryLogPG derives from PGBackend::Listener in nautilus, and its
  PGBackend::Listener's only derived class. So we need to update
  PGBackend::Listener accordingly. (quoted from Kefu's mimic backport)
  NOTE: This is needed because 8a8947d2a32d6390cb17099398e7f2212660c9a1 went in
  post-nautilus and is not being backported.

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

index b48cbfb1bd4af38c4cfe18ef171d6c8a1866c715..b9641a5305c7b9b3caeece706b47188686f454e2 100644 (file)
@@ -108,7 +108,7 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
      virtual void failed_push(const list<pg_shard_t> &from,
                               const hobject_t &soid,
                               const eversion_t &need = eversion_t()) = 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 c034383c9f22cad124625f5208b2107fc35ccd82..d2d69c46f7a1c55a4c8f45f056634e36badba46f 100644 (file)
@@ -11590,7 +11590,7 @@ void PrimaryLogPG::remove_missing_object(const hobject_t &soid,
   ceph_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 acb1a7e29182b3b31ba33d55b0a2e322b01a6860..b0fee77c91c0011a0d8a3d81aca7e630ca0045ec 100644 (file)
@@ -1126,7 +1126,7 @@ protected:
                                  PGBackend::RecoveryHandle *h,
                                  bool *work_started);
 
-  void finish_degraded_object(const hobject_t& oid) override;
+  void finish_degraded_object(const hobject_t oid) override;
 
   // Cancels/resets pulls from peer
   void check_recovery_sources(const OSDMapRef& map) override ;