From: Kefu Chai Date: Mon, 25 Jul 2016 03:12:14 +0000 (+0800) Subject: osd: fix the mem leak of RepGather X-Git-Tag: ses5-milestone5~306^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F10423%2Fhead;p=ceph.git osd: fix the mem leak of RepGather ReplicatedPG::new_repop() returns a pointer to RepGather with two refcounts, one is held by ReplicatedPG::repop_queue, the other is supposed to be held by the caller of this function. but it's caller ReplicatedPG::submit_log_entries() assigns it to a boost::intrusive_ptr() directly, why by default add_ref() in its constructor. this makes the refcount 3. that's why we have a leak of RepGather in `ReplicatedPG::new_repop(ObcLockManager&&, boost::optional>&&)`. Fixes: http://tracker.ceph.com/issues/16801 Signed-off-by: Kefu Chai --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 62a766fb930..b0aa968e346 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -8619,7 +8619,7 @@ ReplicatedPG::RepGather *ReplicatedPG::new_repop( return repop; } -ReplicatedPG::RepGather *ReplicatedPG::new_repop( +boost::intrusive_ptr ReplicatedPG::new_repop( ObcLockManager &&manager, boost::optional > &&on_complete) { @@ -8632,11 +8632,10 @@ ReplicatedPG::RepGather *ReplicatedPG::new_repop( repop->start = ceph_clock_now(cct); repop_queue.push_back(&repop->queue_item); - repop->get(); osd->logger->inc(l_osd_op_wip); - return repop; + return boost::intrusive_ptr(repop); } void ReplicatedPG::remove_repop(RepGather *repop) diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 3fe75339b54..d1f2a3f141f 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -893,7 +893,7 @@ protected: OpContext *ctx, ObjectContextRef obc, ceph_tid_t rep_tid); - RepGather *new_repop( + boost::intrusive_ptr new_repop( ObcLockManager &&manager, boost::optional > &&on_complete); void remove_repop(RepGather *repop);