diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/cls/cas/cls_cas_client.cc | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.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/cas/cls_cas_client.cc')
-rw-r--r-- | src/cls/cas/cls_cas_client.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/cls/cas/cls_cas_client.cc b/src/cls/cas/cls_cas_client.cc new file mode 100644 index 00000000..b041641f --- /dev/null +++ b/src/cls/cas/cls_cas_client.cc @@ -0,0 +1,62 @@ +#include <errno.h> + +#include "cls/cas/cls_cas_client.h" +#include "cls/cas/cls_cas_ops.h" +#include "include/rados/librados.hpp" + +using namespace librados; + +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("cas", "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("cas", "chunk_put", in); +} + +void cls_chunk_refcount_set(librados::ObjectWriteOperation& op, set<hobject_t>& refs) +{ + bufferlist in; + cls_chunk_refcount_set_op call; + call.refs = refs; + encode(call, in); + op.exec("cas", "chunk_set", in); +} + +int cls_chunk_refcount_read(librados::IoCtx& io_ctx, string& oid, set<hobject_t> *refs) +{ + bufferlist in, out; + int r = io_ctx.exec(oid, "cas", "chunk_read", in, out); + if (r < 0) + return r; + + cls_chunk_refcount_read_ret ret; + try { + auto iter = out.cbegin(); + decode(ret, iter); + } catch (buffer::error& err) { + return -EIO; + } + + *refs = ret.refs; + + return r; +} + +int cls_chunk_has_chunk(librados::IoCtx& io_ctx, string& oid, string& fp_oid) +{ + bufferlist in, out; + encode(fp_oid, in); + int r = io_ctx.exec(oid, "cas", "has_chunk", in, out); + return r; +} |