From 3da62cb6e9fa906efc6091cc34267e4ad6dc4c17 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Fri, 16 Apr 2021 11:58:57 +0900 Subject: [PATCH] osd: fix reference leak when ManifestOp is released without being referenced fixes: https://tracker.ceph.com/issues/50299 Signed-off-by: Myoungwon Oh --- src/osd/PrimaryLogPG.cc | 5 +++-- src/osd/PrimaryLogPG.h | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 3ba1a62aa288..df9c75270d65 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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(new RefCountCallback(ctx, osd_op)); + ManifestOpRef mop(std::make_shared()); 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(nullptr)); + ManifestOpRef mop(std::make_shared()); // cdc std::map chunks; diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 68542035a2d5..f2da4f7c62dd 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -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 results; std::map tids; @@ -270,7 +270,8 @@ public: ManifestOp(RefCountCallback* cb) - : cb(cb), objecter_tid(0) {} + : cb(cb) {} + ManifestOp() = default; }; typedef std::shared_ptr ManifestOpRef; std::map manifest_ops; -- 2.47.3