From 5d67bb97f77a96efed49cbac557495451cfb3247 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Mon, 19 Mar 2018 16:20:18 +0900 Subject: [PATCH] cls/refcount: add chunk_refcount_client() Signed-off-by: Myoungwon Oh --- src/cls/refcount/cls_refcount_client.cc | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/cls/refcount/cls_refcount_client.cc b/src/cls/refcount/cls_refcount_client.cc index 14da2ff2b31..d3e1aeecb47 100644 --- a/src/cls/refcount/cls_refcount_client.cc +++ b/src/cls/refcount/cls_refcount_client.cc @@ -58,3 +58,50 @@ int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list *refs, return r; } + +void cls_chunk_refcount_get(librados::ObjectWriteOperation& op, const hobject_t& soid) +{ + bufferlist in; + cls_chunk_refcount_get_op call; + call.source = soid; + encode(call, in); + op.exec("refcount", "chunk_get", in); +} + +void cls_chunk_refcount_put(librados::ObjectWriteOperation& op, const hobject_t& soid) +{ + bufferlist in; + cls_chunk_refcount_put_op call; + call.source = soid; + encode(call, in); + op.exec("refcount", "chunk_put", in); +} + +void cls_chunk_refcount_set(librados::ObjectWriteOperation& op, set& refs) +{ + bufferlist in; + cls_chunk_refcount_set_op call; + call.refs = refs; + encode(call, in); + op.exec("refcount", "chunk_set", in); +} + +int cls_chunk_refcount_read(librados::IoCtx& io_ctx, string& oid, set *refs) +{ + bufferlist in, out; + int r = io_ctx.exec(oid, "refcount", "chunk_read", in, out); + if (r < 0) + return r; + + cls_chunk_refcount_read_ret ret; + try { + bufferlist::iterator iter = out.begin(); + decode(ret, iter); + } catch (buffer::error& err) { + return -EIO; + } + + *refs = ret.refs; + + return r; +} -- 2.47.3