crimson/osd: Implement missing objclass functions used by cls_rgw

Signed-off-by: Amnon Hanuhov <ahanukov@redhat.com>
This commit is contained in:
Amnon Hanuhov 2021-07-29 16:19:48 +03:00 committed by Amnon Hanuhov
parent e816237374
commit b51f2e04e7

View File

@ -126,7 +126,22 @@ int cls_cxx_stat2(cls_method_context_t hctx,
uint64_t *size,
ceph::real_time *mtime)
{
return 0;
OSDOp op{CEPH_OSD_OP_STAT};
if (const int ret = execute_osd_op(hctx, op); ret < 0) {
return ret;
}
uint64_t dummy_size;
real_time dummy_mtime;
uint64_t& out_size = size ? *size : dummy_size;
real_time& out_mtime = mtime ? *mtime : dummy_mtime;
try {
auto iter = op.outdata.cbegin();
decode(out_size, iter);
decode(out_mtime, iter);
return 0;
} catch (buffer::error& err) {
return -EIO;
}
}
int cls_cxx_read2(cls_method_context_t hctx,
@ -228,6 +243,16 @@ int cls_cxx_getxattr(cls_method_context_t hctx,
int cls_cxx_getxattrs(cls_method_context_t hctx,
map<string, bufferlist> *attrset)
{
OSDOp op{CEPH_OSD_OP_GETXATTRS};
if (const int ret = execute_osd_op(hctx, op); ret < 0) {
return ret;
}
try {
auto iter = op.outdata.cbegin();
decode(*attrset, iter);
} catch (buffer::error& err) {
return -EIO;
}
return 0;
}
@ -381,7 +406,8 @@ int cls_cxx_map_set_vals(cls_method_context_t hctx,
int cls_cxx_map_clear(cls_method_context_t hctx)
{
return 0;
OSDOp op{CEPH_OSD_OP_OMAPCLEAR};
return execute_osd_op(hctx, op);
}
int cls_cxx_map_write_header(cls_method_context_t hctx, bufferlist *inbl)
@ -403,7 +429,10 @@ int cls_cxx_map_remove_range(cls_method_context_t hctx,
int cls_cxx_map_remove_key(cls_method_context_t hctx, const string &key)
{
return 0;
OSDOp op{CEPH_OSD_OP_OMAPRMKEYS};
std::vector<string> to_rm{key};
encode(to_rm, op.indata);
return execute_osd_op(hctx, op);
}
int cls_cxx_list_watchers(cls_method_context_t hctx,
@ -414,7 +443,8 @@ int cls_cxx_list_watchers(cls_method_context_t hctx,
uint64_t cls_current_version(cls_method_context_t hctx)
{
return 0;
auto* ox = reinterpret_cast<crimson::osd::OpsExecuter*>(hctx);
return ox->get_last_user_version();
}