]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #include <errno.h> |
2 | ||
31f18b77 | 3 | #include "cls/refcount/cls_refcount_client.h" |
7c673cae FG |
4 | #include "cls/refcount/cls_refcount_ops.h" |
5 | #include "include/rados/librados.hpp" | |
6 | ||
7 | using namespace librados; | |
8 | ||
9 | ||
10 | void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref) | |
11 | { | |
12 | bufferlist in; | |
13 | cls_refcount_get_op call; | |
14 | call.tag = tag; | |
15 | call.implicit_ref = implicit_ref; | |
11fdf7f2 | 16 | encode(call, in); |
7c673cae FG |
17 | op.exec("refcount", "get", in); |
18 | } | |
19 | ||
20 | void cls_refcount_put(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref) | |
21 | { | |
22 | bufferlist in; | |
23 | cls_refcount_put_op call; | |
24 | call.tag = tag; | |
25 | call.implicit_ref = implicit_ref; | |
11fdf7f2 | 26 | encode(call, in); |
7c673cae FG |
27 | op.exec("refcount", "put", in); |
28 | } | |
29 | ||
30 | void cls_refcount_set(librados::ObjectWriteOperation& op, list<string>& refs) | |
31 | { | |
32 | bufferlist in; | |
33 | cls_refcount_set_op call; | |
34 | call.refs = refs; | |
11fdf7f2 | 35 | encode(call, in); |
7c673cae FG |
36 | op.exec("refcount", "set", in); |
37 | } | |
38 | ||
39 | int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list<string> *refs, bool implicit_ref) | |
40 | { | |
41 | bufferlist in, out; | |
42 | cls_refcount_read_op call; | |
43 | call.implicit_ref = implicit_ref; | |
11fdf7f2 | 44 | encode(call, in); |
7c673cae FG |
45 | int r = io_ctx.exec(oid, "refcount", "read", in, out); |
46 | if (r < 0) | |
47 | return r; | |
48 | ||
49 | cls_refcount_read_ret ret; | |
50 | try { | |
11fdf7f2 TL |
51 | auto iter = out.cbegin(); |
52 | decode(ret, iter); | |
7c673cae FG |
53 | } catch (buffer::error& err) { |
54 | return -EIO; | |
55 | } | |
56 | ||
57 | *refs = ret.refs; | |
58 | ||
59 | return r; | |
60 | } | |
11fdf7f2 | 61 |