Skip to content

Commit

Permalink
osd: fix the mem leak of RepGather
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tchaikov committed Jul 25, 2016
1 parent 16ce830 commit d3a2846
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/osd/ReplicatedPG.cc
Expand Up @@ -8619,7 +8619,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)
{
Expand All @@ -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<RepGather>(repop);
}

void ReplicatedPG::remove_repop(RepGather *repop)
Expand Down
2 changes: 1 addition & 1 deletion src/osd/ReplicatedPG.h
Expand Up @@ -893,7 +893,7 @@ class ReplicatedPG : public PG, public PGBackend::Listener {
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);
Expand Down

0 comments on commit d3a2846

Please sign in to comment.