From: Tao Ning Date: Wed, 14 Aug 2019 13:07:46 +0000 (+0800) Subject: osd/PrimaryLogPG: Avoid accessing destroyed references in finish_degraded_object X-Git-Tag: v13.2.7~142^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57f2210dc868f21cddf178c838d8d349c5bf6db1;p=ceph.git 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/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. --- diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index f8317a9da94a..cb4dcc46471e 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -106,7 +106,7 @@ typedef ceph::shared_ptr OSDMapRef; const hobject_t oid) = 0; virtual void failed_push(const list &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; diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 0a0c2967fe0b..6c2fe17ff451 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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)) { diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 24ee09067aca..6c411d407b5e 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -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 ;