summaryrefslogtreecommitdiffstats
path: root/src/cls/refcount/cls_refcount_client.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/cls/refcount/cls_refcount_client.cc
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cls/refcount/cls_refcount_client.cc')
-rw-r--r--src/cls/refcount/cls_refcount_client.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/cls/refcount/cls_refcount_client.cc b/src/cls/refcount/cls_refcount_client.cc
new file mode 100644
index 00000000..9d5210c8
--- /dev/null
+++ b/src/cls/refcount/cls_refcount_client.cc
@@ -0,0 +1,61 @@
+#include <errno.h>
+
+#include "cls/refcount/cls_refcount_client.h"
+#include "cls/refcount/cls_refcount_ops.h"
+#include "include/rados/librados.hpp"
+
+using namespace librados;
+
+
+void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref)
+{
+ bufferlist in;
+ cls_refcount_get_op call;
+ call.tag = tag;
+ call.implicit_ref = implicit_ref;
+ encode(call, in);
+ op.exec("refcount", "get", in);
+}
+
+void cls_refcount_put(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref)
+{
+ bufferlist in;
+ cls_refcount_put_op call;
+ call.tag = tag;
+ call.implicit_ref = implicit_ref;
+ encode(call, in);
+ op.exec("refcount", "put", in);
+}
+
+void cls_refcount_set(librados::ObjectWriteOperation& op, list<string>& refs)
+{
+ bufferlist in;
+ cls_refcount_set_op call;
+ call.refs = refs;
+ encode(call, in);
+ op.exec("refcount", "set", in);
+}
+
+int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list<string> *refs, bool implicit_ref)
+{
+ bufferlist in, out;
+ cls_refcount_read_op call;
+ call.implicit_ref = implicit_ref;
+ encode(call, in);
+ int r = io_ctx.exec(oid, "refcount", "read", in, out);
+ if (r < 0)
+ return r;
+
+ cls_refcount_read_ret ret;
+ try {
+ auto iter = out.cbegin();
+ decode(ret, iter);
+ } catch (buffer::error& err) {
+ return -EIO;
+ }
+
+ *refs = ret.refs;
+
+ return r;
+}
+