From: Bin Zheng Date: Tue, 26 Jan 2016 10:41:12 +0000 (-0500) Subject: OSD:memory leak in ReplicatedPG.cc X-Git-Tag: v10.0.4~74^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a17ea399dd9cf52e87fafa848ca9c3601bcf7432;p=ceph.git OSD:memory leak in ReplicatedPG.cc "return NULL" in "if (p == snapset.clones.end())" can not free the memory of "*repop" Signed-off-by: Bin Zheng --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4d5c94db46b..e873879ad43 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -3238,14 +3238,6 @@ ReplicatedPG::RepGather *ReplicatedPG::trim_object(const hobject_t &coid) return NULL; } - RepGather *repop = simple_repop_create(obc); - OpContext *ctx = repop->ctx; - ctx->snapset_obc = snapset_obc; - ctx->lock_to_release = OpContext::W_LOCK; - ctx->release_snapset_obc = true; - ctx->at_version = get_next_version(); - - PGBackend::PGTransaction *t = ctx->op_t; set new_snaps; for (set::iterator i = old_snaps.begin(); i != old_snaps.end(); @@ -3254,22 +3246,33 @@ ReplicatedPG::RepGather *ReplicatedPG::trim_object(const hobject_t &coid) new_snaps.insert(*i); } + vector::iterator p = snapset.clones.end(); + + if (new_snaps.empty()) { + p = std::find(snapset.clones.begin(), snapset.clones.end(), coid.snap); + if (p == snapset.clones.end()) { + osd->clog->error() << __func__ << " Snap " << coid.snap << " not in clones" << "\n"; + return NULL; + } + } + + RepGather *repop = simple_repop_create(obc); + OpContext *ctx = repop->ctx; + ctx->snapset_obc = snapset_obc; + ctx->lock_to_release = OpContext::W_LOCK; + ctx->release_snapset_obc = true; + ctx->at_version = get_next_version(); + PGBackend::PGTransaction *t = ctx->op_t; + if (new_snaps.empty()) { // remove clone dout(10) << coid << " snaps " << old_snaps << " -> " << new_snaps << " ... deleting" << dendl; // ...from snapset + assert(p != snapset.clones.end()); + snapid_t last = coid.snap; - vector::iterator p; - for (p = snapset.clones.begin(); p != snapset.clones.end(); ++p) - if (*p == last) - break; - if (p == snapset.clones.end()) { - osd->clog->error() << __func__ << " Snap " << coid.snap << " not in clones" << "\n"; - return NULL; - } - ctx->delta_stats.num_bytes -= snapset.get_clone_bytes(last); if (p != snapset.clones.begin()) {