]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix reference leak when ManifestOp is released without being referenced 40879/head
authormyoungwon oh <ohmyoungwon@gmail.com>
Fri, 16 Apr 2021 02:58:57 +0000 (11:58 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Fri, 16 Apr 2021 08:05:29 +0000 (17:05 +0900)
fixes: https://tracker.ceph.com/issues/50299

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index 3ba1a62aa288e843fde02772d032561e4830ba63..df9c75270d6511d47de40ed66b4a9cab5d66237d 100644 (file)
@@ -3539,7 +3539,7 @@ bool PrimaryLogPG::inc_refcount_by_set(OpContext* ctx, object_manifest_t& set_ch
     refs);
   bool need_inc_ref = false;
   if (!refs.is_empty()) {
-    ManifestOpRef mop = std::make_shared<ManifestOp>(new RefCountCallback(ctx, osd_op));
+    ManifestOpRef mop(std::make_shared<ManifestOp>());
     for (auto c : set_chunk.chunk_map) {
       auto p = refs.find(c.second.oid);
       if (p == refs.end()) {
@@ -3578,6 +3578,7 @@ bool PrimaryLogPG::inc_refcount_by_set(OpContext* ctx, object_manifest_t& set_ch
       }
     }
     if (mop->tids.size()) {
+      mop->cb = new RefCountCallback(ctx, osd_op);
       manifest_ops[ctx->obs->oi.soid] = mop;
       manifest_ops[ctx->obs->oi.soid]->op = ctx->op;
     }
@@ -10356,7 +10357,7 @@ int PrimaryLogPG::start_dedup(OpRequestRef op, ObjectContextRef obc)
    * The operations to make dedup chunks are tracked by a ManifestOp.
    * This op will be finished if all the operations are completed.
    */
-  ManifestOpRef mop(std::make_shared<ManifestOp>(nullptr));
+  ManifestOpRef mop(std::make_shared<ManifestOp>());
 
   // cdc
   std::map<uint64_t, bufferlist> chunks; 
index 68542035a2d5e76a9e436a7a7fc337b925ebf734..f2da4f7c62dde2a967fac8eefc8f71f2c6e75e15 100644 (file)
@@ -259,8 +259,8 @@ public:
 
   friend struct RefCountCallback;
   struct ManifestOp {
-    RefCountCallback *cb;
-    ceph_tid_t objecter_tid;
+    RefCountCallback *cb = nullptr;
+    ceph_tid_t objecter_tid = 0;
     OpRequestRef op;
     std::map<uint64_t, int> results;
     std::map<uint64_t, ceph_tid_t> tids; 
@@ -270,7 +270,8 @@ public:
     
 
     ManifestOp(RefCountCallback* cb)
-      : cb(cb), objecter_tid(0) {}
+      : cb(cb) {}
+    ManifestOp() = default;
   };
   typedef std::shared_ptr<ManifestOp> ManifestOpRef;
   std::map<hobject_t, ManifestOpRef> manifest_ops;