From cb0af356ea7e955e3a9116868543ba1bca5caa3e Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 14 Aug 2019 16:49:01 +0200 Subject: [PATCH] crimson/osd: implement a bunch of objclass methods. Signed-off-by: Radoslaw Zarzynski --- src/crimson/osd/objclass.cc | 55 ++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/src/crimson/osd/objclass.cc b/src/crimson/osd/objclass.cc index e0b080807f4..bfaf406d8b2 100644 --- a/src/crimson/osd/objclass.cc +++ b/src/crimson/osd/objclass.cc @@ -63,7 +63,15 @@ int cls_cxx_create(cls_method_context_t hctx, bool exclusive) int cls_cxx_remove(cls_method_context_t hctx) { - return 0; + OSDOp op{CEPH_OSD_OP_DELETE}; + + // we're blocking here which presumes execution in Seastar's thread. + try { + reinterpret_cast(hctx)->do_osd_op(op).get(); + return 0; + } catch (ceph::osd::error& e) { + return -e.code().value(); + } } int cls_cxx_stat(cls_method_context_t hctx, uint64_t *size, time_t *mtime) @@ -149,12 +157,44 @@ int cls_cxx_replace(cls_method_context_t hctx, int len, bufferlist *inbl) { - return 0; + { + OSDOp top{CEPH_OSD_OP_TRUNCATE}; + top.op.extent.offset = 0; + top.op.extent.length = 0; + try { + reinterpret_cast(hctx)->do_osd_op(top).get(); + return 0; + } catch (ceph::osd::error& e) { + return -e.code().value(); + } + } + + { + OSDOp wop{CEPH_OSD_OP_WRITE}; + wop.op.extent.offset = ofs; + wop.op.extent.length = len; + wop.indata = *inbl; + + try { + reinterpret_cast(hctx)->do_osd_op(wop).get(); + return 0; + } catch (ceph::osd::error& e) { + return -e.code().value(); + } + } } int cls_cxx_truncate(cls_method_context_t hctx, int ofs) { - return 0; + OSDOp op{CEPH_OSD_OP_TRUNCATE}; + op.op.extent.offset = ofs; + op.op.extent.length = 0; + try { + reinterpret_cast(hctx)->do_osd_op(op).get(); + return 0; + } catch (ceph::osd::error& e) { + return -e.code().value(); + } } int cls_cxx_getxattr(cls_method_context_t hctx, @@ -198,7 +238,14 @@ int cls_cxx_setxattr(cls_method_context_t hctx, int cls_cxx_snap_revert(cls_method_context_t hctx, snapid_t snapid) { - return 0; + OSDOp op{op = CEPH_OSD_OP_ROLLBACK}; + op.op.snap.snapid = snapid; + try { + reinterpret_cast(hctx)->do_osd_op(op).get(); + return 0; + } catch (ceph::osd::error& e) { + return -e.code().value(); + } } int cls_cxx_map_get_all_vals(cls_method_context_t hctx, -- 2.39.5