]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD:memory leak in ReplicatedPG.cc 7357/head
authorBin Zheng <zhengbin.08747@h3c.com>
Tue, 26 Jan 2016 10:41:12 +0000 (05:41 -0500)
committerBin Zheng <zhengbin.08747@h3c.com>
Sun, 31 Jan 2016 08:21:44 +0000 (03:21 -0500)
"return NULL" in "if (p == snapset.clones.end())" can not free the
memory of "*repop"

Signed-off-by: Bin Zheng <zhengbin.08747@h3c.com>
src/osd/ReplicatedPG.cc

index 4d5c94db46b57490908c53164b53eaa2ed7d821e..e873879ad434c3d6e84deddd5df7f2a2632f0a38 100644 (file)
@@ -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<snapid_t> new_snaps;
   for (set<snapid_t>::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<snapid_t>::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<snapid_t>::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()) {