]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix the mem leak of RepGather 10760/head
authorKefu Chai <kchai@redhat.com>
Mon, 25 Jul 2016 03:12:14 +0000 (11:12 +0800)
committerLoic Dachary <ldachary@redhat.com>
Wed, 17 Aug 2016 15:47:35 +0000 (17:47 +0200)
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<RepGather>() 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<std::function<void ()>>&&)`.

Fixes: http://tracker.ceph.com/issues/16801
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit d3a28465fc7b7002f38cff364fdf601f7486add3)

src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 5e8af4eaa205f8cb6bf1d4e3746b844ec48dce33..6dfa97b7cb0bc346ab66c827f7ff3e002a243a22 100644 (file)
@@ -8530,7 +8530,7 @@ ReplicatedPG::RepGather *ReplicatedPG::new_repop(
   return repop;
 }
 
-ReplicatedPG::RepGather *ReplicatedPG::new_repop(
+boost::intrusive_ptr<ReplicatedPG::RepGather> ReplicatedPG::new_repop(
   ObcLockManager &&manager,
   boost::optional<std::function<void(void)> > &&on_complete)
 {
@@ -8543,11 +8543,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<RepGather>(repop);
 }
  
 void ReplicatedPG::remove_repop(RepGather *repop)
index 47a6a1613d3a66126770aac545e1bb514a47ac63..cfbfbe51462614f8fe9bf9557921a2cce98646df 100644 (file)
@@ -878,7 +878,7 @@ protected:
     OpContext *ctx,
     ObjectContextRef obc,
     ceph_tid_t rep_tid);
-  RepGather *new_repop(
+  boost::intrusive_ptr<RepGather> new_repop(
     ObcLockManager &&manager,
     boost::optional<std::function<void(void)> > &&on_complete);
   void remove_repop(RepGather *repop);