From a1401847eb218a844b700e5605b5324bd10cc6d1 Mon Sep 17 00:00:00 2001 From: Tao Ning Date: Wed, 14 Aug 2019 21:07:46 +0800 Subject: [PATCH] osd/PrimaryLogPG: Avoid accessing destroyed references in finish_degraded_object 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::iterator i = objects_blocked_on_degraded_snap.find( oid.get_head()); // Access ... } Fixes: https://tracker.ceph.com/issues/41250 Signed-off-by: Tao Ning (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 | 2 +- src/osd/PrimaryLogPG.cc | 2 +- src/osd/PrimaryLogPG.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index b48cbfb1bd4af..b9641a5305c7b 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -108,7 +108,7 @@ typedef std::shared_ptr OSDMapRef; virtual void failed_push(const list &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; diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index c034383c9f22c..d2d69c46f7a1c 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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)) { diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index acb1a7e29182b..b0fee77c91c00 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -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 ; -- 2.39.5