From 6d1948ceed16c209bb37d40f08695a393a095065 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Fri, 12 Jan 2018 17:24:51 +0900 Subject: [PATCH] osd: add refcount_manifest() for the object that has manifest Signed-off-by: Myoungwon Oh --- src/osd/PrimaryLogPG.cc | 30 ++++++++++++++++++++++++++++++ src/osd/PrimaryLogPG.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index a82fb107544..049b978d534 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -51,6 +51,7 @@ #include "json_spirit/json_spirit_reader.h" #include "include/assert.h" // json_spirit clobbers it #include "include/rados/rados_types.hpp" +#include "cls/refcount/cls_refcount_ops.h" #ifdef WITH_LTTNG #include "tracing/osd.h" @@ -3392,6 +3393,35 @@ void PrimaryLogPG::do_proxy_chunked_op(OpRequestRef op, const hobject_t& missing } } +void PrimaryLogPG::refcount_manifest(ObjectContextRef obc, object_locator_t oloc, hobject_t soid, + SnapContext snapc, bool get, Context *cb, uint64_t offset) +{ + unsigned flags = CEPH_OSD_FLAG_IGNORE_CACHE | CEPH_OSD_FLAG_IGNORE_OVERLAY | + CEPH_OSD_FLAG_RWORDERED; + + dout(10) << __func__ << " Start refcount for " << soid << dendl; + + ObjectOperation obj_op; + bufferlist in; + if (get) { + cls_chunk_refcount_get_op call; + call.source = obc->obs.oi.soid; + ::encode(call, in); + obj_op.call("refcount", "chunk_get", in); + } else { + cls_chunk_refcount_put_op call; + call.source = obc->obs.oi.soid; + ::encode(call, in); + obj_op.call("refcount", "chunk_put", in); + } + + unsigned n = info.pgid.hash_to_shard(osd->m_objecter_finishers); + osd->objecter->mutate( + soid.oid, oloc, obj_op, snapc, + ceph::real_clock::from_ceph_timespec(obc->obs.oi.mtime), + flags, new C_OnFinisher(cb, osd->objecter_finishers[n])); +} + void PrimaryLogPG::do_proxy_chunked_read(OpRequestRef op, ObjectContextRef obc, int op_index, uint64_t chunk_index, uint64_t req_offset, uint64_t req_length, uint64_t req_total_len, bool write_ordered) diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index e26a4b5033b..67240b1af70 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -1405,6 +1405,8 @@ protected: uint64_t last_offset); void handle_manifest_flush(hobject_t oid, ceph_tid_t tid, int r, uint64_t offset, uint64_t last_offset); + void refcount_manifest(ObjectContextRef obc, object_locator_t oloc, hobject_t soid, + SnapContext snapc, bool get, Context *cb, uint64_t offset); friend struct C_ProxyChunkRead; friend class PromoteManifestCallback; -- 2.39.5