cls_method_handle_t h_2pc_queue_remove_entries;
cls_method_handle_t h_2pc_queue_expire_reservations;
- cls_register(TPC_QUEUE_CLASS, &h_class);
-
- cls_register_cxx_method(h_class, TPC_QUEUE_INIT, CLS_METHOD_RD | CLS_METHOD_WR, cls_2pc_queue_init, &h_2pc_queue_init);
- cls_register_cxx_method(h_class, TPC_QUEUE_GET_CAPACITY, CLS_METHOD_RD, cls_2pc_queue_get_capacity, &h_2pc_queue_get_capacity);
- cls_register_cxx_method(h_class, TPC_QUEUE_GET_TOPIC_STATS, CLS_METHOD_RD, cls_2pc_queue_get_topic_stats, &h_2pc_queue_get_topic_stats);
- cls_register_cxx_method(h_class, TPC_QUEUE_RESERVE, CLS_METHOD_RD | CLS_METHOD_WR, cls_2pc_queue_reserve, &h_2pc_queue_reserve);
- cls_register_cxx_method(h_class, TPC_QUEUE_COMMIT, CLS_METHOD_RD | CLS_METHOD_WR, cls_2pc_queue_commit, &h_2pc_queue_commit);
- cls_register_cxx_method(h_class, TPC_QUEUE_ABORT, CLS_METHOD_RD | CLS_METHOD_WR, cls_2pc_queue_abort, &h_2pc_queue_abort);
- cls_register_cxx_method(h_class, TPC_QUEUE_LIST_RESERVATIONS, CLS_METHOD_RD, cls_2pc_queue_list_reservations, &h_2pc_queue_list_reservations);
- cls_register_cxx_method(h_class, TPC_QUEUE_LIST_ENTRIES, CLS_METHOD_RD, cls_2pc_queue_list_entries, &h_2pc_queue_list_entries);
- cls_register_cxx_method(h_class, TPC_QUEUE_REMOVE_ENTRIES, CLS_METHOD_RD | CLS_METHOD_WR, cls_2pc_queue_remove_entries, &h_2pc_queue_remove_entries);
- cls_register_cxx_method(h_class, TPC_QUEUE_EXPIRE_RESERVATIONS, CLS_METHOD_RD | CLS_METHOD_WR, cls_2pc_queue_expire_reservations, &h_2pc_queue_expire_reservations);
+ using namespace cls::tpc_queue;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ using namespace method;
+ cls.register_cxx_method(init, cls_2pc_queue_init, &h_2pc_queue_init);
+ cls.register_cxx_method(get_capacity, cls_2pc_queue_get_capacity, &h_2pc_queue_get_capacity);
+ cls.register_cxx_method(get_topic_stats, cls_2pc_queue_get_topic_stats, &h_2pc_queue_get_topic_stats);
+ cls.register_cxx_method(reserve, cls_2pc_queue_reserve, &h_2pc_queue_reserve);
+ cls.register_cxx_method(commit, cls_2pc_queue_commit, &h_2pc_queue_commit);
+ cls.register_cxx_method(method::abort, cls_2pc_queue_abort, &h_2pc_queue_abort);
+ cls.register_cxx_method(list_reservations, cls_2pc_queue_list_reservations, &h_2pc_queue_list_reservations);
+ cls.register_cxx_method(list_entries, cls_2pc_queue_list_entries, &h_2pc_queue_list_entries);
+ cls.register_cxx_method(remove_entries, cls_2pc_queue_remove_entries, &h_2pc_queue_remove_entries);
+ cls.register_cxx_method(expire_reservations, cls_2pc_queue_expire_reservations, &h_2pc_queue_expire_reservations);
return;
}
#include "cls/queue/cls_queue_const.h"
using namespace librados;
+using namespace cls::tpc_queue;
void cls_2pc_queue_init(ObjectWriteOperation& op, const std::string& queue_name, uint64_t size) {
bufferlist in;
cls_queue_init_op call;
call.queue_size = size;
encode(call, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_INIT, in);
+ op.exec(method::init, in);
}
int cls_2pc_queue_get_capacity_result(const bufferlist& bl, uint64_t& size) {
#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_2pc_queue_get_capacity(IoCtx& io_ctx, const std::string& queue_name, uint64_t& size) {
bufferlist in, out;
- const auto r = io_ctx.exec(queue_name, TPC_QUEUE_CLASS, TPC_QUEUE_GET_CAPACITY, in, out);
+ const auto r = io_ctx.exec(queue_name, method::get_capacity, in, out);
if (r < 0 ) {
return r;
}
// after answer is received, call cls_2pc_queue_get_capacity_result() to parse the results
void cls_2pc_queue_get_capacity(ObjectReadOperation& op, bufferlist* obl, int* prval) {
bufferlist in;
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_GET_CAPACITY, in, obl, prval);
+ op.exec(method::get_capacity, in, obl, prval);
}
#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_2pc_queue_get_topic_stats(IoCtx& io_ctx, const std::string& queue_name, uint32_t& committed_entries, uint64_t& size) {
bufferlist in, out;
- const auto r = io_ctx.exec(queue_name, TPC_QUEUE_CLASS, TPC_QUEUE_GET_TOPIC_STATS, in, out);
+ const auto r = io_ctx.exec(queue_name, method::get_topic_stats, in, out);
if (r < 0 ) {
return r;
}
// after answer is received, call cls_2pc_queue_get_topic_stats_result() to parse the results
void cls_2pc_queue_get_topic_stats(ObjectReadOperation& op, bufferlist* obl, int* prval) {
bufferlist in;
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_GET_TOPIC_STATS, in, obl, prval);
+ op.exec(method::get_topic_stats, in, obl, prval);
}
encode(reserve_op, in);
int rval;
ObjectWriteOperation op;
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_RESERVE, in, &out, &rval);
+ op.exec(method::reserve, in, &out, &rval);
const auto r = io_ctx.operate(queue_name, &op, librados::OPERATION_RETURNVEC);
if (r < 0) {
reserve_op.size = res_size;
reserve_op.entries = entries;
encode(reserve_op, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_RESERVE, in, obl, prval);
+ op.exec(method::reserve, in, obl, prval);
}
void cls_2pc_queue_commit(ObjectWriteOperation& op, std::vector<bufferlist> bl_data_vec,
commit_op.id = res_id;
commit_op.bl_data_vec = std::move(bl_data_vec);
encode(commit_op, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_COMMIT, in);
+ op.exec(method::commit, in);
}
void cls_2pc_queue_abort(ObjectWriteOperation& op, cls_2pc_reservation::id_t res_id) {
cls_2pc_queue_abort_op abort_op;
abort_op.id = res_id;
encode(abort_op, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_ABORT, in);
+ op.exec(method::abort, in);
}
int cls_2pc_queue_list_entries_result(const bufferlist& bl, std::vector<cls_queue_entry>& entries,
op.max = max;
encode(op, in);
- const auto r = io_ctx.exec(queue_name, TPC_QUEUE_CLASS, TPC_QUEUE_LIST_ENTRIES, in, out);
+ const auto r = io_ctx.exec(queue_name, method::list_entries, in, out);
if (r < 0) {
return r;
}
list_op.max = max;
encode(list_op, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_LIST_ENTRIES, in, obl, prval);
+ op.exec(method::list_entries, in, obl, prval);
+}
+
+void cls_2pc_queue_list_entries(ObjectWriteOperation& op, const std::string& marker, uint32_t max, bufferlist* obl, int* prval) {
+ bufferlist in;
+ cls_queue_list_op list_op;
+ list_op.start_marker = marker;
+ list_op.max = max;
+ encode(list_op, in);
+
+ op.exec(method::list_entries, in, obl, prval);
}
int cls_2pc_queue_list_reservations_result(const bufferlist& bl, cls_2pc_reservations& reservations) {
int cls_2pc_queue_list_reservations(IoCtx& io_ctx, const std::string& queue_name, cls_2pc_reservations& reservations) {
bufferlist in, out;
- const auto r = io_ctx.exec(queue_name, TPC_QUEUE_CLASS, TPC_QUEUE_LIST_RESERVATIONS, in, out);
+ const auto r = io_ctx.exec(queue_name, method::list_reservations, in, out);
if (r < 0) {
return r;
}
void cls_2pc_queue_list_reservations(ObjectReadOperation& op, bufferlist* obl, int* prval) {
bufferlist in;
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_LIST_RESERVATIONS, in, obl, prval);
+ op.exec(method::list_reservations, in, obl, prval);
}
void cls_2pc_queue_remove_entries(ObjectWriteOperation& op, const std::string& end_marker, uint64_t entries_to_remove) {
rem_op.end_marker = end_marker;
rem_op.entries_to_remove = entries_to_remove;
encode(rem_op, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_REMOVE_ENTRIES, in);
+ op.exec(method::remove_entries, in);
}
void cls_2pc_queue_expire_reservations(librados::ObjectWriteOperation& op, ceph::coarse_real_time stale_time) {
cls_2pc_queue_expire_op expire_op;
expire_op.stale_time = stale_time;
encode(expire_op, in);
- op.exec(TPC_QUEUE_CLASS, TPC_QUEUE_EXPIRE_RESERVATIONS, in);
+ op.exec(method::expire_reservations, in);
}
// optionally async incremental listing of all entries in the queue
// after answer is received, call cls_2pc_queue_list_entries_result() to parse the results
void cls_2pc_queue_list_entries(librados::ObjectReadOperation& op, const std::string& marker, uint32_t max, bufferlist* obl, int* prval);
+void cls_2pc_queue_list_entries(librados::ObjectWriteOperation& op, const std::string& marker, uint32_t max, bufferlist* obl, int* prval);
int cls_2pc_queue_list_entries_result(const bufferlist& bl, std::vector<cls_queue_entry>& entries,
bool *truncated, std::string& next_marker);
#include "common/Formatter.h"
#include "include/encoding.h"
#include "include/types.h"
+#include "include/rados/cls_traits.h"
+#include "cls_2pc_queue_const.h"
#include <unordered_map>
}
};
WRITE_CLASS_ENCODER(cls_2pc_urgent_data)
+
+namespace cls::tpc_queue {
+struct ClassId {
+ static constexpr auto name = "2pc_queue";
+};
+namespace method {
+constexpr auto init = ClsMethod<RdWrTag, ClassId>(TPC_QUEUE_INIT);
+constexpr auto get_capacity = ClsMethod<RdTag, ClassId>(TPC_QUEUE_GET_CAPACITY);
+constexpr auto get_topic_stats = ClsMethod<RdTag, ClassId>(TPC_QUEUE_GET_TOPIC_STATS);
+constexpr auto reserve = ClsMethod<RdWrTag, ClassId>(TPC_QUEUE_RESERVE);
+constexpr auto commit = ClsMethod<RdWrTag, ClassId>(TPC_QUEUE_COMMIT);
+constexpr auto abort = ClsMethod<RdWrTag, ClassId>(TPC_QUEUE_ABORT);
+constexpr auto list_reservations = ClsMethod<RdTag, ClassId>(TPC_QUEUE_LIST_RESERVATIONS);
+constexpr auto list_entries = ClsMethod<RdTag, ClassId>(TPC_QUEUE_LIST_ENTRIES);
+constexpr auto remove_entries = ClsMethod<RdWrTag, ClassId>(TPC_QUEUE_REMOVE_ENTRIES);
+constexpr auto expire_reservations = ClsMethod<RdWrTag, ClassId>(TPC_QUEUE_EXPIRE_RESERVATIONS);
+}
+}
+
#include "include/compat.h"
#include "osd/osd_types.h"
+
using ceph::bufferlist;
using ceph::decode;
cls_method_handle_t h_chunk_put_ref;
cls_method_handle_t h_references_chunk;
- cls_register("cas", &h_class);
-
- cls_register_cxx_method(h_class, "chunk_create_or_get_ref",
- CLS_METHOD_RD | CLS_METHOD_WR,
- chunk_create_or_get_ref,
- &h_chunk_create_or_get_ref);
- cls_register_cxx_method(h_class, "chunk_get_ref",
- CLS_METHOD_RD | CLS_METHOD_WR,
- chunk_get_ref,
- &h_chunk_get_ref);
- cls_register_cxx_method(h_class, "chunk_put_ref",
- CLS_METHOD_RD | CLS_METHOD_WR,
- chunk_put_ref,
- &h_chunk_put_ref);
- cls_register_cxx_method(h_class, "references_chunk", CLS_METHOD_RD,
- references_chunk,
- &h_references_chunk);
+ using namespace cls::cas;
+ cls_register(ClassId::name, &h_class);
+
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::chunk_create_or_get_ref, chunk_create_or_get_ref, &h_chunk_create_or_get_ref);
+ cls.register_cxx_method(method::chunk_get_ref, chunk_get_ref, &h_chunk_get_ref);
+ cls.register_cxx_method(method::chunk_put_ref, chunk_put_ref, &h_chunk_put_ref);
+ cls.register_cxx_method(method::references_chunk, references_chunk, &h_references_chunk);
return;
}
using ceph::decode;
using ceph::encode;
+using namespace cls::cas;
+
void cls_cas_chunk_create_or_get_ref(
librados::ObjectWriteOperation& op,
const hobject_t& soid,
}
call.data = data;
encode(call, in);
- op.exec("cas", "chunk_create_or_get_ref", in);
+ op.exec(method::chunk_create_or_get_ref, in);
}
void cls_cas_chunk_get_ref(
cls_cas_chunk_get_ref_op call;
call.source = soid;
encode(call, in);
- op.exec("cas", "chunk_get_ref", in);
+ op.exec(method::chunk_get_ref, in);
}
void cls_cas_chunk_put_ref(
cls_cas_chunk_put_ref_op call;
call.source = soid;
encode(call, in);
- op.exec("cas", "chunk_put_ref", in);
+ op.exec(method::chunk_put_ref, in);
}
int cls_cas_references_chunk(
{
bufferlist in, out;
encode(chunk_oid, in);
- int r = io_ctx.exec(oid, "cas", "references_chunk", in, out);
+ int r = io_ctx.exec(oid, method::references_chunk, in, out);
return r;
}
#include "include/types.h"
#include "include/rados/librados_fwd.hpp"
#include "common/hobject.h"
+#include "cls_cas_types.h"
//
// basic methods
#include "include/types.h"
#include "common/hobject.h"
#include "common/Formatter.h"
+#include "cls_cas_types.h"
struct cls_cas_chunk_create_or_get_ref_op {
enum {
--- /dev/null
+#pragma once
+#include "include/rados/cls_traits.h"
+
+namespace cls::cas {
+struct ClassId {
+ static constexpr auto name = "cas";
+};
+namespace method {
+ constexpr auto chunk_create_or_get_ref = ClsMethod<RdWrTag, ClassId>("chunk_create_or_get_ref");
+ constexpr auto chunk_get_ref = ClsMethod<RdWrTag, ClassId>("chunk_get_ref");
+ constexpr auto chunk_put_ref = ClsMethod<RdWrTag, ClassId>("chunk_put_ref");
+ constexpr auto references_chunk = ClsMethod<RdTag, ClassId>("references_chunk");
+}
+}
\ No newline at end of file
cls_handle_t h_class;
cls_method_handle_t h_accumulate_inode_metadata;
- cls_register("cephfs", &h_class);
- cls_register_cxx_method(h_class, "accumulate_inode_metadata",
- CLS_METHOD_WR | CLS_METHOD_RD,
- accumulate_inode_metadata, &h_accumulate_inode_metadata);
+ using namespace ::cls::cephfs;
+ cls_register(ClassId::name, &h_class);
+
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::accumulate_inode_metadata,
+ accumulate_inode_metadata, &h_accumulate_inode_metadata);
// A PGLS filter
cls_register_cxx_filter(h_class, "inode_tag", inode_tag_filter);
*/
#include "include/encoding.h"
+#include "cls_cephfs_types.h"
/**
* Value class for the xattr we'll use to accumulate
using ceph::bufferlist;
using ceph::decode;
+using namespace cls::cephfs;
+
#define XATTR_CEILING "scan_ceiling"
#define XATTR_MAX_MTIME "scan_max_mtime"
#define XATTR_MAX_SIZE "scan_max_size"
librados::ObjectWriteOperation op;
bufferlist inbl;
args.encode(inbl);
- op.exec("cephfs", "accumulate_inode_metadata", inbl);
+ op.exec(method::accumulate_inode_metadata, inbl);
if (obj_pool_id != -1) {
bufferlist bl;
#include "include/rados/librados_fwd.hpp"
#include "mds/mdstypes.h"
#include "cls_cephfs.h"
+#include "cls_cephfs_types.h"
struct inode_backtrace_t;
class AccumulateArgs;
--- /dev/null
+#pragma once
+#include "include/rados/cls_traits.h"
+namespace cls::cephfs {
+struct ClassId {
+ static constexpr auto name = "cephfs";
+};
+namespace method {
+constexpr auto accumulate_inode_metadata = ClsMethod<RdWrTag, ClassId>("accumulate_inode_metadata");
+}
+}
\ No newline at end of file
bufferlist in;
encode(call, in);
- op.exec("cmpomap", "cmp_vals", in);
+ op.exec(method::cmp_vals, in);
return 0;
}
bufferlist in;
encode(call, in);
- op.exec("cmpomap", "cmp_set_vals", in);
+ op.exec(method::cmp_set_vals, in);
return 0;
}
bufferlist in;
encode(call, in);
- op.exec("cmpomap", "cmp_rm_keys", in);
+ op.exec(method::cmp_rm_keys, in);
return 0;
}
#include "types.h"
#include "include/encoding.h"
+#include "include/rados/cls_traits.h"
namespace cls::cmpomap {
DECODE_FINISH(bl);
}
+struct ClassId {
+ static constexpr auto name = "cmpomap";
+};
+namespace method {
+constexpr auto cmp_vals = ClsMethod<RdTag, ClassId>("cmp_vals");
+constexpr auto cmp_set_vals = ClsMethod<RdWrTag, ClassId>("cmp_set_vals");
+constexpr auto cmp_rm_keys = ClsMethod<RdWrTag, ClassId>("cmp_rm_keys");
+}
+
} // namespace cls::cmpomap
cls_method_handle_t h_cmp_set_vals;
cls_method_handle_t h_cmp_rm_keys;
- cls_register("cmpomap", &h_class);
+ using namespace cls::cmpomap;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
- cls_register_cxx_method(h_class, "cmp_vals", CLS_METHOD_RD,
- cmp_vals, &h_cmp_vals);
- cls_register_cxx_method(h_class, "cmp_set_vals", CLS_METHOD_RD | CLS_METHOD_WR,
- cmp_set_vals, &h_cmp_set_vals);
- cls_register_cxx_method(h_class, "cmp_rm_keys", CLS_METHOD_RD | CLS_METHOD_WR,
- cmp_rm_keys, &h_cmp_rm_keys);
+ cls.register_cxx_method(method::cmp_vals, cmp_vals, &h_cmp_vals);
+ cls.register_cxx_method(method::cmp_set_vals, cmp_set_vals, &h_cmp_set_vals);
+ cls.register_cxx_method(method::cmp_rm_keys, cmp_rm_keys, &h_cmp_rm_keys);
}
cls_method_handle_t h_list_part;
cls_method_handle_t h_get_part_info;
- cls_register(op::CLASS, &h_class);
- cls_register_cxx_method(h_class, op::CREATE_META,
- CLS_METHOD_RD | CLS_METHOD_WR,
- create_meta, &h_create_meta);
-
- cls_register_cxx_method(h_class, op::GET_META,
- CLS_METHOD_RD,
- get_meta, &h_get_meta);
-
- cls_register_cxx_method(h_class, op::UPDATE_META,
- CLS_METHOD_RD | CLS_METHOD_WR,
- update_meta, &h_update_meta);
-
- cls_register_cxx_method(h_class, op::INIT_PART,
- CLS_METHOD_RD | CLS_METHOD_WR,
- init_part, &h_init_part);
-
- cls_register_cxx_method(h_class, op::PUSH_PART,
- CLS_METHOD_RD | CLS_METHOD_WR,
- push_part, &h_push_part);
-
- cls_register_cxx_method(h_class, op::TRIM_PART,
- CLS_METHOD_RD | CLS_METHOD_WR,
- trim_part, &h_trim_part);
-
- cls_register_cxx_method(h_class, op::LIST_PART,
- CLS_METHOD_RD,
- list_part, &h_list_part);
-
- cls_register_cxx_method(h_class, op::GET_PART_INFO,
- CLS_METHOD_RD,
- get_part_info, &h_get_part_info);
+ using namespace rados::cls::fifo;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::create_meta, create_meta, &h_create_meta);
+ cls.register_cxx_method(method::get_meta, get_meta, &h_get_meta);
+ cls.register_cxx_method(method::update_meta, update_meta, &h_update_meta);
+ cls.register_cxx_method(method::init_part, init_part, &h_init_part);
+ cls.register_cxx_method(method::push_part, push_part, &h_push_part);
+ cls.register_cxx_method(method::trim_part, trim_part, &h_trim_part);
+ cls.register_cxx_method(method::list_part, list_part, &h_list_part);
+ cls.register_cxx_method(method::get_part_info, get_part_info, &h_get_part_info);
/* calculate entry overhead */
struct entry_header entry_header;
#include "include/types.h"
#include "cls/fifo/cls_fifo_types.h"
+#include "include/rados/cls_traits.h"
-namespace rados::cls::fifo::op {
+namespace rados::cls::fifo {
+namespace op {
struct create_meta
{
std::string id;
inline constexpr auto TRIM_PART = "trim_part";
inline constexpr auto LIST_PART = "part_list";
inline constexpr auto GET_PART_INFO = "get_part_info";
-} // namespace rados::cls::fifo::op
+} // namespace op
+
+struct ClassId {
+ static constexpr auto name = op::CLASS;
+};
+namespace method {
+constexpr auto create_meta = ClsMethod<RdWrTag, ClassId>(op::CREATE_META);
+constexpr auto get_meta = ClsMethod<RdTag, ClassId>(op::GET_META);
+constexpr auto update_meta = ClsMethod<RdWrTag, ClassId>(op::UPDATE_META);
+constexpr auto init_part = ClsMethod<RdWrTag, ClassId>(op::INIT_PART);
+constexpr auto push_part = ClsMethod<RdWrTag, ClassId>(op::PUSH_PART);
+constexpr auto trim_part = ClsMethod<RdWrTag, ClassId>(op::TRIM_PART);
+constexpr auto list_part = ClsMethod<RdTag, ClassId>(op::LIST_PART);
+constexpr auto get_part_info = ClsMethod<RdTag, ClassId>(op::GET_PART_INFO);
+} // namespace method
+} // namespace rados::cls::fifo
#include "objclass/objclass.h"
#include "osd/osd_types.h"
+#include "cls_hello_ops.h"
using std::string;
using std::ostringstream;
cls_method_handle_t h_bad_reader;
cls_method_handle_t h_bad_writer;
- cls_register("hello", &h_class);
+ using namespace cls::hello;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
// There are two flags we specify for methods:
//
// neither, the data it returns to the caller is a function of the
// request and not the object contents.
- cls_register_cxx_method(h_class, "say_hello",
- CLS_METHOD_RD,
- say_hello, &h_say_hello);
- cls_register_cxx_method(h_class, "record_hello",
- CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- record_hello, &h_record_hello);
- cls_register_cxx_method(h_class, "write_return_data",
- CLS_METHOD_WR,
- write_return_data, &h_write_return_data);
+ cls.register_cxx_method(method::say_hello, say_hello, &h_say_hello);
+ cls.register_cxx_method(method::record_hello, record_hello, &h_record_hello);
+ cls.register_cxx_method(method::write_return_data, write_return_data, &h_write_return_data);
// legacy alias for this method for pre-octopus clients
- cls_register_cxx_method(h_class, "writes_dont_return_data",
- CLS_METHOD_WR,
- write_return_data, &h_writes_dont_return_data);
- cls_register_cxx_method(h_class, "write_too_much_return_data",
- CLS_METHOD_WR,
- write_too_much_return_data, &h_write_too_much_return_data);
- cls_register_cxx_method(h_class, "replay",
- CLS_METHOD_RD,
- replay, &h_replay);
+ cls.register_cxx_method(method::writes_dont_return_data, write_return_data, &h_writes_dont_return_data);
+ cls.register_cxx_method(method::write_too_much_return_data, write_too_much_return_data, &h_write_too_much_return_data);
+ cls.register_cxx_method(method::replay, replay, &h_replay);
// RD | WR is a read-modify-write method.
- cls_register_cxx_method(h_class, "turn_it_to_11",
- CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- turn_it_to_11, &h_turn_it_to_11);
+ cls.register_cxx_method(method::turn_it_to_11, turn_it_to_11, &h_turn_it_to_11);
// counter-examples
- cls_register_cxx_method(h_class, "bad_reader", CLS_METHOD_WR,
- bad_reader, &h_bad_reader);
- cls_register_cxx_method(h_class, "bad_writer", CLS_METHOD_RD,
- bad_writer, &h_bad_writer);
+ cls.register_cxx_method(method::bad_reader, bad_reader, &h_bad_reader);
+ cls.register_cxx_method(method::bad_writer, bad_writer, &h_bad_writer);
// A PGLS filter
cls_register_cxx_filter(h_class, "hello", hello_filter);
--- /dev/null
+#pragma once
+
+#include "include/rados/cls_traits.h"
+
+namespace cls::hello {
+struct ClassId {
+ static constexpr auto name = "hello";
+};
+namespace method {
+constexpr auto say_hello = ClsMethod<RdTag, ClassId>("say_hello");
+constexpr auto record_hello = ClsMethod<WrPromoteTag, ClassId>("record_hello");
+constexpr auto write_return_data = ClsMethod<WrTag, ClassId>("write_return_data");
+constexpr auto writes_dont_return_data = ClsMethod<WrTag, ClassId>("writes_dont_return_data");
+constexpr auto write_too_much_return_data = ClsMethod<WrTag, ClassId>("write_too_much_return_data");
+constexpr auto replay = ClsMethod<RdTag, ClassId>("replay");
+constexpr auto turn_it_to_11 = ClsMethod<RdWrPromoteTag, ClassId>("turn_it_to_11");
+constexpr auto bad_reader = ClsMethod<WrTag, ClassId>("bad_reader");
+constexpr auto bad_writer = ClsMethod<RdTag, ClassId>("bad_writer");
+}
+}
#include "common/errno.h"
#include "objclass/objclass.h"
#include "cls/journal/cls_journal_types.h"
+#include "cls/journal/cls_journal_ops.h"
#include <errno.h>
#include <iomanip>
#include <map>
cls_method_handle_t h_journal_object_guard_append;
cls_method_handle_t h_journal_object_append;
- cls_register("journal", &h_class);
-
- /// methods for journal.$journal_id objects
- cls_register_cxx_method(h_class, "create",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_create, &h_journal_create);
- cls_register_cxx_method(h_class, "get_order",
- CLS_METHOD_RD,
- journal_get_order, &h_journal_get_order);
- cls_register_cxx_method(h_class, "get_splay_width",
- CLS_METHOD_RD,
- journal_get_splay_width, &h_journal_get_splay_width);
- cls_register_cxx_method(h_class, "get_pool_id",
- CLS_METHOD_RD,
- journal_get_pool_id, &h_journal_get_pool_id);
- cls_register_cxx_method(h_class, "get_minimum_set",
- CLS_METHOD_RD,
- journal_get_minimum_set,
- &h_journal_get_minimum_set);
- cls_register_cxx_method(h_class, "set_minimum_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_set_minimum_set,
- &h_journal_set_minimum_set);
- cls_register_cxx_method(h_class, "get_active_set",
- CLS_METHOD_RD,
- journal_get_active_set,
- &h_journal_get_active_set);
- cls_register_cxx_method(h_class, "set_active_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_set_active_set,
- &h_journal_set_active_set);
-
- cls_register_cxx_method(h_class, "get_client",
- CLS_METHOD_RD,
- journal_get_client, &h_journal_get_client);
- cls_register_cxx_method(h_class, "client_register",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_client_register, &h_journal_client_register);
- cls_register_cxx_method(h_class, "client_update_data",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_client_update_data,
- &h_journal_client_update_data);
- cls_register_cxx_method(h_class, "client_update_state",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_client_update_state,
- &h_journal_client_update_state);
- cls_register_cxx_method(h_class, "client_unregister",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_client_unregister,
- &h_journal_client_unregister);
- cls_register_cxx_method(h_class, "client_commit",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_client_commit, &h_journal_client_commit);
- cls_register_cxx_method(h_class, "client_list",
- CLS_METHOD_RD,
- journal_client_list, &h_journal_client_list);
-
- cls_register_cxx_method(h_class, "get_next_tag_tid",
- CLS_METHOD_RD,
- journal_get_next_tag_tid,
- &h_journal_get_next_tag_tid);
- cls_register_cxx_method(h_class, "get_tag",
- CLS_METHOD_RD,
- journal_get_tag, &h_journal_get_tag);
- cls_register_cxx_method(h_class, "tag_create",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_tag_create, &h_journal_tag_create);
- cls_register_cxx_method(h_class, "tag_list",
- CLS_METHOD_RD,
- journal_tag_list, &h_journal_tag_list);
-
- /// methods for journal_data.$journal_id.$object_id objects
- cls_register_cxx_method(h_class, "guard_append",
- CLS_METHOD_RD | CLS_METHOD_WR,
- journal_object_guard_append,
- &h_journal_object_guard_append);
- cls_register_cxx_method(h_class, "append", CLS_METHOD_RD | CLS_METHOD_WR,
- journal_object_append, &h_journal_object_append);
+ using namespace cls::journal;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::create, journal_create, &h_journal_create);
+ cls.register_cxx_method(method::get_order, journal_get_order, &h_journal_get_order);
+ cls.register_cxx_method(method::get_splay_width, journal_get_splay_width, &h_journal_get_splay_width);
+ cls.register_cxx_method(method::get_pool_id, journal_get_pool_id, &h_journal_get_pool_id);
+ cls.register_cxx_method(method::get_minimum_set, journal_get_minimum_set, &h_journal_get_minimum_set);
+ cls.register_cxx_method(method::set_minimum_set, journal_set_minimum_set, &h_journal_set_minimum_set);
+ cls.register_cxx_method(method::get_active_set, journal_get_active_set, &h_journal_get_active_set);
+ cls.register_cxx_method(method::set_active_set, journal_set_active_set, &h_journal_set_active_set);
+ cls.register_cxx_method(method::get_client, journal_get_client, &h_journal_get_client);
+ cls.register_cxx_method(method::client_register, journal_client_register, &h_journal_client_register);
+ cls.register_cxx_method(method::client_update_data, journal_client_update_data, &h_journal_client_update_data);
+ cls.register_cxx_method(method::client_update_state, journal_client_update_state, &h_journal_client_update_state);
+ cls.register_cxx_method(method::client_unregister, journal_client_unregister, &h_journal_client_unregister);
+ cls.register_cxx_method(method::client_commit, journal_client_commit, &h_journal_client_commit);
+ cls.register_cxx_method(method::client_list, journal_client_list, &h_journal_client_list);
+ cls.register_cxx_method(method::get_next_tag_tid, journal_get_next_tag_tid, &h_journal_get_next_tag_tid);
+ cls.register_cxx_method(method::get_tag, journal_get_tag, &h_journal_get_tag);
+ cls.register_cxx_method(method::tag_create, journal_tag_create, &h_journal_tag_create);
+ cls.register_cxx_method(method::tag_list, journal_tag_list, &h_journal_tag_list);
+ cls.register_cxx_method(method::guard_append, journal_object_guard_append, &h_journal_object_guard_append);
+ cls.register_cxx_method(method::append, journal_object_append, &h_journal_object_append);
}
#include "include/Context.h"
#include "common/Cond.h"
#include <errno.h>
+using namespace cls::journal;
namespace cls {
namespace journal {
namespace {
+
struct C_AioExec : public Context {
librados::IoCtx &ioctx;
std::string oid;
encode(JOURNAL_MAX_RETURN, inbl);
librados::ObjectReadOperation op;
- op.exec("journal", "client_list", inbl);
+ op.exec(method::client_list, inbl);
outbl.clear();
librados::AioCompletion *rados_completion =
void send() {
librados::ObjectReadOperation op;
bufferlist inbl;
- op.exec("journal", "get_order", inbl);
- op.exec("journal", "get_splay_width", inbl);
- op.exec("journal", "get_pool_id", inbl);
+ op.exec(method::get_order, inbl);
+ op.exec(method::get_splay_width, inbl);
+ op.exec(method::get_pool_id, inbl);
librados::AioCompletion *rados_completion =
librados::Rados::aio_create_completion(this, rados_callback);
void send() {
librados::ObjectReadOperation op;
bufferlist inbl;
- op.exec("journal", "get_minimum_set", inbl);
- op.exec("journal", "get_active_set", inbl);
+ op.exec(method::get_minimum_set, inbl);
+ op.exec(method::get_active_set, inbl);
librados::AioCompletion *rados_completion =
librados::Rados::aio_create_completion(this, rados_callback);
encode(splay, bl);
encode(pool_id, bl);
- op->exec("journal", "create", bl);
+ op->exec(method::create, bl);
}
int create(librados::IoCtx &ioctx, const std::string &oid, uint8_t order,
void set_minimum_set(librados::ObjectWriteOperation *op, uint64_t object_set) {
bufferlist bl;
encode(object_set, bl);
- op->exec("journal", "set_minimum_set", bl);
+ op->exec(method::set_minimum_set, bl);
}
void set_active_set(librados::ObjectWriteOperation *op, uint64_t object_set) {
bufferlist bl;
encode(object_set, bl);
- op->exec("journal", "set_active_set", bl);
+ op->exec(method::set_active_set, bl);
}
int get_client(librados::IoCtx &ioctx, const std::string &oid,
const std::string &id) {
bufferlist bl;
encode(id, bl);
- op->exec("journal", "get_client", bl);
+ op->exec(method::get_client, bl);
}
int get_client_finish(bufferlist::const_iterator *iter,
bufferlist bl;
encode(id, bl);
encode(data, bl);
- op->exec("journal", "client_register", bl);
+ op->exec(method::client_register, bl);
}
int client_update_data(librados::IoCtx &ioctx, const std::string &oid,
bufferlist bl;
encode(id, bl);
encode(data, bl);
- op->exec("journal", "client_update_data", bl);
+ op->exec(method::client_update_data, bl);
}
int client_update_state(librados::IoCtx &ioctx, const std::string &oid,
bufferlist bl;
encode(id, bl);
encode(static_cast<uint8_t>(state), bl);
- op->exec("journal", "client_update_state", bl);
+ op->exec(method::client_update_state, bl);
}
int client_unregister(librados::IoCtx &ioctx, const std::string &oid,
bufferlist bl;
encode(id, bl);
- op->exec("journal", "client_unregister", bl);
+ op->exec(method::client_unregister, bl);
}
void client_commit(librados::ObjectWriteOperation *op, const std::string &id,
bufferlist bl;
encode(id, bl);
encode(commit_position, bl);
- op->exec("journal", "client_commit", bl);
+ op->exec(method::client_commit, bl);
}
int client_list(librados::IoCtx &ioctx, const std::string &oid,
void get_next_tag_tid_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("journal", "get_next_tag_tid", bl);
+ op->exec(method::get_next_tag_tid, bl);
}
int get_next_tag_tid_finish(bufferlist::const_iterator *iter,
uint64_t tag_tid) {
bufferlist bl;
encode(tag_tid, bl);
- op->exec("journal", "get_tag", bl);
+ op->exec(method::get_tag, bl);
}
int get_tag_finish(bufferlist::const_iterator *iter, cls::journal::Tag *tag) {
encode(tag_tid, bl);
encode(tag_class, bl);
encode(data, bl);
- op->exec("journal", "tag_create", bl);
+ op->exec(method::tag_create, bl);
}
int tag_list(librados::IoCtx &ioctx, const std::string &oid,
encode(max_return, bl);
encode(client_id, bl);
encode(tag_class, bl);
- op->exec("journal", "tag_list", bl);
+ op->exec(method::tag_list, bl);
}
int tag_list_finish(bufferlist::const_iterator *iter,
void guard_append(librados::ObjectWriteOperation *op, uint64_t soft_max_size) {
bufferlist bl;
encode(soft_max_size, bl);
- op->exec("journal", "guard_append", bl);
+ op->exec(method::guard_append, bl);
}
void append(librados::ObjectWriteOperation *op, uint64_t soft_max_size,
encode(soft_max_size, bl);
encode(data, bl);
- op->exec("journal", "append", bl);
+ op->exec(method::append, bl);
}
} // namespace client
#include "include/rados/librados_fwd.hpp"
#include "cls/journal/cls_journal_types.h"
+#include "cls/journal/cls_journal_ops.h"
#include <set>
#include <boost/optional.hpp>
--- /dev/null
+#pragma once
+
+#include "include/rados/cls_traits.h"
+
+namespace cls::journal {
+struct ClassId {
+ static constexpr auto name = "journal";
+};
+namespace method {
+constexpr auto create = ClsMethod<RdWrTag, ClassId>("create");
+constexpr auto get_order = ClsMethod<RdTag, ClassId>("get_order");
+constexpr auto get_splay_width = ClsMethod<RdTag, ClassId>("get_splay_width");
+constexpr auto get_pool_id = ClsMethod<RdTag, ClassId>("get_pool_id");
+constexpr auto get_minimum_set = ClsMethod<RdTag, ClassId>("get_minimum_set");
+constexpr auto set_minimum_set = ClsMethod<RdWrTag, ClassId>("set_minimum_set");
+constexpr auto get_active_set = ClsMethod<RdTag, ClassId>("get_active_set");
+constexpr auto set_active_set = ClsMethod<RdWrTag, ClassId>("set_active_set");
+constexpr auto get_client = ClsMethod<RdTag, ClassId>("get_client");
+constexpr auto client_register = ClsMethod<RdWrTag, ClassId>("client_register");
+constexpr auto client_update_data = ClsMethod<RdWrTag, ClassId>("client_update_data");
+constexpr auto client_update_state = ClsMethod<RdWrTag, ClassId>("client_update_state");
+constexpr auto client_unregister = ClsMethod<RdWrTag, ClassId>("client_unregister");
+constexpr auto client_commit = ClsMethod<RdWrTag, ClassId>("client_commit");
+constexpr auto client_list = ClsMethod<RdTag, ClassId>("client_list");
+constexpr auto get_next_tag_tid = ClsMethod<RdTag, ClassId>("get_next_tag_tid");
+constexpr auto get_tag = ClsMethod<RdTag, ClassId>("get_tag");
+constexpr auto tag_create = ClsMethod<RdWrTag, ClassId>("tag_create");
+constexpr auto tag_list = ClsMethod<RdTag, ClassId>("tag_list");
+constexpr auto guard_append = ClsMethod<RdWrTag, ClassId>("guard_append");
+constexpr auto append = ClsMethod<RdWrTag, ClassId>("append");
+}
+}
\ No newline at end of file
cls_method_handle_t h_assert_locked;
cls_method_handle_t h_set_cookie;
- cls_register("lock", &h_class);
- cls_register_cxx_method(h_class, "lock",
- CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- lock_op, &h_lock_op);
- cls_register_cxx_method(h_class, "unlock",
- CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- unlock_op, &h_unlock_op);
- cls_register_cxx_method(h_class, "break_lock",
- CLS_METHOD_RD | CLS_METHOD_WR,
- break_lock, &h_break_lock);
- cls_register_cxx_method(h_class, "get_info",
- CLS_METHOD_RD,
- get_info, &h_get_info);
- cls_register_cxx_method(h_class, "list_locks",
- CLS_METHOD_RD,
- list_locks, &h_list_locks);
- cls_register_cxx_method(h_class, "assert_locked",
- CLS_METHOD_RD | CLS_METHOD_PROMOTE,
- assert_locked, &h_assert_locked);
- cls_register_cxx_method(h_class, "set_cookie",
- CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- set_cookie, &h_set_cookie);
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::lock, lock_op, &h_lock_op);
+ cls.register_cxx_method(method::unlock, unlock_op, &h_unlock_op);
+ cls.register_cxx_method(method::break_lock, break_lock, &h_break_lock);
+ cls.register_cxx_method(method::get_info, get_info, &h_get_info);
+ cls.register_cxx_method(method::list_locks, list_locks, &h_list_locks);
+ cls.register_cxx_method(method::assert_locked, assert_locked, &h_assert_locked);
+ cls.register_cxx_method(method::set_cookie, set_cookie, &h_set_cookie);
return;
}
op.flags = flags;
bufferlist in;
encode(op, in);
- rados_op->exec("lock", "lock", in);
+ rados_op->exec(method::lock, in);
}
int lock(IoCtx *ioctx,
bufferlist in;
encode(op, in);
- rados_op->exec("lock", "unlock", in);
+ rados_op->exec(method::unlock, in);
}
int unlock(IoCtx *ioctx, const std::string& oid,
op.locker = locker;
bufferlist in;
encode(op, in);
- rados_op->exec("lock", "break_lock", in);
+ rados_op->exec(method::break_lock, in);
}
int break_lock(IoCtx *ioctx, const std::string& oid,
int list_locks(IoCtx *ioctx, const std::string& oid, std::list<std::string> *locks)
{
bufferlist in, out;
- int r = ioctx->exec(oid, "lock", "list_locks", in, out);
+ int r = ioctx->exec(oid, method::list_locks, in, out);
if (r < 0)
return r;
cls_lock_get_info_op op;
op.name = name;
encode(op, in);
- rados_op->exec("lock", "get_info", in);
+ rados_op->exec(method::get_info, in);
}
int get_lock_info_finish(bufferlist::const_iterator *iter,
op.tag = tag;
bufferlist in;
encode(op, in);
- rados_op->exec("lock", "assert_locked", in);
+ rados_op->exec(method::assert_locked, in);
}
void set_cookie(librados::ObjectWriteOperation *rados_op,
op.new_cookie = new_cookie;
bufferlist in;
encode(op, in);
- rados_op->exec("lock", "set_cookie", in);
+ rados_op->exec(method::set_cookie, in);
}
void Lock::assert_locked_shared(ObjectOperation *op)
#include "include/types.h"
#include "include/utime.h"
#include "cls/lock/cls_lock_types.h"
+#include "include/rados/cls_traits.h"
struct cls_lock_lock_op
{
};
WRITE_CLASS_ENCODER(cls_lock_set_cookie_op)
+namespace rados::cls::lock {
+struct ClassId {
+ static constexpr auto name = "lock";
+};
+
+namespace method {
+constexpr auto lock = ClsMethod<RdWrPromoteTag, ClassId>("lock");
+constexpr auto unlock = ClsMethod<RdWrPromoteTag, ClassId>("unlock");
+constexpr auto break_lock = ClsMethod<RdWrTag, ClassId>("break_lock");
+constexpr auto get_info = ClsMethod<RdTag, ClassId>("get_info");
+constexpr auto list_locks = ClsMethod<RdTag, ClassId>("list_locks");
+constexpr auto assert_locked = ClsMethod<RdPromoteTag, ClassId>("assert_locked");
+constexpr auto set_cookie = ClsMethod<RdWrPromoteTag, ClassId>("set_cookie");
+}
+}
+
#endif
*/
#include "common/Formatter.h"
-
-#include "cls/lock/cls_lock_types.h"
+#include "cls_lock_types.h"
using namespace rados::cls::lock;
#include "include/types.h"
#include "include/utime.h"
#include "msg/msg_types.h"
+#include "include/rados/cls_traits.h"
/* lock flags */
#define LOCK_FLAG_MAY_RENEW 0x1 /* idempotent lock acquire */
cls_method_handle_t h_log_trim;
cls_method_handle_t h_log_info;
- cls_register("log", &h_class);
-
- /* log */
- cls_register_cxx_method(h_class, "add", CLS_METHOD_RD | CLS_METHOD_WR, cls_log_add, &h_log_add);
- cls_register_cxx_method(h_class, "list", CLS_METHOD_RD, cls_log_list, &h_log_list);
- cls_register_cxx_method(h_class, "trim", CLS_METHOD_RD | CLS_METHOD_WR, cls_log_trim, &h_log_trim);
- cls_register_cxx_method(h_class, "info", CLS_METHOD_RD, cls_log_info, &h_log_info);
+ using namespace cls::log;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::add, cls_log_add, &h_log_add);
+ cls.register_cxx_method(method::list, cls_log_list, &h_log_list);
+ cls.register_cxx_method(method::trim, cls_log_trim, &h_log_trim);
+ cls.register_cxx_method(method::info, cls_log_info, &h_log_info);
return;
}
using ceph::bufferlist;
using namespace librados;
-
+using namespace cls::log;
void cls_log_add(librados::ObjectWriteOperation& op, vector<cls::log::entry>& entries, bool monotonic_inc)
cls::log::ops::add_op call;
call.entries = entries;
encode(call, in);
- op.exec("log", "add", in);
+ op.exec(method::add, in);
}
void cls_log_add(librados::ObjectWriteOperation& op, cls::log::entry& entry)
cls::log::ops::add_op call;
call.entries.push_back(entry);
encode(call, in);
- op.exec("log", "add", in);
+ op.exec(method::add, in);
}
void cls_log_add_prepare_entry(cls::log::entry& entry, ceph::real_time timestamp,
call.from_marker = from_marker;
call.to_marker = to_marker;
encode(call, in);
- op.exec("log", "trim", in);
+ op.exec(method::trim, in);
}
int cls_log_trim(librados::IoCtx& io_ctx, const string& oid,
encode(call, inbl);
- op.exec("log", "list", inbl, new LogListCtx(&entries, out_marker, truncated));
+ op.exec(method::list, inbl, new LogListCtx(&entries, out_marker, truncated));
}
class LogInfoCtx : public ObjectOperationCompletion {
encode(call, inbl);
- op.exec("log", "info", inbl, new LogInfoCtx(header));
+ op.exec(method::info, inbl, new LogInfoCtx(header));
}
#include "common/ceph_time.h"
#include "cls_log_types.h"
+#include "include/rados/cls_traits.h"
namespace cls::log::ops {
struct add_op {
WRITE_CLASS_ENCODER(info_ret)
} // namespace cls::log::ops
+namespace cls::log {
+struct ClassId {
+ static constexpr auto name = "log";
+};
+namespace method {
+constexpr auto add = ClsMethod<RdWrTag, ClassId>("add");
+constexpr auto list = ClsMethod<RdTag, ClassId>("list");
+constexpr auto trim = ClsMethod<RdWrTag, ClassId>("trim");
+constexpr auto info = ClsMethod<RdTag, ClassId>("info");
+}
+}
+
#endif
cls_method_handle_t h_eval_json;
cls_method_handle_t h_eval_bufferlist;
- cls_register("lua", &h_class);
+ using namespace cls::lua;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
- cls_register_cxx_method(h_class, "eval_json",
- CLS_METHOD_RD | CLS_METHOD_WR, eval_json, &h_eval_json);
-
- cls_register_cxx_method(h_class, "eval_bufferlist",
- CLS_METHOD_RD | CLS_METHOD_WR, eval_bufferlist, &h_eval_bufferlist);
+ cls.register_cxx_method(method::eval_json, eval_json, &h_eval_json);
+ cls.register_cxx_method(method::eval_bufferlist, eval_bufferlist, &h_eval_bufferlist);
}
using librados::IoCtx;
using librados::bufferlist;
+using namespace cls::lua;
+
namespace cls_lua_client {
/*
* Currently the return code and return bufferlist are not wrapped in a
librados::ObjectWriteOperation wop;
int rval;
- wop.exec("lua", "eval_bufferlist", inbl, &output, &rval);
+ wop.exec(method::eval_bufferlist, inbl, &output, &rval);
return ioctx.operate(oid, &wop);
}
}
#include <string>
#include "include/encoding.h"
+#include "include/rados/cls_traits.h"
struct cls_lua_eval_op {
std::string script;
};
WRITE_CLASS_ENCODER(cls_lua_eval_op)
+namespace cls::lua {
+struct ClassId {
+ static constexpr auto name = "lua";
+};
+namespace method {
+constexpr auto eval_json = ClsMethod<RdWrTag, ClassId>("eval_json");
+constexpr auto eval_bufferlist = ClsMethod<RdWrTag, ClassId>("eval_bufferlist");
+}
+}
+
#endif
#include <cstdio>
#include <include/compat.h>
+#include "cls_numops_ops.h"
+
#define DECIMAL_PRECISION 10
using ceph::bufferlist;
cls_method_handle_t h_add;
cls_method_handle_t h_mul;
- cls_register("numops", &h_class);
-
- cls_register_cxx_method(h_class, "add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- add, &h_add);
+ using namespace rados::cls::numops;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
- cls_register_cxx_method(h_class, "mul",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mul, &h_mul);
+ cls.register_cxx_method(method::add, add, &h_add);
+ cls.register_cxx_method(method::mul, mul, &h_mul);
}
#include <errno.h>
#include <sstream>
+using namespace rados::cls::numops;
+
namespace rados {
namespace cls {
namespace numops {
encode(stream.str(), in);
librados::ObjectWriteOperation op;
- op.exec("numops", "add", in);
+ op.exec(method::add, in);
return ioctx->operate(oid, &op);
}
encode(stream.str(), in);
librados::ObjectWriteOperation op;
- op.exec("numops", "mul", in);
+ op.exec(method::mul, in);
return ioctx->operate(oid, &op);
}
#define CEPH_LIBRBD_CLS_NUMOPS_CLIENT_H
#include "include/rados/librados_fwd.hpp"
+#include "cls_numops_ops.h"
#include <string>
namespace rados {
--- /dev/null
+#pragma once
+
+#include "include/rados/cls_traits.h"
+
+namespace rados::cls::numops {
+struct ClassId {
+ static constexpr auto name = "numops";
+};
+namespace method {
+constexpr auto add = ClsMethod<RdWrTag, ClassId>("add");
+constexpr auto mul = ClsMethod<RdWrTag, ClassId>("mul");
+}
+}
\ No newline at end of file
cls_method_handle_t h_remove_otp_op;
cls_method_handle_t h_get_current_time_op;
- cls_register("otp", &h_class);
- cls_register_cxx_method(h_class, "otp_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- otp_set_op, &h_set_otp_op);
- cls_register_cxx_method(h_class, "otp_get",
- CLS_METHOD_RD,
- otp_get_op, &h_get_otp_op);
- cls_register_cxx_method(h_class, "otp_check",
- CLS_METHOD_RD | CLS_METHOD_WR,
- otp_check_op, &h_check_otp_op);
- cls_register_cxx_method(h_class, "otp_get_result",
- CLS_METHOD_RD,
- otp_get_result, &h_get_result_op);
- cls_register_cxx_method(h_class, "otp_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- otp_remove_op, &h_remove_otp_op);
- cls_register_cxx_method(h_class, "get_current_time",
- CLS_METHOD_RD,
- otp_get_current_time_op, &h_get_current_time_op);
+ using namespace rados::cls::otp;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::set, otp_set_op, &h_set_otp_op);
+ cls.register_cxx_method(method::get, otp_get_op, &h_get_otp_op);
+ cls.register_cxx_method(method::check, otp_check_op, &h_check_otp_op);
+ cls.register_cxx_method(method::get_result, otp_get_result, &h_get_result_op);
+ cls.register_cxx_method(method::remove, otp_remove_op, &h_remove_otp_op);
+ cls.register_cxx_method(method::get_current_time, otp_get_current_time_op, &h_get_current_time_op);
return;
}
op.entries.push_back(config);
bufferlist in;
encode(op, in);
- rados_op->exec("otp", "otp_set", in);
+ rados_op->exec(method::set, in);
}
void OTP::set(librados::ObjectWriteOperation *rados_op,
op.entries = entries;
bufferlist in;
encode(op, in);
- rados_op->exec("otp", "otp_set", in);
+ rados_op->exec(method::set, in);
}
void OTP::remove(librados::ObjectWriteOperation *rados_op,
op.ids.push_back(id);
bufferlist in;
encode(op, in);
- rados_op->exec("otp", "otp_remove", in);
+ rados_op->exec(method::remove, in);
}
int OTP::check(CephContext *cct, librados::IoCtx& ioctx, const string& oid,
bufferlist out;
encode(op, in);
librados::ObjectWriteOperation wop;
- wop.exec("otp", "otp_check", in);
+ wop.exec(method::check, in);
int r = ioctx.operate(oid, &wop);
if (r < 0) {
return r;
bufferlist in2;
bufferlist out2;
encode(op2, in2);
- r = ioctx.exec(oid, "otp", "otp_get_result", in, out);
+ r = ioctx.exec(oid, method::get_result, in, out);
if (r < 0) {
return r;
}
bufferlist out;
int op_ret;
encode(op, in);
- rop->exec("otp", "otp_get", in, &out, &op_ret);
+ rop->exec(method::get, in, &out, &op_ret);
int r = ioctx.operate(oid, rop, nullptr);
if (r < 0) {
return r;
int op_ret;
encode(op, in);
ObjectReadOperation rop;
- rop.exec("otp", "get_current_time", in, &out, &op_ret);
+ rop.exec(method::get_current_time, in, &out, &op_ret);
int r = ioctx.operate(oid, &rop, nullptr);
if (r < 0) {
return r;
#include "include/types.h"
#include "include/utime.h"
#include "cls/otp/cls_otp_types.h"
+#include "include/rados/cls_traits.h"
struct cls_otp_set_otp_op
{
};
WRITE_CLASS_ENCODER(cls_otp_get_current_time_reply)
+namespace rados::cls::otp {
+struct ClassId {
+ static constexpr auto name = "otp";
+};
+namespace method {
+constexpr auto set = ClsMethod<RdWrTag, ClassId>("otp_set");
+constexpr auto get = ClsMethod<RdTag, ClassId>("otp_get");
+constexpr auto check = ClsMethod<RdWrTag, ClassId>("otp_check");
+constexpr auto get_result = ClsMethod<RdTag, ClassId>("otp_get_result");
+constexpr auto remove = ClsMethod<RdWrTag, ClassId>("otp_remove");
+constexpr auto get_current_time = ClsMethod<RdTag, ClassId>("get_current_time");
+}
+}
+
#endif
cls_method_handle_t h_queue_list_entries;
cls_method_handle_t h_queue_remove_entries;
- cls_register(QUEUE_CLASS, &h_class);
-
- /* queue*/
- cls_register_cxx_method(h_class, QUEUE_INIT, CLS_METHOD_RD | CLS_METHOD_WR, cls_queue_init, &h_queue_init);
- cls_register_cxx_method(h_class, QUEUE_GET_CAPACITY, CLS_METHOD_RD, cls_queue_get_capacity, &h_queue_get_capacity);
- cls_register_cxx_method(h_class, QUEUE_ENQUEUE, CLS_METHOD_RD | CLS_METHOD_WR, cls_queue_enqueue, &h_queue_enqueue);
- cls_register_cxx_method(h_class, QUEUE_LIST_ENTRIES, CLS_METHOD_RD, cls_queue_list_entries, &h_queue_list_entries);
- cls_register_cxx_method(h_class, QUEUE_REMOVE_ENTRIES, CLS_METHOD_RD | CLS_METHOD_WR, cls_queue_remove_entries, &h_queue_remove_entries);
-
+ using namespace cls::queue;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::init, cls_queue_init, &h_queue_init);
+ cls.register_cxx_method(method::get_capacity, cls_queue_get_capacity, &h_queue_get_capacity);
+ cls.register_cxx_method(method::enqueue, cls_queue_enqueue, &h_queue_enqueue);
+ cls.register_cxx_method(method::list_entries, cls_queue_list_entries, &h_queue_list_entries);
+ cls.register_cxx_method(method::remove_entries, cls_queue_remove_entries, &h_queue_remove_entries);
return;
}
using namespace std;
using namespace librados;
+using namespace cls::queue;
void cls_queue_init(ObjectWriteOperation& op, const string& queue_name, uint64_t size)
{
call.max_urgent_data_size = 0;
call.queue_size = size;
encode(call, in);
- op.exec(QUEUE_CLASS, QUEUE_INIT, in);
+ op.exec(method::init, in);
}
int cls_queue_get_capacity(IoCtx& io_ctx, const string& oid, uint64_t& size)
{
bufferlist in, out;
- int r = io_ctx.exec(oid, QUEUE_CLASS, QUEUE_GET_CAPACITY, in, out);
+ int r = io_ctx.exec(oid, method::get_capacity, in, out);
if (r < 0)
return r;
cls_queue_enqueue_op call;
call.bl_data_vec = std::move(bl_data_vec);
encode(call, in);
- op.exec(QUEUE_CLASS, QUEUE_ENQUEUE, in);
+ op.exec(method::enqueue, in);
}
int cls_queue_list_entries_inner(IoCtx& io_ctx, const string& oid, vector<cls_queue_entry>& entries,
bool *truncated, string& next_marker, bufferlist& in, bufferlist& out)
{
- int r = io_ctx.exec(oid, QUEUE_CLASS, QUEUE_LIST_ENTRIES, in, out);
+ int r = io_ctx.exec(oid, method::list_entries, in, out);
if (r < 0)
return r;
cls_queue_remove_op rem_op;
rem_op.end_marker = end_marker;
encode(rem_op, in);
- op.exec(QUEUE_CLASS, QUEUE_REMOVE_ENTRIES, in);
+ op.exec(method::remove_entries, in);
}
#define CEPH_CLS_QUEUE_OPS_H
#include "common/ceph_json.h"
-#include "cls/queue/cls_queue_types.h"
+#include "include/rados/cls_traits.h"
+#include "cls_queue_const.h"
+#include "cls_queue_types.h"
struct cls_queue_init_op {
uint64_t queue_size{0};
};
WRITE_CLASS_ENCODER(cls_queue_get_stats_ret)
+
+namespace cls::queue {
+struct ClassId {
+ static constexpr auto name = QUEUE_CLASS;
+};
+namespace method {
+constexpr auto init = ClsMethod<RdWrTag, ClassId>(QUEUE_INIT);
+constexpr auto get_capacity = ClsMethod<RdTag, ClassId>(QUEUE_GET_CAPACITY);
+constexpr auto enqueue = ClsMethod<RdWrTag, ClassId>(QUEUE_ENQUEUE);
+constexpr auto list_entries = ClsMethod<RdTag, ClassId>(QUEUE_LIST_ENTRIES);
+constexpr auto remove_entries = ClsMethod<RdWrTag, ClassId>(QUEUE_REMOVE_ENTRIES);
+}
+}
+
#endif /* CEPH_CLS_QUEUE_OPS_H */
cls_method_handle_t h_assert_snapc_seq;
cls_method_handle_t h_sparsify;
- cls_register("rbd", &h_class);
- cls_register_cxx_method(h_class, "create",
- CLS_METHOD_RD | CLS_METHOD_WR,
- create, &h_create);
- cls_register_cxx_method(h_class, "get_features",
- CLS_METHOD_RD,
- get_features, &h_get_features);
- cls_register_cxx_method(h_class, "set_features",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_features, &h_set_features);
- cls_register_cxx_method(h_class, "get_size",
- CLS_METHOD_RD,
- get_size, &h_get_size);
- cls_register_cxx_method(h_class, "set_size",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_size, &h_set_size);
- cls_register_cxx_method(h_class, "get_snapcontext",
- CLS_METHOD_RD,
- get_snapcontext, &h_get_snapcontext);
- cls_register_cxx_method(h_class, "get_object_prefix",
- CLS_METHOD_RD,
- get_object_prefix, &h_get_object_prefix);
- cls_register_cxx_method(h_class, "get_data_pool", CLS_METHOD_RD,
- get_data_pool, &h_get_data_pool);
- cls_register_cxx_method(h_class, "get_snapshot_name",
- CLS_METHOD_RD,
- get_snapshot_name, &h_get_snapshot_name);
- cls_register_cxx_method(h_class, "get_snapshot_timestamp",
- CLS_METHOD_RD,
- get_snapshot_timestamp, &h_get_snapshot_timestamp);
- cls_register_cxx_method(h_class, "snapshot_get",
- CLS_METHOD_RD,
- snapshot_get, &h_snapshot_get);
- cls_register_cxx_method(h_class, "snapshot_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- snapshot_add, &h_snapshot_add);
- cls_register_cxx_method(h_class, "snapshot_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- snapshot_remove, &h_snapshot_remove);
- cls_register_cxx_method(h_class, "snapshot_rename",
- CLS_METHOD_RD | CLS_METHOD_WR,
- snapshot_rename, &h_snapshot_rename);
- cls_register_cxx_method(h_class, "snapshot_trash_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- snapshot_trash_add, &h_snapshot_trash_add);
- cls_register_cxx_method(h_class, "get_all_features",
- CLS_METHOD_RD,
- get_all_features, &h_get_all_features);
+ using namespace cls::rbd;
+ cls_register(ClassId::name, &h_class);
+
+ ClassRegistrar<ClassId> cls(h_class);
+
+
+ cls.register_cxx_method(method::create, create, &h_create);
+ cls.register_cxx_method(method::get_features, get_features, &h_get_features);
+ cls.register_cxx_method(method::set_features, set_features, &h_set_features);
+ cls.register_cxx_method(method::get_size, get_size, &h_get_size);
+ cls.register_cxx_method(method::set_size, set_size, &h_set_size);
+ cls.register_cxx_method(method::get_snapcontext, get_snapcontext, &h_get_snapcontext);
+ cls.register_cxx_method(method::get_object_prefix, get_object_prefix, &h_get_object_prefix);
+ cls.register_cxx_method(method::get_data_pool, get_data_pool, &h_get_data_pool);
+ cls.register_cxx_method(method::get_snapshot_name, get_snapshot_name, &h_get_snapshot_name);
+ cls.register_cxx_method(method::get_snapshot_timestamp, get_snapshot_timestamp, &h_get_snapshot_timestamp);
+ cls.register_cxx_method(method::snapshot_get, snapshot_get, &h_snapshot_get);
+ cls.register_cxx_method(method::snapshot_add, snapshot_add, &h_snapshot_add);
+ cls.register_cxx_method(method::snapshot_remove, snapshot_remove, &h_snapshot_remove);
+ cls.register_cxx_method(method::snapshot_rename, snapshot_rename, &h_snapshot_rename);
+ cls.register_cxx_method(method::snapshot_trash_add, snapshot_trash_add, &h_snapshot_trash_add);
+ cls.register_cxx_method(method::get_all_features, get_all_features, &h_get_all_features);
// NOTE: deprecate v1 parent APIs after mimic EOLed
- cls_register_cxx_method(h_class, "get_parent",
- CLS_METHOD_RD,
- get_parent, &h_get_parent);
- cls_register_cxx_method(h_class, "set_parent",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_parent, &h_set_parent);
- cls_register_cxx_method(h_class, "remove_parent",
- CLS_METHOD_RD | CLS_METHOD_WR,
- remove_parent, &h_remove_parent);
-
- cls_register_cxx_method(h_class, "parent_get",
- CLS_METHOD_RD, parent_get, &h_parent_get);
- cls_register_cxx_method(h_class, "parent_overlap_get",
- CLS_METHOD_RD, parent_overlap_get,
- &h_parent_overlap_get);
- cls_register_cxx_method(h_class, "parent_attach",
- CLS_METHOD_RD | CLS_METHOD_WR,
- parent_attach, &h_parent_attach);
- cls_register_cxx_method(h_class, "parent_detach",
- CLS_METHOD_RD | CLS_METHOD_WR,
- parent_detach, &h_parent_detach);
-
- cls_register_cxx_method(h_class, "set_protection_status",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_protection_status, &h_set_protection_status);
- cls_register_cxx_method(h_class, "get_protection_status",
- CLS_METHOD_RD,
- get_protection_status, &h_get_protection_status);
- cls_register_cxx_method(h_class, "get_stripe_unit_count",
- CLS_METHOD_RD,
- get_stripe_unit_count, &h_get_stripe_unit_count);
- cls_register_cxx_method(h_class, "set_stripe_unit_count",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_stripe_unit_count, &h_set_stripe_unit_count);
- cls_register_cxx_method(h_class, "get_create_timestamp",
- CLS_METHOD_RD,
- get_create_timestamp, &h_get_create_timestamp);
- cls_register_cxx_method(h_class, "get_access_timestamp",
- CLS_METHOD_RD,
- get_access_timestamp, &h_get_access_timestamp);
- cls_register_cxx_method(h_class, "get_modify_timestamp",
- CLS_METHOD_RD,
- get_modify_timestamp, &h_get_modify_timestamp);
- cls_register_cxx_method(h_class, "get_flags",
- CLS_METHOD_RD,
- get_flags, &h_get_flags);
- cls_register_cxx_method(h_class, "set_flags",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_flags, &h_set_flags);
- cls_register_cxx_method(h_class, "op_features_get", CLS_METHOD_RD,
- op_features_get, &h_op_features_get);
- cls_register_cxx_method(h_class, "op_features_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- op_features_set, &h_op_features_set);
- cls_register_cxx_method(h_class, "metadata_list",
- CLS_METHOD_RD,
- metadata_list, &h_metadata_list);
- cls_register_cxx_method(h_class, "metadata_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- metadata_set, &h_metadata_set);
- cls_register_cxx_method(h_class, "metadata_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- metadata_remove, &h_metadata_remove);
- cls_register_cxx_method(h_class, "metadata_get",
- CLS_METHOD_RD,
- metadata_get, &h_metadata_get);
- cls_register_cxx_method(h_class, "snapshot_get_limit",
- CLS_METHOD_RD,
- snapshot_get_limit, &h_snapshot_get_limit);
- cls_register_cxx_method(h_class, "snapshot_set_limit",
- CLS_METHOD_RD | CLS_METHOD_WR,
- snapshot_set_limit, &h_snapshot_set_limit);
- cls_register_cxx_method(h_class, "child_attach",
- CLS_METHOD_RD | CLS_METHOD_WR,
- child_attach, &h_child_attach);
- cls_register_cxx_method(h_class, "child_detach",
- CLS_METHOD_RD | CLS_METHOD_WR,
- child_detach, &h_child_detach);
- cls_register_cxx_method(h_class, "children_list",
- CLS_METHOD_RD,
- children_list, &h_children_list);
- cls_register_cxx_method(h_class, "migration_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- migration_set, &h_migration_set);
- cls_register_cxx_method(h_class, "migration_set_state",
- CLS_METHOD_RD | CLS_METHOD_WR,
- migration_set_state, &h_migration_set_state);
- cls_register_cxx_method(h_class, "migration_get",
- CLS_METHOD_RD,
- migration_get, &h_migration_get);
- cls_register_cxx_method(h_class, "migration_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- migration_remove, &h_migration_remove);
-
- cls_register_cxx_method(h_class, "set_modify_timestamp",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_modify_timestamp, &h_set_modify_timestamp);
-
- cls_register_cxx_method(h_class, "set_access_timestamp",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_access_timestamp, &h_set_access_timestamp);
-
- /* methods for the rbd_children object */
- cls_register_cxx_method(h_class, "add_child",
- CLS_METHOD_RD | CLS_METHOD_WR,
- add_child, &h_add_child);
- cls_register_cxx_method(h_class, "remove_child",
- CLS_METHOD_RD | CLS_METHOD_WR,
- remove_child, &h_remove_child);
- cls_register_cxx_method(h_class, "get_children",
- CLS_METHOD_RD,
- get_children, &h_get_children);
+ cls.register_cxx_method(method::get_parent, get_parent, &h_get_parent);
+ cls.register_cxx_method(method::set_parent, set_parent, &h_set_parent);
+ cls.register_cxx_method(method::remove_parent, remove_parent, &h_remove_parent);
+
+ // Parent/Layering (V2 APIs)
+ cls.register_cxx_method(method::parent_get, parent_get, &h_parent_get);
+ cls.register_cxx_method(method::parent_overlap_get, parent_overlap_get, &h_parent_overlap_get);
+ cls.register_cxx_method(method::parent_attach, parent_attach, &h_parent_attach);
+ cls.register_cxx_method(method::parent_detach, parent_detach, &h_parent_detach);
+
+ cls.register_cxx_method(method::set_protection_status, set_protection_status, &h_set_protection_status);
+ cls.register_cxx_method(method::get_protection_status, get_protection_status, &h_get_protection_status);
+ cls.register_cxx_method(method::get_stripe_unit_count, get_stripe_unit_count, &h_get_stripe_unit_count);
+ cls.register_cxx_method(method::set_stripe_unit_count, set_stripe_unit_count, &h_set_stripe_unit_count);
+ cls.register_cxx_method(method::get_create_timestamp, get_create_timestamp, &h_get_create_timestamp);
+ cls.register_cxx_method(method::get_access_timestamp, get_access_timestamp, &h_get_access_timestamp);
+ cls.register_cxx_method(method::get_modify_timestamp, get_modify_timestamp, &h_get_modify_timestamp);
+ cls.register_cxx_method(method::get_flags, get_flags, &h_get_flags);
+ cls.register_cxx_method(method::set_flags, set_flags, &h_set_flags);
+ cls.register_cxx_method(method::op_features_get, op_features_get, &h_op_features_get);
+ cls.register_cxx_method(method::op_features_set, op_features_set, &h_op_features_set);
+ cls.register_cxx_method(method::metadata_list, metadata_list, &h_metadata_list);
+ cls.register_cxx_method(method::metadata_set, metadata_set, &h_metadata_set);
+ cls.register_cxx_method(method::metadata_remove, metadata_remove, &h_metadata_remove);
+ cls.register_cxx_method(method::metadata_get, metadata_get, &h_metadata_get);
+ cls.register_cxx_method(method::snapshot_get_limit, snapshot_get_limit, &h_snapshot_get_limit);
+ cls.register_cxx_method(method::snapshot_set_limit, snapshot_set_limit, &h_snapshot_set_limit);
+ cls.register_cxx_method(method::child_attach, child_attach, &h_child_attach);
+ cls.register_cxx_method(method::child_detach, child_detach, &h_child_detach);
+ cls.register_cxx_method(method::children_list, children_list, &h_children_list);
+ cls.register_cxx_method(method::migration_set, migration_set, &h_migration_set);
+ cls.register_cxx_method(method::migration_set_state, migration_set_state, &h_migration_set_state);
+ cls.register_cxx_method(method::migration_get, migration_get, &h_migration_get);
+ cls.register_cxx_method(method::migration_remove, migration_remove, &h_migration_remove);
+
+ cls.register_cxx_method(method::set_modify_timestamp, set_modify_timestamp, &h_set_modify_timestamp);
+
+ cls.register_cxx_method(method::set_access_timestamp, set_access_timestamp, &h_set_access_timestamp);
+
+ cls.register_cxx_method(method::add_child, add_child, &h_add_child);
+ cls.register_cxx_method(method::remove_child, remove_child, &h_remove_child);
+ cls.register_cxx_method(method::get_children, get_children, &h_get_children);
/* methods for the rbd_id.$image_name objects */
- cls_register_cxx_method(h_class, "get_id",
- CLS_METHOD_RD,
- get_id, &h_get_id);
- cls_register_cxx_method(h_class, "set_id",
- CLS_METHOD_RD | CLS_METHOD_WR,
- set_id, &h_set_id);
+ cls.register_cxx_method(method::get_id, get_id, &h_get_id);
+ cls.register_cxx_method(method::set_id, set_id, &h_set_id);
/* methods for the rbd_directory object */
- cls_register_cxx_method(h_class, "dir_get_id",
- CLS_METHOD_RD,
- dir_get_id, &h_dir_get_id);
- cls_register_cxx_method(h_class, "dir_get_name",
- CLS_METHOD_RD,
- dir_get_name, &h_dir_get_name);
- cls_register_cxx_method(h_class, "dir_list",
- CLS_METHOD_RD,
- dir_list, &h_dir_list);
- cls_register_cxx_method(h_class, "dir_add_image",
- CLS_METHOD_RD | CLS_METHOD_WR,
- dir_add_image, &h_dir_add_image);
- cls_register_cxx_method(h_class, "dir_remove_image",
- CLS_METHOD_RD | CLS_METHOD_WR,
- dir_remove_image, &h_dir_remove_image);
- cls_register_cxx_method(h_class, "dir_rename_image",
- CLS_METHOD_RD | CLS_METHOD_WR,
- dir_rename_image, &h_dir_rename_image);
- cls_register_cxx_method(h_class, "dir_state_assert", CLS_METHOD_RD,
- dir_state_assert, &h_dir_state_assert);
- cls_register_cxx_method(h_class, "dir_state_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- dir_state_set, &h_dir_state_set);
+ cls.register_cxx_method(method::dir_get_id, dir_get_id, &h_dir_get_id);
+ cls.register_cxx_method(method::dir_get_name, dir_get_name, &h_dir_get_name);
+ cls.register_cxx_method(method::dir_list, dir_list, &h_dir_list);
+ cls.register_cxx_method(method::dir_add_image, dir_add_image, &h_dir_add_image);
+ cls.register_cxx_method(method::dir_remove_image, dir_remove_image, &h_dir_remove_image);
+ cls.register_cxx_method(method::dir_rename_image, dir_rename_image, &h_dir_rename_image);
+ cls.register_cxx_method(method::dir_state_assert, dir_state_assert, &h_dir_state_assert);
+ cls.register_cxx_method(method::dir_state_set, dir_state_set, &h_dir_state_set);
/* methods for the rbd_object_map.$image_id object */
- cls_register_cxx_method(h_class, "object_map_load",
- CLS_METHOD_RD,
- object_map_load, &h_object_map_load);
- cls_register_cxx_method(h_class, "object_map_save",
- CLS_METHOD_RD | CLS_METHOD_WR,
- object_map_save, &h_object_map_save);
- cls_register_cxx_method(h_class, "object_map_resize",
- CLS_METHOD_RD | CLS_METHOD_WR,
- object_map_resize, &h_object_map_resize);
- cls_register_cxx_method(h_class, "object_map_update",
- CLS_METHOD_RD | CLS_METHOD_WR,
- object_map_update, &h_object_map_update);
- cls_register_cxx_method(h_class, "object_map_snap_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- object_map_snap_add, &h_object_map_snap_add);
- cls_register_cxx_method(h_class, "object_map_snap_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- object_map_snap_remove, &h_object_map_snap_remove);
+ cls.register_cxx_method(method::object_map_load, object_map_load, &h_object_map_load);
+ cls.register_cxx_method(method::object_map_save, object_map_save, &h_object_map_save);
+ cls.register_cxx_method(method::object_map_resize, object_map_resize, &h_object_map_resize);
+ cls.register_cxx_method(method::object_map_update, object_map_update, &h_object_map_update);
+ cls.register_cxx_method(method::object_map_snap_add, object_map_snap_add, &h_object_map_snap_add);
+ cls.register_cxx_method(method::object_map_snap_remove, object_map_snap_remove, &h_object_map_snap_remove);
/* methods for the old format */
- cls_register_cxx_method(h_class, "snap_list",
- CLS_METHOD_RD,
- old_snapshots_list, &h_old_snapshots_list);
- cls_register_cxx_method(h_class, "snap_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- old_snapshot_add, &h_old_snapshot_add);
- cls_register_cxx_method(h_class, "snap_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- old_snapshot_remove, &h_old_snapshot_remove);
- cls_register_cxx_method(h_class, "snap_rename",
- CLS_METHOD_RD | CLS_METHOD_WR,
- old_snapshot_rename, &h_old_snapshot_rename);
+ cls.register_cxx_method(method::snap_list, old_snapshots_list, &h_old_snapshots_list);
+ cls.register_cxx_method(method::snap_add, old_snapshot_add, &h_old_snapshot_add);
+ cls.register_cxx_method(method::snap_remove, old_snapshot_remove, &h_old_snapshot_remove);
+ cls.register_cxx_method(method::snap_rename, old_snapshot_rename, &h_old_snapshot_rename);
/* methods for the rbd_mirroring object */
- cls_register_cxx_method(h_class, "mirror_uuid_get", CLS_METHOD_RD,
- mirror_uuid_get, &h_mirror_uuid_get);
- cls_register_cxx_method(h_class, "mirror_uuid_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_uuid_set, &h_mirror_uuid_set);
- cls_register_cxx_method(h_class, "mirror_mode_get", CLS_METHOD_RD,
- mirror_mode_get, &h_mirror_mode_get);
- cls_register_cxx_method(h_class, "mirror_mode_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_mode_set, &h_mirror_mode_set);
- cls_register_cxx_method(h_class, "mirror_remote_namespace_get",
- CLS_METHOD_RD, mirror_remote_namespace_get,
- &h_mirror_remote_namespace_get);
- cls_register_cxx_method(h_class, "mirror_remote_namespace_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_remote_namespace_set,
- &h_mirror_remote_namespace_set);
- cls_register_cxx_method(h_class, "mirror_peer_ping",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_peer_ping, &h_mirror_peer_ping);
- cls_register_cxx_method(h_class, "mirror_peer_list", CLS_METHOD_RD,
- mirror_peer_list, &h_mirror_peer_list);
- cls_register_cxx_method(h_class, "mirror_peer_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_peer_add, &h_mirror_peer_add);
- cls_register_cxx_method(h_class, "mirror_peer_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_peer_remove, &h_mirror_peer_remove);
- cls_register_cxx_method(h_class, "mirror_peer_set_client",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_peer_set_client, &h_mirror_peer_set_client);
- cls_register_cxx_method(h_class, "mirror_peer_set_cluster",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_peer_set_cluster, &h_mirror_peer_set_cluster);
- cls_register_cxx_method(h_class, "mirror_peer_set_direction",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_peer_set_direction,
- &h_mirror_peer_set_direction);
- cls_register_cxx_method(h_class, "mirror_image_list", CLS_METHOD_RD,
- mirror_image_list, &h_mirror_image_list);
- cls_register_cxx_method(h_class, "mirror_image_get_image_id", CLS_METHOD_RD,
- mirror_image_get_image_id,
- &h_mirror_image_get_image_id);
- cls_register_cxx_method(h_class, "mirror_image_get", CLS_METHOD_RD,
- mirror_image_get, &h_mirror_image_get);
- cls_register_cxx_method(h_class, "mirror_image_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_image_set, &h_mirror_image_set);
- cls_register_cxx_method(h_class, "mirror_image_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_image_remove, &h_mirror_image_remove);
- cls_register_cxx_method(h_class, "mirror_image_status_set",
- CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- mirror_image_status_set, &h_mirror_image_status_set);
- cls_register_cxx_method(h_class, "mirror_image_status_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_image_status_remove,
- &h_mirror_image_status_remove);
- cls_register_cxx_method(h_class, "mirror_image_status_get", CLS_METHOD_RD,
- mirror_image_status_get, &h_mirror_image_status_get);
- cls_register_cxx_method(h_class, "mirror_image_status_list", CLS_METHOD_RD,
- mirror_image_status_list,
- &h_mirror_image_status_list);
- cls_register_cxx_method(h_class, "mirror_image_status_get_summary",
- CLS_METHOD_RD, mirror_image_status_get_summary,
- &h_mirror_image_status_get_summary);
- cls_register_cxx_method(h_class, "mirror_image_status_remove_down",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_image_status_remove_down,
- &h_mirror_image_status_remove_down);
- cls_register_cxx_method(h_class, "mirror_image_instance_get", CLS_METHOD_RD,
- mirror_image_instance_get,
- &h_mirror_image_instance_get);
- cls_register_cxx_method(h_class, "mirror_image_instance_list", CLS_METHOD_RD,
- mirror_image_instance_list,
- &h_mirror_image_instance_list);
- cls_register_cxx_method(h_class, "mirror_instances_list", CLS_METHOD_RD,
- mirror_instances_list, &h_mirror_instances_list);
- cls_register_cxx_method(h_class, "mirror_instances_add",
- CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE,
- mirror_instances_add, &h_mirror_instances_add);
- cls_register_cxx_method(h_class, "mirror_instances_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_instances_remove,
- &h_mirror_instances_remove);
- cls_register_cxx_method(h_class, "mirror_image_map_list",
- CLS_METHOD_RD, mirror_image_map_list,
- &h_mirror_image_map_list);
- cls_register_cxx_method(h_class, "mirror_image_map_update",
- CLS_METHOD_WR, mirror_image_map_update,
- &h_mirror_image_map_update);
- cls_register_cxx_method(h_class, "mirror_image_map_remove",
- CLS_METHOD_WR, mirror_image_map_remove,
- &h_mirror_image_map_remove);
- cls_register_cxx_method(h_class, "mirror_image_snapshot_unlink_peer",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_image_snapshot_unlink_peer,
- &h_mirror_image_snapshot_unlink_peer);
- cls_register_cxx_method(h_class, "mirror_image_snapshot_set_copy_progress",
- CLS_METHOD_RD | CLS_METHOD_WR,
- mirror_image_snapshot_set_copy_progress,
- &h_mirror_image_snapshot_set_copy_progress);
+ cls.register_cxx_method(method::mirror_uuid_get, mirror_uuid_get, &h_mirror_uuid_get);
+ cls.register_cxx_method(method::mirror_uuid_set, mirror_uuid_set, &h_mirror_uuid_set);
+ cls.register_cxx_method(method::mirror_mode_get, mirror_mode_get, &h_mirror_mode_get);
+ cls.register_cxx_method(method::mirror_mode_set, mirror_mode_set, &h_mirror_mode_set);
+ cls.register_cxx_method(method::mirror_remote_namespace_get, mirror_remote_namespace_get, &h_mirror_remote_namespace_get);
+ cls.register_cxx_method(method::mirror_remote_namespace_set, mirror_remote_namespace_set, &h_mirror_remote_namespace_set);
+ cls.register_cxx_method(method::mirror_peer_ping, mirror_peer_ping, &h_mirror_peer_ping);
+ cls.register_cxx_method(method::mirror_peer_list, mirror_peer_list, &h_mirror_peer_list);
+ cls.register_cxx_method(method::mirror_peer_add, mirror_peer_add, &h_mirror_peer_add);
+ cls.register_cxx_method(method::mirror_peer_remove, mirror_peer_remove, &h_mirror_peer_remove);
+ cls.register_cxx_method(method::mirror_peer_set_client, mirror_peer_set_client, &h_mirror_peer_set_client);
+ cls.register_cxx_method(method::mirror_peer_set_cluster, mirror_peer_set_cluster, &h_mirror_peer_set_cluster);
+ cls.register_cxx_method(method::mirror_peer_set_direction, mirror_peer_set_direction, &h_mirror_peer_set_direction);
+ cls.register_cxx_method(method::mirror_image_list, mirror_image_list, &h_mirror_image_list);
+ cls.register_cxx_method(method::mirror_image_get_image_id, mirror_image_get_image_id, &h_mirror_image_get_image_id);
+ cls.register_cxx_method(method::mirror_image_get, mirror_image_get, &h_mirror_image_get);
+ cls.register_cxx_method(method::mirror_image_set, mirror_image_set, &h_mirror_image_set);
+ cls.register_cxx_method(method::mirror_image_remove, mirror_image_remove, &h_mirror_image_remove);
+ cls.register_cxx_method(method::mirror_image_status_set, mirror_image_status_set, &h_mirror_image_status_set);
+ cls.register_cxx_method(method::mirror_image_status_remove, mirror_image_status_remove, &h_mirror_image_status_remove);
+ cls.register_cxx_method(method::mirror_image_status_get, mirror_image_status_get, &h_mirror_image_status_get);
+ cls.register_cxx_method(method::mirror_image_status_list, mirror_image_status_list, &h_mirror_image_status_list);
+ cls.register_cxx_method(method::mirror_image_status_get_summary, mirror_image_status_get_summary, &h_mirror_image_status_get_summary);
+ cls.register_cxx_method(method::mirror_image_status_remove_down, mirror_image_status_remove_down, &h_mirror_image_status_remove_down);
+ cls.register_cxx_method(method::mirror_image_instance_get, mirror_image_instance_get, &h_mirror_image_instance_get);
+ cls.register_cxx_method(method::mirror_image_instance_list, mirror_image_instance_list, &h_mirror_image_instance_list);
+ cls.register_cxx_method(method::mirror_instances_list, mirror_instances_list, &h_mirror_instances_list);
+ cls.register_cxx_method(method::mirror_instances_add, mirror_instances_add, &h_mirror_instances_add);
+ cls.register_cxx_method(method::mirror_instances_remove, mirror_instances_remove, &h_mirror_instances_remove);
+ cls.register_cxx_method(method::mirror_image_map_list, mirror_image_map_list, &h_mirror_image_map_list);
+ cls.register_cxx_method(method::mirror_image_map_update, mirror_image_map_update, &h_mirror_image_map_update);
+ cls.register_cxx_method(method::mirror_image_map_remove, mirror_image_map_remove, &h_mirror_image_map_remove);
+ cls.register_cxx_method(method::mirror_image_snapshot_unlink_peer, mirror_image_snapshot_unlink_peer, &h_mirror_image_snapshot_unlink_peer);
+ cls.register_cxx_method(method::mirror_image_snapshot_set_copy_progress, mirror_image_snapshot_set_copy_progress, &h_mirror_image_snapshot_set_copy_progress);
/* methods for the groups feature */
- cls_register_cxx_method(h_class, "group_dir_list",
- CLS_METHOD_RD,
- group_dir_list, &h_group_dir_list);
- cls_register_cxx_method(h_class, "group_dir_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_dir_add, &h_group_dir_add);
- cls_register_cxx_method(h_class, "group_dir_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_dir_remove, &h_group_dir_remove);
- cls_register_cxx_method(h_class, "group_dir_rename",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_dir_rename, &h_group_dir_rename);
- cls_register_cxx_method(h_class, "group_image_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_image_remove, &h_group_image_remove);
- cls_register_cxx_method(h_class, "group_image_list",
- CLS_METHOD_RD,
- group_image_list, &h_group_image_list);
- cls_register_cxx_method(h_class, "group_image_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_image_set, &h_group_image_set);
- cls_register_cxx_method(h_class, "image_group_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- image_group_add, &h_image_group_add);
- cls_register_cxx_method(h_class, "image_group_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- image_group_remove, &h_image_group_remove);
- cls_register_cxx_method(h_class, "image_group_get",
- CLS_METHOD_RD,
- image_group_get, &h_image_group_get);
- cls_register_cxx_method(h_class, "group_snap_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_snap_set, &h_group_snap_set);
- cls_register_cxx_method(h_class, "group_snap_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- group_snap_remove, &h_group_snap_remove);
- cls_register_cxx_method(h_class, "group_snap_get_by_id",
- CLS_METHOD_RD,
- group_snap_get_by_id, &h_group_snap_get_by_id);
- cls_register_cxx_method(h_class, "group_snap_list",
- CLS_METHOD_RD,
- group_snap_list, &h_group_snap_list);
- cls_register_cxx_method(h_class, "group_snap_list_order",
- CLS_METHOD_RD,
- group_snap_list_order, &h_group_snap_list_order);
+ cls.register_cxx_method(method::group_dir_list, group_dir_list, &h_group_dir_list);
+ cls.register_cxx_method(method::group_dir_add, group_dir_add, &h_group_dir_add);
+ cls.register_cxx_method(method::group_dir_remove, group_dir_remove, &h_group_dir_remove);
+ cls.register_cxx_method(method::group_dir_rename, group_dir_rename, &h_group_dir_rename);
+ cls.register_cxx_method(method::group_image_remove, group_image_remove, &h_group_image_remove);
+ cls.register_cxx_method(method::group_image_list, group_image_list, &h_group_image_list);
+ cls.register_cxx_method(method::group_image_set, group_image_set, &h_group_image_set);
+ cls.register_cxx_method(method::image_group_add, image_group_add, &h_image_group_add);
+ cls.register_cxx_method(method::image_group_remove, image_group_remove, &h_image_group_remove);
+ cls.register_cxx_method(method::image_group_get, image_group_get, &h_image_group_get);
+ cls.register_cxx_method(method::group_snap_set, group_snap_set, &h_group_snap_set);
+ cls.register_cxx_method(method::group_snap_remove, group_snap_remove, &h_group_snap_remove);
+ cls.register_cxx_method(method::group_snap_get_by_id, group_snap_get_by_id, &h_group_snap_get_by_id);
+ cls.register_cxx_method(method::group_snap_list, group_snap_list, &h_group_snap_list);
+ cls.register_cxx_method(method::group_snap_list_order, group_snap_list_order, &h_group_snap_list_order);
/* rbd_trash object methods */
- cls_register_cxx_method(h_class, "trash_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- trash_add, &h_trash_add);
- cls_register_cxx_method(h_class, "trash_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- trash_remove, &h_trash_remove);
- cls_register_cxx_method(h_class, "trash_list",
- CLS_METHOD_RD,
- trash_list, &h_trash_list);
- cls_register_cxx_method(h_class, "trash_get",
- CLS_METHOD_RD,
- trash_get, &h_trash_get);
- cls_register_cxx_method(h_class, "trash_state_set",
- CLS_METHOD_RD | CLS_METHOD_WR,
- trash_state_set, &h_trash_state_set);
+ cls.register_cxx_method(method::trash_add, trash_add, &h_trash_add);
+ cls.register_cxx_method(method::trash_remove, trash_remove, &h_trash_remove);
+ cls.register_cxx_method(method::trash_list, trash_list, &h_trash_list);
+ cls.register_cxx_method(method::trash_get, trash_get, &h_trash_get);
+ cls.register_cxx_method(method::trash_state_set, trash_state_set, &h_trash_state_set);
/* rbd_namespace object methods */
- cls_register_cxx_method(h_class, "namespace_add",
- CLS_METHOD_RD | CLS_METHOD_WR,
- namespace_add, &h_namespace_add);
- cls_register_cxx_method(h_class, "namespace_remove",
- CLS_METHOD_RD | CLS_METHOD_WR,
- namespace_remove, &h_namespace_remove);
- cls_register_cxx_method(h_class, "namespace_list", CLS_METHOD_RD,
- namespace_list, &h_namespace_list);
+ cls.register_cxx_method(method::namespace_add, namespace_add, &h_namespace_add);
+ cls.register_cxx_method(method::namespace_remove, namespace_remove, &h_namespace_remove);
+ cls.register_cxx_method(method::namespace_list, namespace_list, &h_namespace_list);
/* data object methods */
- cls_register_cxx_method(h_class, "copyup",
- CLS_METHOD_RD | CLS_METHOD_WR,
- copyup, &h_copyup);
- cls_register_cxx_method(h_class, "sparse_copyup",
- CLS_METHOD_RD | CLS_METHOD_WR,
- sparse_copyup, &h_sparse_copyup);
- cls_register_cxx_method(h_class, "assert_snapc_seq",
- CLS_METHOD_RD | CLS_METHOD_WR,
- assert_snapc_seq,
- &h_assert_snapc_seq);
- cls_register_cxx_method(h_class, "sparsify",
- CLS_METHOD_RD | CLS_METHOD_WR,
- sparsify, &h_sparsify);
+ cls.register_cxx_method(method::copyup, copyup, &h_copyup);
+ cls.register_cxx_method(method::sparse_copyup, sparse_copyup, &h_sparse_copyup);
+ cls.register_cxx_method(method::assert_snapc_seq, assert_snapc_seq, &h_assert_snapc_seq);
+ cls.register_cxx_method(method::sparsify, sparsify, &h_sparsify);
}
using ceph::decode;
using ceph::encode;
+using namespace cls::rbd;
+
void create_image(librados::ObjectWriteOperation *op, uint64_t size,
uint8_t order, uint64_t features,
const std::string &object_prefix, int64_t data_pool_id)
encode(object_prefix, bl);
encode(data_pool_id, bl);
- op->exec("rbd", "create", bl);
+ op->exec(method::create, bl);
}
int create_image(librados::IoCtx *ioctx, const std::string &oid,
bufferlist bl;
encode(static_cast<uint64_t>(CEPH_NOSNAP), bl);
encode(read_only, bl);
- op->exec("rbd", "get_features", bl);
+ op->exec(method::get_features, bl);
}
int get_features_finish(bufferlist::const_iterator *it, uint64_t *features,
encode(features, bl);
encode(mask, bl);
- op->exec("rbd", "set_features", bl);
+ op->exec(method::set_features, bl);
}
int set_features(librados::IoCtx *ioctx, const std::string &oid,
void get_object_prefix_start(librados::ObjectReadOperation *op)
{
bufferlist bl;
- op->exec("rbd", "get_object_prefix", bl);
+ op->exec(method::get_object_prefix, bl);
}
int get_object_prefix_finish(bufferlist::const_iterator *it,
void get_data_pool_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("rbd", "get_data_pool", bl);
+ op->exec(method::get_data_pool, bl);
}
int get_data_pool_finish(bufferlist::const_iterator *it, int64_t *data_pool_id) {
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "get_size", bl);
+ op->exec(method::get_size, bl);
}
int get_size_finish(bufferlist::const_iterator *it, uint64_t *size,
{
bufferlist bl;
encode(size, bl);
- op->exec("rbd", "set_size", bl);
+ op->exec(method::set_size, bl);
}
void get_flags_start(librados::ObjectReadOperation *op, snapid_t snap_id) {
bufferlist in_bl;
encode(static_cast<snapid_t>(snap_id), in_bl);
- op->exec("rbd", "get_flags", in_bl);
+ op->exec(method::get_flags, in_bl);
}
int get_flags_finish(bufferlist::const_iterator *it, uint64_t *flags) {
encode(flags, inbl);
encode(mask, inbl);
encode(snap_id, inbl);
- op->exec("rbd", "set_flags", inbl);
+ op->exec(method::set_flags, inbl);
}
void op_features_get_start(librados::ObjectReadOperation *op)
{
bufferlist in_bl;
- op->exec("rbd", "op_features_get", in_bl);
+ op->exec(method::op_features_get, in_bl);
}
int op_features_get_finish(bufferlist::const_iterator *it, uint64_t *op_features)
bufferlist inbl;
encode(op_features, inbl);
encode(mask, inbl);
- op->exec("rbd", "op_features_set", inbl);
+ op->exec(method::op_features_set, inbl);
}
int op_features_set(librados::IoCtx *ioctx, const std::string &oid,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "get_parent", bl);
+ op->exec(method::get_parent, bl);
}
int get_parent_finish(bufferlist::const_iterator *it,
encode(pspec.snap_id, in_bl);
encode(parent_overlap, in_bl);
- op->exec("rbd", "set_parent", in_bl);
+ op->exec(method::set_parent, in_bl);
}
int remove_parent(librados::IoCtx *ioctx, const std::string &oid)
void remove_parent(librados::ObjectWriteOperation *op)
{
bufferlist inbl;
- op->exec("rbd", "remove_parent", inbl);
+ op->exec(method::remove_parent, inbl);
}
void parent_get_start(librados::ObjectReadOperation* op) {
bufferlist in_bl;
- op->exec("rbd", "parent_get", in_bl);
+ op->exec(method::parent_get, in_bl);
}
int parent_get_finish(bufferlist::const_iterator* it,
snapid_t snap_id) {
bufferlist in_bl;
encode(snap_id, in_bl);
- op->exec("rbd", "parent_overlap_get", in_bl);
+ op->exec(method::parent_overlap_get, in_bl);
}
int parent_overlap_get_finish(bufferlist::const_iterator* it,
encode(parent_image_spec, in_bl);
encode(parent_overlap, in_bl);
encode(reattach, in_bl);
- op->exec("rbd", "parent_attach", in_bl);
+ op->exec(method::parent_attach, in_bl);
}
int parent_attach(librados::IoCtx *ioctx, const std::string &oid,
void parent_detach(librados::ObjectWriteOperation* op) {
bufferlist in_bl;
- op->exec("rbd", "parent_detach", in_bl);
+ op->exec(method::parent_detach, in_bl);
}
int parent_detach(librados::IoCtx *ioctx, const std::string &oid) {
encode(pspec.snap_id, in);
encode(c_imageid, in);
- op->exec("rbd", "add_child", in);
+ op->exec(method::add_child, in);
}
void remove_child(librados::ObjectWriteOperation *op,
encode(pspec.image_id, in);
encode(pspec.snap_id, in);
encode(c_imageid, in);
- op->exec("rbd", "remove_child", in);
+ op->exec(method::remove_child, in);
}
int remove_child(librados::IoCtx *ioctx, const std::string &oid,
encode(pspec.pool_id, in_bl);
encode(pspec.image_id, in_bl);
encode(pspec.snap_id, in_bl);
- op->exec("rbd", "get_children", in_bl);
+ op->exec(method::get_children, in_bl);
}
int get_children_finish(bufferlist::const_iterator *it,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "snapshot_get", bl);
+ op->exec(method::snapshot_get, bl);
}
int snapshot_get_finish(bufferlist::const_iterator* it,
encode(snap_name, bl);
encode(snap_id, bl);
encode(snap_namespace, bl);
- op->exec("rbd", "snapshot_add", bl);
+ op->exec(method::snapshot_add, bl);
}
void snapshot_remove(librados::ObjectWriteOperation *op, snapid_t snap_id)
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "snapshot_remove", bl);
+ op->exec(method::snapshot_remove, bl);
}
void snapshot_rename(librados::ObjectWriteOperation *op,
bufferlist bl;
encode(src_snap_id, bl);
encode(dst_name, bl);
- op->exec("rbd", "snapshot_rename", bl);
+ op->exec(method::snapshot_rename, bl);
}
void snapshot_trash_add(librados::ObjectWriteOperation *op,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "snapshot_trash_add", bl);
+ op->exec(method::snapshot_trash_add, bl);
}
void get_snapcontext_start(librados::ObjectReadOperation *op)
{
bufferlist bl;
- op->exec("rbd", "get_snapcontext", bl);
+ op->exec(method::get_snapcontext, bl);
}
int get_snapcontext_finish(bufferlist::const_iterator *it,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "get_snapshot_name", bl);
+ op->exec(method::get_snapshot_name, bl);
}
int get_snapshot_name_finish(bufferlist::const_iterator *it,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "get_snapshot_timestamp", bl);
+ op->exec(method::get_snapshot_timestamp, bl);
}
int get_snapshot_timestamp_finish(bufferlist::const_iterator *it,
bufferlist bl;
encode(snap_name, bl);
encode(snap_id, bl);
- op->exec("rbd", "snap_add", bl);
+ op->exec(method::snap_add, bl);
}
void old_snapshot_remove(librados::ObjectWriteOperation *op,
{
bufferlist bl;
encode(snap_name, bl);
- op->exec("rbd", "snap_remove", bl);
+ op->exec(method::snap_remove, bl);
}
void old_snapshot_rename(librados::ObjectWriteOperation *op,
bufferlist bl;
encode(src_snap_id, bl);
encode(dst_name, bl);
- op->exec("rbd", "snap_rename", bl);
+ op->exec(method::snap_rename, bl);
}
void old_snapshot_list_start(librados::ObjectReadOperation *op) {
bufferlist in_bl;
- op->exec("rbd", "snap_list", in_bl);
+ op->exec(method::snap_list, in_bl);
}
int old_snapshot_list_finish(bufferlist::const_iterator *it,
void get_all_features_start(librados::ObjectReadOperation *op) {
bufferlist in;
- op->exec("rbd", "get_all_features", in);
+ op->exec(method::get_all_features, in);
}
int get_all_features_finish(bufferlist::const_iterator *it,
template <typename O>
void copyup(O* op, ceph::buffer::list data) {
- op->exec("rbd", "copyup", data);
+ op->exec(method::copyup, data);
}
void copyup(neorados::WriteOp* op, ceph::buffer::list data) {
bufferlist bl;
encode(extent_map, bl);
encode(data, bl);
- op->exec("rbd", "sparse_copyup", bl);
+ op->exec(method::sparse_copyup, bl);
}
void sparse_copyup(neorados::WriteOp* op,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "get_protection_status", bl);
+ op->exec(method::get_protection_status, bl);
}
int get_protection_status_finish(bufferlist::const_iterator *it,
bufferlist in;
encode(snap_id, in);
encode(protection_status, in);
- op->exec("rbd", "set_protection_status", in);
+ op->exec(method::set_protection_status, in);
}
void snapshot_get_limit_start(librados::ObjectReadOperation *op)
{
bufferlist bl;
- op->exec("rbd", "snapshot_get_limit", bl);
+ op->exec(method::snapshot_get_limit, bl);
}
int snapshot_get_limit_finish(bufferlist::const_iterator *it, uint64_t *limit)
{
bufferlist in;
encode(limit, in);
- op->exec("rbd", "snapshot_set_limit", in);
+ op->exec(method::snapshot_set_limit, in);
}
void get_stripe_unit_count_start(librados::ObjectReadOperation *op) {
bufferlist empty_bl;
- op->exec("rbd", "get_stripe_unit_count", empty_bl);
+ op->exec(method::get_stripe_unit_count, empty_bl);
}
int get_stripe_unit_count_finish(bufferlist::const_iterator *it,
encode(stripe_unit, bl);
encode(stripe_count, bl);
- op->exec("rbd", "set_stripe_unit_count", bl);
+ op->exec(method::set_stripe_unit_count, bl);
}
int set_stripe_unit_count(librados::IoCtx *ioctx, const std::string &oid,
void get_create_timestamp_start(librados::ObjectReadOperation *op) {
bufferlist empty_bl;
- op->exec("rbd", "get_create_timestamp", empty_bl);
+ op->exec(method::get_create_timestamp, empty_bl);
}
int get_create_timestamp_finish(bufferlist::const_iterator *it,
void get_access_timestamp_start(librados::ObjectReadOperation *op) {
bufferlist empty_bl;
- op->exec("rbd", "get_access_timestamp", empty_bl);
+ op->exec(method::get_access_timestamp, empty_bl);
}
int get_access_timestamp_finish(bufferlist::const_iterator *it,
void set_access_timestamp(librados::ObjectWriteOperation *op)
{
bufferlist empty_bl;
- op->exec("rbd","set_access_timestamp",empty_bl);
+ op->exec(method::set_access_timestamp,empty_bl);
}
int set_access_timestamp(librados::IoCtx *ioctx, const std::string &oid)
void get_modify_timestamp_start(librados::ObjectReadOperation *op) {
bufferlist empty_bl;
- op->exec("rbd", "get_modify_timestamp", empty_bl);
+ op->exec(method::get_modify_timestamp, empty_bl);
}
int get_modify_timestamp_finish(bufferlist::const_iterator *it,
void set_modify_timestamp(librados::ObjectWriteOperation *op)
{
bufferlist empty_bl;
- op->exec("rbd","set_modify_timestamp",empty_bl);
+ op->exec(method::set_modify_timestamp,empty_bl);
}
int set_modify_timestamp(librados::IoCtx *ioctx, const std::string &oid)
void get_id_start(librados::ObjectReadOperation *op) {
bufferlist empty_bl;
- op->exec("rbd", "get_id", empty_bl);
+ op->exec(method::get_id, empty_bl);
}
int get_id_finish(bufferlist::const_iterator *it, std::string *id) {
{
bufferlist bl;
encode(id, bl);
- op->exec("rbd", "set_id", bl);
+ op->exec(method::set_id, bl);
}
int set_id(librados::IoCtx *ioctx, const std::string &oid, const std::string &id)
bufferlist bl;
encode(image_name, bl);
- op->exec("rbd", "dir_get_id", bl);
+ op->exec(method::dir_get_id, bl);
}
int dir_get_id_finish(bufferlist::const_iterator *iter, std::string *image_id) {
const std::string &id) {
bufferlist in_bl;
encode(id, in_bl);
- op->exec("rbd", "dir_get_name", in_bl);
+ op->exec(method::dir_get_name, in_bl);
}
int dir_get_name_finish(bufferlist::const_iterator *it, std::string *name) {
encode(start, in_bl);
encode(max_return, in_bl);
- op->exec("rbd", "dir_list", in_bl);
+ op->exec(method::dir_list, in_bl);
}
int dir_list_finish(bufferlist::const_iterator *it, map<string, string> *images)
bufferlist bl;
encode(name, bl);
encode(id, bl);
- op->exec("rbd", "dir_add_image", bl);
+ op->exec(method::dir_add_image, bl);
}
int dir_add_image(librados::IoCtx *ioctx, const std::string &oid,
{
bufferlist bl;
encode(directory_state, bl);
- op->exec("rbd", "dir_state_assert", bl);
+ op->exec(method::dir_state_assert, bl);
}
int dir_state_assert(librados::IoCtx *ioctx, const std::string &oid,
{
bufferlist bl;
encode(directory_state, bl);
- op->exec("rbd", "dir_state_set", bl);
+ op->exec(method::dir_state_set, bl);
}
int dir_state_set(librados::IoCtx *ioctx, const std::string &oid,
encode(name, bl);
encode(id, bl);
- op->exec("rbd", "dir_remove_image", bl);
+ op->exec(method::dir_remove_image, bl);
}
void dir_rename_image(librados::ObjectWriteOperation *op,
encode(src, in);
encode(dest, in);
encode(id, in);
- op->exec("rbd", "dir_rename_image", in);
+ op->exec(method::dir_rename_image, in);
}
void object_map_load_start(librados::ObjectReadOperation *op) {
bufferlist in_bl;
- op->exec("rbd", "object_map_load", in_bl);
+ op->exec(method::object_map_load, in_bl);
}
int object_map_load_finish(bufferlist::const_iterator *it,
bufferlist in;
encode(object_map_copy, in);
- rados_op->exec("rbd", "object_map_save", in);
+ rados_op->exec(method::object_map_save, in);
}
void object_map_resize(librados::ObjectWriteOperation *rados_op,
bufferlist in;
encode(object_count, in);
encode(default_state, in);
- rados_op->exec("rbd", "object_map_resize", in);
+ rados_op->exec(method::object_map_resize, in);
}
void object_map_update(librados::ObjectWriteOperation *rados_op,
encode(end_object_no, in);
encode(new_object_state, in);
encode(current_object_state, in);
- rados_op->exec("rbd", "object_map_update", in);
+ rados_op->exec(method::object_map_update, in);
}
void object_map_snap_add(librados::ObjectWriteOperation *rados_op)
{
bufferlist in;
- rados_op->exec("rbd", "object_map_snap_add", in);
+ rados_op->exec(method::object_map_snap_add, in);
}
void object_map_snap_remove(librados::ObjectWriteOperation *rados_op,
bufferlist in;
encode(object_map_copy, in);
- rados_op->exec("rbd", "object_map_snap_remove", in);
+ rados_op->exec(method::object_map_snap_remove, in);
}
void metadata_set(librados::ObjectWriteOperation *op,
bufferlist bl;
encode(data, bl);
- op->exec("rbd", "metadata_set", bl);
+ op->exec(method::metadata_set, bl);
}
int metadata_set(librados::IoCtx *ioctx, const std::string &oid,
bufferlist bl;
encode(key, bl);
- op->exec("rbd", "metadata_remove", bl);
+ op->exec(method::metadata_remove, bl);
}
int metadata_remove(librados::IoCtx *ioctx, const std::string &oid,
bufferlist in_bl;
encode(start, in_bl);
encode(max_return, in_bl);
- op->exec("rbd", "metadata_list", in_bl);
+ op->exec(method::metadata_list, in_bl);
}
int metadata_list_finish(bufferlist::const_iterator *it,
bufferlist bl;
encode(key, bl);
- op->exec("rbd", "metadata_get", bl);
+ op->exec(method::metadata_get, bl);
}
int metadata_get_finish(bufferlist::const_iterator *it,
bufferlist bl;
encode(snap_id, bl);
encode(child_image, bl);
- op->exec("rbd", "child_attach", bl);
+ op->exec(method::child_attach, bl);
}
int child_attach(librados::IoCtx *ioctx, const std::string &oid,
bufferlist bl;
encode(snap_id, bl);
encode(child_image, bl);
- op->exec("rbd", "child_detach", bl);
+ op->exec(method::child_detach, bl);
}
int child_detach(librados::IoCtx *ioctx, const std::string &oid,
{
bufferlist bl;
encode(snap_id, bl);
- op->exec("rbd", "children_list", bl);
+ op->exec(method::children_list, bl);
}
int children_list_finish(bufferlist::const_iterator *it,
const cls::rbd::MigrationSpec &migration_spec) {
bufferlist bl;
encode(migration_spec, bl);
- op->exec("rbd", "migration_set", bl);
+ op->exec(method::migration_set, bl);
}
int migration_set_state(librados::IoCtx *ioctx, const std::string &oid,
bufferlist bl;
encode(state, bl);
encode(description, bl);
- op->exec("rbd", "migration_set_state", bl);
+ op->exec(method::migration_set_state, bl);
}
void migration_get_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("rbd", "migration_get", bl);
+ op->exec(method::migration_get, bl);
}
int migration_get_finish(bufferlist::const_iterator *it,
void migration_remove(librados::ObjectWriteOperation *op) {
bufferlist bl;
- op->exec("rbd", "migration_remove", bl);
+ op->exec(method::migration_remove, bl);
}
template <typename O>
bufferlist bl;
encode(snapc_seq, bl);
encode(state, bl);
- op->exec("rbd", "assert_snapc_seq", bl);
+ op->exec(method::assert_snapc_seq, bl);
}
void assert_snapc_seq(neorados::WriteOp* op,
void mirror_uuid_get_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("rbd", "mirror_uuid_get", bl);
+ op->exec(method::mirror_uuid_get, bl);
}
int mirror_uuid_get_finish(bufferlist::const_iterator *it,
encode(uuid, in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_uuid_set", in_bl);
+ op.exec(method::mirror_uuid_set, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
void mirror_mode_get_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("rbd", "mirror_mode_get", bl);
+ op->exec(method::mirror_mode_get, bl);
}
int mirror_mode_get_finish(bufferlist::const_iterator *it,
encode(static_cast<uint32_t>(mirror_mode), in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_mode_set", in_bl);
+ op.exec(method::mirror_mode_set, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
bufferlist in_bl;
bufferlist out_bl;
- int r = ioctx->exec(RBD_MIRRORING, "rbd", "mirror_remote_namespace_get",
+ int r = ioctx->exec(RBD_MIRRORING, method::mirror_remote_namespace_get,
in_bl, out_bl);
if (r < 0) {
return r;
encode(mirror_namespace, in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_remote_namespace_set", in_bl);
+ op.exec(method::mirror_remote_namespace_set, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
void mirror_peer_list_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("rbd", "mirror_peer_list", bl);
+ op->exec(method::mirror_peer_list, bl);
}
int mirror_peer_list_finish(bufferlist::const_iterator *it,
encode(fsid, in_bl);
encode(static_cast<uint8_t>(cls::rbd::MIRROR_PEER_DIRECTION_TX), in_bl);
- op->exec("rbd", "mirror_peer_ping", in_bl);
+ op->exec(method::mirror_peer_ping, in_bl);
}
int mirror_peer_add(librados::IoCtx *ioctx,
bufferlist in_bl;
encode(mirror_peer, in_bl);
- op->exec("rbd", "mirror_peer_add", in_bl);
+ op->exec(method::mirror_peer_add, in_bl);
}
int mirror_peer_remove(librados::IoCtx *ioctx,
encode(uuid, in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_peer_remove", in_bl);
+ op.exec(method::mirror_peer_remove, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
encode(client_name, in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_peer_set_client", in_bl);
+ op.exec(method::mirror_peer_set_client, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
encode(cluster_name, in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_peer_set_cluster", in_bl);
+ op.exec(method::mirror_peer_set_cluster, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
encode(static_cast<uint8_t>(mirror_peer_direction), in_bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "mirror_peer_set_direction", in_bl);
+ op.exec(method::mirror_peer_set_direction, in_bl);
int r = ioctx->operate(RBD_MIRRORING, &op);
if (r < 0) {
return r;
bufferlist in_bl;
encode(start, in_bl);
encode(max_return, in_bl);
- op->exec("rbd", "mirror_image_list", in_bl);
+ op->exec(method::mirror_image_list, in_bl);
}
int mirror_image_list_finish(bufferlist::const_iterator *it,
const std::string &global_image_id) {
bufferlist in_bl;
encode(global_image_id, in_bl);
- op->exec( "rbd", "mirror_image_get_image_id", in_bl);
+ op->exec( method::mirror_image_get_image_id, in_bl);
}
int mirror_image_get_image_id_finish(bufferlist::const_iterator *it,
bufferlist in_bl;
encode(image_id, in_bl);
- op->exec("rbd", "mirror_image_get", in_bl);
+ op->exec(method::mirror_image_get, in_bl);
}
int mirror_image_get_finish(bufferlist::const_iterator *iter,
encode(image_id, bl);
encode(mirror_image, bl);
- op->exec("rbd", "mirror_image_set", bl);
+ op->exec(method::mirror_image_set, bl);
}
int mirror_image_set(librados::IoCtx *ioctx, const std::string &image_id,
bufferlist bl;
encode(image_id, bl);
- op->exec("rbd", "mirror_image_remove", bl);
+ op->exec(method::mirror_image_remove, bl);
}
int mirror_image_remove(librados::IoCtx *ioctx, const std::string &image_id) {
bufferlist bl;
encode(global_image_id, bl);
encode(status, bl);
- op->exec("rbd", "mirror_image_status_set", bl);
+ op->exec(method::mirror_image_status_set, bl);
}
int mirror_image_status_get(librados::IoCtx *ioctx,
const std::string &global_image_id) {
bufferlist bl;
encode(global_image_id, bl);
- op->exec("rbd", "mirror_image_status_get", bl);
+ op->exec(method::mirror_image_status_get, bl);
}
int mirror_image_status_get_finish(bufferlist::const_iterator *iter,
bufferlist bl;
encode(start, bl);
encode(max_return, bl);
- op->exec("rbd", "mirror_image_status_list", bl);
+ op->exec(method::mirror_image_status_list, bl);
}
int mirror_image_status_list_finish(bufferlist::const_iterator *iter,
const std::vector<cls::rbd::MirrorPeer>& mirror_peer_sites) {
bufferlist bl;
encode(mirror_peer_sites, bl);
- op->exec("rbd", "mirror_image_status_get_summary", bl);
+ op->exec(method::mirror_image_status_get_summary, bl);
}
int mirror_image_status_get_summary_finish(
const std::string &global_image_id) {
bufferlist bl;
encode(global_image_id, bl);
- op->exec("rbd", "mirror_image_status_remove", bl);
+ op->exec(method::mirror_image_status_remove, bl);
}
int mirror_image_status_remove_down(librados::IoCtx *ioctx) {
void mirror_image_status_remove_down(librados::ObjectWriteOperation *op) {
bufferlist bl;
- op->exec("rbd", "mirror_image_status_remove_down", bl);
+ op->exec(method::mirror_image_status_remove_down, bl);
}
int mirror_image_instance_get(librados::IoCtx *ioctx,
const std::string &global_image_id) {
bufferlist bl;
encode(global_image_id, bl);
- op->exec("rbd", "mirror_image_instance_get", bl);
+ op->exec(method::mirror_image_instance_get, bl);
}
int mirror_image_instance_get_finish(bufferlist::const_iterator *iter,
bufferlist bl;
encode(start, bl);
encode(max_return, bl);
- op->exec("rbd", "mirror_image_instance_list", bl);
+ op->exec(method::mirror_image_instance_list, bl);
}
int mirror_image_instance_list_finish(
void mirror_instances_list_start(librados::ObjectReadOperation *op) {
bufferlist bl;
- op->exec("rbd", "mirror_instances_list", bl);
+ op->exec(method::mirror_instances_list, bl);
}
int mirror_instances_list_finish(bufferlist::const_iterator *iter,
const std::string &instance_id) {
bufferlist bl;
encode(instance_id, bl);
- op->exec("rbd", "mirror_instances_add", bl);
+ op->exec(method::mirror_instances_add, bl);
}
int mirror_instances_add(librados::IoCtx *ioctx,
const std::string &instance_id) {
bufferlist bl;
encode(instance_id, bl);
- op->exec("rbd", "mirror_instances_remove", bl);
+ op->exec(method::mirror_instances_remove, bl);
}
int mirror_instances_remove(librados::IoCtx *ioctx,
encode(start_after, bl);
encode(max_read, bl);
- op->exec("rbd", "mirror_image_map_list", bl);
+ op->exec(method::mirror_image_map_list, bl);
}
int mirror_image_map_list_finish(bufferlist::const_iterator *iter,
encode(global_image_id, bl);
encode(image_map, bl);
- op->exec("rbd", "mirror_image_map_update", bl);
+ op->exec(method::mirror_image_map_update, bl);
}
void mirror_image_map_remove(librados::ObjectWriteOperation *op,
bufferlist bl;
encode(global_image_id, bl);
- op->exec("rbd", "mirror_image_map_remove", bl);
+ op->exec(method::mirror_image_map_remove, bl);
}
void mirror_image_snapshot_unlink_peer(librados::ObjectWriteOperation *op,
encode(snap_id, bl);
encode(mirror_peer_uuid, bl);
- op->exec("rbd", "mirror_image_snapshot_unlink_peer", bl);
+ op->exec(method::mirror_image_snapshot_unlink_peer, bl);
}
int mirror_image_snapshot_unlink_peer(librados::IoCtx *ioctx,
encode(complete, bl);
encode(copy_progress, bl);
- op->exec("rbd", "mirror_image_snapshot_set_copy_progress", bl);
+ op->exec(method::mirror_image_snapshot_set_copy_progress, bl);
}
int mirror_image_snapshot_set_copy_progress(librados::IoCtx *ioctx,
bufferlist in, out;
encode(start, in);
encode(max_return, in);
- int r = ioctx->exec(oid, "rbd", "group_dir_list", in, out);
+ int r = ioctx->exec(oid, method::group_dir_list, in, out);
if (r < 0)
return r;
encode(name, in);
encode(id, in);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_dir_add", in);
+ op.exec(method::group_dir_add, in);
return ioctx->operate(oid, &op);
}
encode(dest, in);
encode(id, in);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_dir_rename", in);
+ op.exec(method::group_dir_rename, in);
return ioctx->operate(oid, &op);
}
encode(name, in);
encode(id, in);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_dir_remove", in);
+ op.exec(method::group_dir_remove, in);
return ioctx->operate(oid, &op);
}
encode(spec, bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_image_remove", bl);
+ op.exec(method::group_image_remove, bl);
return ioctx->operate(oid, &op);
}
encode(start, bl);
encode(max_return, bl);
- int r = ioctx->exec(oid, "rbd", "group_image_list", bl, bl2);
+ int r = ioctx->exec(oid, method::group_image_list, bl, bl2);
if (r < 0)
return r;
encode(st, bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_image_set", bl);
+ op.exec(method::group_image_set, bl);
return ioctx->operate(oid, &op);
}
encode(group_spec, bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "image_group_add", bl);
+ op.exec(method::image_group_add, bl);
return ioctx->operate(oid, &op);
}
encode(group_spec, bl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "image_group_remove", bl);
+ op.exec(method::image_group_remove, bl);
return ioctx->operate(oid, &op);
}
void image_group_get_start(librados::ObjectReadOperation *op)
{
bufferlist in_bl;
- op->exec("rbd", "image_group_get", in_bl);
+ op->exec(method::image_group_get, in_bl);
}
int image_group_get_finish(bufferlist::const_iterator *iter,
bufferlist inbl;
encode(snapshot, inbl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_snap_set", inbl);
+ op.exec(method::group_snap_set, inbl);
int r = ioctx->operate(oid, &op);
return r;
}
bufferlist inbl;
encode(snap_id, inbl);
librados::ObjectWriteOperation op;
- op.exec("rbd", "group_snap_remove", inbl);
+ op.exec(method::group_snap_remove, inbl);
return ioctx->operate(oid, &op);
}
bufferlist inbl, outbl;
encode(snap_id, inbl);
- int r = ioctx->exec(oid, "rbd", "group_snap_get_by_id", inbl, outbl);
+ int r = ioctx->exec(oid, method::group_snap_get_by_id, inbl, outbl);
if (r < 0) {
return r;
}
encode(start, bl);
encode(max_return, bl);
- op->exec("rbd", "group_snap_list", bl);
+ op->exec(method::group_snap_list, bl);
}
int group_snap_list_finish(bufferlist::const_iterator *iter,
bufferlist bl;
encode(start, bl);
encode(max_return, bl);
- op->exec("rbd", "group_snap_list_order", bl);
+ op->exec(method::group_snap_list_order, bl);
}
int group_snap_list_order_finish(bufferlist::const_iterator *iter,
bufferlist bl;
encode(id, bl);
encode(trash_spec, bl);
- op->exec("rbd", "trash_add", bl);
+ op->exec(method::trash_add, bl);
}
int trash_add(librados::IoCtx *ioctx, const std::string &id,
{
bufferlist bl;
encode(id, bl);
- op->exec("rbd", "trash_remove", bl);
+ op->exec(method::trash_remove, bl);
}
int trash_remove(librados::IoCtx *ioctx, const std::string &id)
bufferlist bl;
encode(start, bl);
encode(max_return, bl);
- op->exec("rbd", "trash_list", bl);
+ op->exec(method::trash_list, bl);
}
int trash_list_finish(bufferlist::const_iterator *it,
{
bufferlist bl;
encode(id, bl);
- op->exec("rbd", "trash_get", bl);
+ op->exec(method::trash_get, bl);
}
int trash_get_finish(bufferlist::const_iterator *it,
encode(id, bl);
encode(trash_state, bl);
encode(expect_state, bl);
- op->exec("rbd", "trash_state_set", bl);
+ op->exec(method::trash_state_set, bl);
}
int trash_state_set(librados::IoCtx *ioctx, const std::string &id,
{
bufferlist bl;
encode(name, bl);
- op->exec("rbd", "namespace_add", bl);
+ op->exec(method::namespace_add, bl);
}
int namespace_add(librados::IoCtx *ioctx, const std::string &name)
{
bufferlist bl;
encode(name, bl);
- op->exec("rbd", "namespace_remove", bl);
+ op->exec(method::namespace_remove, bl);
}
int namespace_remove(librados::IoCtx *ioctx, const std::string &name)
bufferlist bl;
encode(start, bl);
encode(max_return, bl);
- op->exec("rbd", "namespace_list", bl);
+ op->exec(method::namespace_list, bl);
}
int namespace_list_finish(bufferlist::const_iterator *it,
bufferlist bl;
encode(sparse_size, bl);
encode(remove_empty, bl);
- op->exec("rbd", "sparsify", bl);
+ op->exec(method::sparsify, bl);
}
int sparsify(librados::IoCtx *ioctx, const std::string &oid, uint64_t sparse_size,
void dir_rename_image(librados::ObjectWriteOperation *op,
const std::string &src, const std::string &dest,
const std::string &id);
+[[deprecated("in favor of read/write variants")]]
void dir_state_assert(librados::ObjectOperation *op,
cls::rbd::DirectoryState directory_state);
+template<typename ObjectOperation>
+void dir_state_assert(ObjectOperation *op,
+ cls::rbd::DirectoryState directory_state)
+{
+ bufferlist bl;
+ encode(directory_state, bl);
+ op->exec(cls::rbd::method::dir_state_assert, bl);
+}
int dir_state_assert(librados::IoCtx *ioctx, const std::string &oid,
cls::rbd::DirectoryState directory_state);
void dir_state_set(librados::ObjectWriteOperation *op,
--- /dev/null
+#pragma once
+
+#include "include/rados/cls_traits.h"
+
+namespace cls::rbd {
+struct ClassId {
+ static constexpr auto name = "rbd";
+};
+namespace method {
+constexpr auto create = ClsMethod<RdWrTag, ClassId>("create");
+constexpr auto get_features = ClsMethod<RdTag, ClassId>("get_features");
+constexpr auto set_features = ClsMethod<RdWrTag, ClassId>("set_features");
+constexpr auto get_size = ClsMethod<RdTag, ClassId>("get_size");
+constexpr auto set_size = ClsMethod<RdWrTag, ClassId>("set_size");
+constexpr auto get_snapcontext = ClsMethod<RdTag, ClassId>("get_snapcontext");
+constexpr auto get_object_prefix = ClsMethod<RdTag, ClassId>("get_object_prefix");
+constexpr auto get_data_pool = ClsMethod<RdTag, ClassId>("get_data_pool");
+constexpr auto get_snapshot_name = ClsMethod<RdTag, ClassId>("get_snapshot_name");
+constexpr auto get_snapshot_timestamp = ClsMethod<RdTag, ClassId>("get_snapshot_timestamp");
+constexpr auto snapshot_get = ClsMethod<RdTag, ClassId>("snapshot_get");
+constexpr auto snapshot_add = ClsMethod<RdWrTag, ClassId>("snapshot_add");
+constexpr auto snapshot_remove = ClsMethod<RdWrTag, ClassId>("snapshot_remove");
+constexpr auto snapshot_rename = ClsMethod<RdWrTag, ClassId>("snapshot_rename");
+constexpr auto snapshot_trash_add = ClsMethod<RdWrTag, ClassId>("snapshot_trash_add");
+constexpr auto get_all_features = ClsMethod<RdTag, ClassId>("get_all_features");
+
+// NOTE: deprecate v1 parent APIs after mimic EOLed
+constexpr auto get_parent = ClsMethod<RdTag, ClassId>("get_parent");
+constexpr auto set_parent = ClsMethod<RdWrTag, ClassId>("set_parent");
+constexpr auto remove_parent = ClsMethod<RdWrTag, ClassId>("remove_parent");
+
+// Parent/Layering (V2 APIs)
+constexpr auto parent_get = ClsMethod<RdTag, ClassId>("parent_get");
+constexpr auto parent_overlap_get = ClsMethod<RdTag, ClassId>("parent_overlap_get");
+constexpr auto parent_attach = ClsMethod<RdWrTag, ClassId>("parent_attach");
+constexpr auto parent_detach = ClsMethod<RdWrTag, ClassId>("parent_detach");
+
+constexpr auto set_protection_status = ClsMethod<RdWrTag, ClassId>("set_protection_status");
+constexpr auto get_protection_status = ClsMethod<RdTag, ClassId>("get_protection_status");
+constexpr auto get_stripe_unit_count = ClsMethod<RdTag, ClassId>("get_stripe_unit_count");
+constexpr auto set_stripe_unit_count = ClsMethod<RdWrTag, ClassId>("set_stripe_unit_count");
+constexpr auto get_create_timestamp = ClsMethod<RdTag, ClassId>("get_create_timestamp");
+constexpr auto get_access_timestamp = ClsMethod<RdTag, ClassId>("get_access_timestamp");
+constexpr auto get_modify_timestamp = ClsMethod<RdTag, ClassId>("get_modify_timestamp");
+constexpr auto get_flags = ClsMethod<RdTag, ClassId>("get_flags");
+constexpr auto set_flags = ClsMethod<RdWrTag, ClassId>("set_flags");
+constexpr auto op_features_get = ClsMethod<RdTag, ClassId>("op_features_get");
+constexpr auto op_features_set = ClsMethod<RdWrTag, ClassId>("op_features_set");
+constexpr auto metadata_list = ClsMethod<RdTag, ClassId>("metadata_list");
+constexpr auto metadata_set = ClsMethod<RdWrTag, ClassId>("metadata_set");
+constexpr auto metadata_remove = ClsMethod<RdWrTag, ClassId>("metadata_remove");
+constexpr auto metadata_get = ClsMethod<RdTag, ClassId>("metadata_get");
+constexpr auto snapshot_get_limit = ClsMethod<RdTag, ClassId>("snapshot_get_limit");
+constexpr auto snapshot_set_limit = ClsMethod<RdWrTag, ClassId>("snapshot_set_limit");
+constexpr auto child_attach = ClsMethod<RdWrTag, ClassId>("child_attach");
+constexpr auto child_detach = ClsMethod<RdWrTag, ClassId>("child_detach");
+constexpr auto children_list = ClsMethod<RdTag, ClassId>("children_list");
+constexpr auto migration_set = ClsMethod<RdWrTag, ClassId>("migration_set");
+constexpr auto migration_set_state = ClsMethod<RdWrTag, ClassId>("migration_set_state");
+constexpr auto migration_get = ClsMethod<RdTag, ClassId>("migration_get");
+constexpr auto migration_remove = ClsMethod<RdWrTag, ClassId>("migration_remove");
+
+constexpr auto set_modify_timestamp = ClsMethod<RdWrTag, ClassId>("set_modify_timestamp");
+
+constexpr auto set_access_timestamp = ClsMethod<RdWrTag, ClassId>("set_access_timestamp");
+
+constexpr auto add_child = ClsMethod<RdWrTag, ClassId>("add_child");
+constexpr auto remove_child = ClsMethod<RdWrTag, ClassId>("remove_child");
+constexpr auto get_children = ClsMethod<RdTag, ClassId>("get_children");
+
+/* methods for the rbd_id.$image_name objects */
+constexpr auto get_id = ClsMethod<RdTag, ClassId>("get_id");
+constexpr auto set_id = ClsMethod<RdWrTag, ClassId>("set_id");
+
+/* methods for the rbd_directory object */
+constexpr auto dir_get_id = ClsMethod<RdTag, ClassId>("dir_get_id");
+constexpr auto dir_get_name = ClsMethod<RdTag, ClassId>("dir_get_name");
+constexpr auto dir_list = ClsMethod<RdTag, ClassId>("dir_list");
+constexpr auto dir_add_image = ClsMethod<RdWrTag, ClassId>("dir_add_image");
+constexpr auto dir_remove_image = ClsMethod<RdWrTag, ClassId>("dir_remove_image");
+constexpr auto dir_rename_image = ClsMethod<RdWrTag, ClassId>("dir_rename_image");
+constexpr auto dir_state_assert = ClsMethod<RdTag, ClassId>("dir_state_assert");
+constexpr auto dir_state_set = ClsMethod<RdWrTag, ClassId>("dir_state_set");
+
+/* methods for the rbd_object_map.$image_id object */
+constexpr auto object_map_load = ClsMethod<RdTag, ClassId>("object_map_load");
+constexpr auto object_map_save = ClsMethod<RdWrTag, ClassId>("object_map_save");
+constexpr auto object_map_resize = ClsMethod<RdWrTag, ClassId>("object_map_resize");
+constexpr auto object_map_update = ClsMethod<RdWrTag, ClassId>("object_map_update");
+constexpr auto object_map_snap_add = ClsMethod<RdWrTag, ClassId>("object_map_snap_add");
+constexpr auto object_map_snap_remove = ClsMethod<RdWrTag, ClassId>("object_map_snap_remove");
+
+/* methods for the old format */
+constexpr auto snap_list = ClsMethod<RdTag, ClassId>("snap_list");
+constexpr auto snap_add = ClsMethod<RdWrTag, ClassId>("snap_add");
+constexpr auto snap_remove = ClsMethod<RdWrTag, ClassId>("snap_remove");
+constexpr auto snap_rename = ClsMethod<RdWrTag, ClassId>("snap_rename");
+
+/* methods for the rbd_mirroring object */
+constexpr auto mirror_uuid_get = ClsMethod<RdTag, ClassId>("mirror_uuid_get");
+constexpr auto mirror_uuid_set = ClsMethod<RdWrTag, ClassId>("mirror_uuid_set");
+constexpr auto mirror_mode_get = ClsMethod<RdTag, ClassId>("mirror_mode_get");
+constexpr auto mirror_mode_set = ClsMethod<RdWrTag, ClassId>("mirror_mode_set");
+constexpr auto mirror_remote_namespace_get = ClsMethod<RdTag, ClassId>("mirror_remote_namespace_get");
+constexpr auto mirror_remote_namespace_set = ClsMethod<RdWrTag, ClassId>("mirror_remote_namespace_set");
+constexpr auto mirror_peer_ping = ClsMethod<RdWrTag, ClassId>("mirror_peer_ping");
+constexpr auto mirror_peer_list = ClsMethod<RdTag, ClassId>("mirror_peer_list");
+constexpr auto mirror_peer_add = ClsMethod<RdWrTag, ClassId>("mirror_peer_add");
+constexpr auto mirror_peer_remove = ClsMethod<RdWrTag, ClassId>("mirror_peer_remove");
+constexpr auto mirror_peer_set_client = ClsMethod<RdWrTag, ClassId>("mirror_peer_set_client");
+constexpr auto mirror_peer_set_cluster = ClsMethod<RdWrTag, ClassId>("mirror_peer_set_cluster");
+constexpr auto mirror_peer_set_direction = ClsMethod<RdWrTag, ClassId>("mirror_peer_set_direction");
+constexpr auto mirror_image_list = ClsMethod<RdTag, ClassId>("mirror_image_list");
+constexpr auto mirror_image_get_image_id = ClsMethod<RdTag, ClassId>("mirror_image_get_image_id");
+constexpr auto mirror_image_get = ClsMethod<RdTag, ClassId>("mirror_image_get");
+constexpr auto mirror_image_set = ClsMethod<RdWrTag, ClassId>("mirror_image_set");
+constexpr auto mirror_image_remove = ClsMethod<RdWrTag, ClassId>("mirror_image_remove");
+constexpr auto mirror_image_status_set = ClsMethod<RdWrPromoteTag, ClassId>("mirror_image_status_set");
+constexpr auto mirror_image_status_remove = ClsMethod<RdWrTag, ClassId>("mirror_image_status_remove");
+constexpr auto mirror_image_status_get = ClsMethod<RdTag, ClassId>("mirror_image_status_get");
+constexpr auto mirror_image_status_list = ClsMethod<RdTag, ClassId>("mirror_image_status_list");
+constexpr auto mirror_image_status_get_summary = ClsMethod<RdTag, ClassId>("mirror_image_status_get_summary");
+constexpr auto mirror_image_status_remove_down = ClsMethod<RdWrTag, ClassId>("mirror_image_status_remove_down");
+constexpr auto mirror_image_instance_get = ClsMethod<RdTag, ClassId>("mirror_image_instance_get");
+constexpr auto mirror_image_instance_list = ClsMethod<RdTag, ClassId>("mirror_image_instance_list");
+constexpr auto mirror_instances_list = ClsMethod<RdTag, ClassId>("mirror_instances_list");
+constexpr auto mirror_instances_add = ClsMethod<RdWrPromoteTag, ClassId>("mirror_instances_add");
+constexpr auto mirror_instances_remove = ClsMethod<RdWrTag, ClassId>("mirror_instances_remove");
+constexpr auto mirror_image_map_list = ClsMethod<RdTag, ClassId>("mirror_image_map_list");
+constexpr auto mirror_image_map_update = ClsMethod<WrTag, ClassId>("mirror_image_map_update");
+constexpr auto mirror_image_map_remove = ClsMethod<WrTag, ClassId>("mirror_image_map_remove");
+constexpr auto mirror_image_snapshot_unlink_peer = ClsMethod<RdWrTag, ClassId>("mirror_image_snapshot_unlink_peer");
+constexpr auto mirror_image_snapshot_set_copy_progress = ClsMethod<RdWrTag, ClassId>("mirror_image_snapshot_set_copy_progress");
+
+/* methods for the groups feature */
+constexpr auto group_dir_list = ClsMethod<RdTag, ClassId>("group_dir_list");
+constexpr auto group_dir_add = ClsMethod<RdWrTag, ClassId>("group_dir_add");
+constexpr auto group_dir_remove = ClsMethod<RdWrTag, ClassId>("group_dir_remove");
+constexpr auto group_dir_rename = ClsMethod<RdWrTag, ClassId>("group_dir_rename");
+constexpr auto group_image_remove = ClsMethod<RdWrTag, ClassId>("group_image_remove");
+constexpr auto group_image_list = ClsMethod<RdTag, ClassId>("group_image_list");
+constexpr auto group_image_set = ClsMethod<RdWrTag, ClassId>("group_image_set");
+constexpr auto image_group_add = ClsMethod<RdWrTag, ClassId>("image_group_add");
+constexpr auto image_group_remove = ClsMethod<RdWrTag, ClassId>("image_group_remove");
+constexpr auto image_group_get = ClsMethod<RdTag, ClassId>("image_group_get");
+constexpr auto group_snap_set = ClsMethod<RdWrTag, ClassId>("group_snap_set");
+constexpr auto group_snap_remove = ClsMethod<RdWrTag, ClassId>("group_snap_remove");
+constexpr auto group_snap_get_by_id = ClsMethod<RdTag, ClassId>("group_snap_get_by_id");
+constexpr auto group_snap_list = ClsMethod<RdTag, ClassId>("group_snap_list");
+constexpr auto group_snap_list_order = ClsMethod<RdTag, ClassId>("group_snap_list_order");
+
+/* rbd_trash object methods */
+constexpr auto trash_add = ClsMethod<RdWrTag, ClassId>("trash_add");
+constexpr auto trash_remove = ClsMethod<RdWrTag, ClassId>("trash_remove");
+constexpr auto trash_list = ClsMethod<RdTag, ClassId>("trash_list");
+constexpr auto trash_get = ClsMethod<RdTag, ClassId>("trash_get");
+constexpr auto trash_state_set = ClsMethod<RdWrTag, ClassId>("trash_state_set");
+
+/* rbd_namespace object methods */
+constexpr auto namespace_add = ClsMethod<RdWrTag, ClassId>("namespace_add");
+constexpr auto namespace_remove = ClsMethod<RdWrTag, ClassId>("namespace_remove");
+constexpr auto namespace_list = ClsMethod<RdTag, ClassId>("namespace_list");
+
+/* data object methods */
+constexpr auto copyup = ClsMethod<RdWrTag, ClassId>("copyup");
+constexpr auto sparse_copyup = ClsMethod<RdWrTag, ClassId>("sparse_copyup");
+constexpr auto assert_snapc_seq = ClsMethod<RdWrTag, ClassId>("assert_snapc_seq");
+constexpr auto sparsify = ClsMethod<RdWrTag, ClassId>("sparsify");
+}
+}
\ No newline at end of file
#include "include/stringify.h"
#include "include/utime.h"
#include "msg/msg_types.h"
+#include "include/rados/cls_traits.h"
#include <iosfwd>
#include <map>
#include <string>
#include <set>
#include <variant>
+#include "cls_rbd_ops.h"
+
#define RBD_GROUP_REF "rbd_group_ref"
namespace ceph { class Formatter; }
void sanitize_entity_inst(entity_inst_t* entity_inst);
+
} // namespace rbd
} // namespace cls
cls_method_handle_t h_refcount_set;
cls_method_handle_t h_refcount_read;
- cls_register("refcount", &h_class);
-
- /* refcount */
- cls_register_cxx_method(h_class, "get", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_refcount_get, &h_refcount_get);
- cls_register_cxx_method(h_class, "put", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_refcount_put, &h_refcount_put);
- cls_register_cxx_method(h_class, "set", CLS_METHOD_RD | CLS_METHOD_WR, cls_rc_refcount_set, &h_refcount_set);
- cls_register_cxx_method(h_class, "read", CLS_METHOD_RD, cls_rc_refcount_read, &h_refcount_read);
+ using namespace cls::refcount;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::get, cls_rc_refcount_get, &h_refcount_get);
+ cls.register_cxx_method(method::put, cls_rc_refcount_put, &h_refcount_put);
+ cls.register_cxx_method(method::set, cls_rc_refcount_set, &h_refcount_set);
+ cls.register_cxx_method(method::read, cls_rc_refcount_read, &h_refcount_read);
return;
}
using std::string;
using ceph::bufferlist;
+using namespace cls::refcount;
void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref)
{
call.tag = tag;
call.implicit_ref = implicit_ref;
encode(call, in);
- op.exec("refcount", "get", in);
+ op.exec(method::get, in);
}
void cls_refcount_put(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref)
call.tag = tag;
call.implicit_ref = implicit_ref;
encode(call, in);
- op.exec("refcount", "put", in);
+ op.exec(method::put, in);
}
void cls_refcount_set(librados::ObjectWriteOperation& op, list<string>& refs)
cls_refcount_set_op call;
call.refs = refs;
encode(call, in);
- op.exec("refcount", "set", in);
+ op.exec(method::set, in);
}
int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list<string> *refs, bool implicit_ref)
cls_refcount_read_op call;
call.implicit_ref = implicit_ref;
encode(call, in);
- int r = io_ctx.exec(oid, "refcount", "read", in, out);
+ int r = io_ctx.exec(oid, method::read, in, out);
if (r < 0)
return r;
#include "include/types.h"
#include "common/hobject.h"
+#include "include/rados/cls_traits.h"
struct cls_refcount_get_op {
std::string tag;
};
WRITE_CLASS_ENCODER(obj_refcount)
+namespace cls::refcount {
+struct ClassId {
+ static constexpr auto name = "refcount";
+};
+namespace method {
+constexpr auto get = ClsMethod<RdWrTag, ClassId>("get");
+constexpr auto put = ClsMethod<RdWrTag, ClassId>("put");
+constexpr auto set = ClsMethod<RdWrTag, ClassId>("set");
+constexpr auto read = ClsMethod<RdTag, ClassId>("read");
+}
+}
#endif
cls_method_handle_t h_rgw_guard_bucket_resharding;
cls_method_handle_t h_rgw_get_bucket_resharding;
- cls_register(RGW_CLASS, &h_class);
-
- /* bucket index */
- cls_register_cxx_method(h_class, RGW_BUCKET_INIT_INDEX, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_init_index, &h_rgw_bucket_init_index);
- cls_register_cxx_method(h_class, RGW_BUCKET_INIT_INDEX2, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_init_index, &h_rgw_bucket_init_index);
- cls_register_cxx_method(h_class, RGW_BUCKET_SET_TAG_TIMEOUT, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_set_tag_timeout, &h_rgw_bucket_set_tag_timeout);
- cls_register_cxx_method(h_class, RGW_BUCKET_LIST, CLS_METHOD_RD, rgw_bucket_list, &h_rgw_bucket_list);
- cls_register_cxx_method(h_class, RGW_BUCKET_CHECK_INDEX, CLS_METHOD_RD, rgw_bucket_check_index, &h_rgw_bucket_check_index);
- cls_register_cxx_method(h_class, RGW_BUCKET_REBUILD_INDEX, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_rebuild_index, &h_rgw_bucket_rebuild_index);
- cls_register_cxx_method(h_class, RGW_BUCKET_UPDATE_STATS, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_update_stats, &h_rgw_bucket_update_stats);
- cls_register_cxx_method(h_class, RGW_BUCKET_PREPARE_OP, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_prepare_op, &h_rgw_bucket_prepare_op);
- cls_register_cxx_method(h_class, RGW_BUCKET_COMPLETE_OP, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_complete_op, &h_rgw_bucket_complete_op);
- cls_register_cxx_method(h_class, RGW_BUCKET_LINK_OLH, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_link_olh, &h_rgw_bucket_link_olh);
- cls_register_cxx_method(h_class, RGW_BUCKET_UNLINK_INSTANCE, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_unlink_instance, &h_rgw_bucket_unlink_instance_op);
- cls_register_cxx_method(h_class, RGW_BUCKET_READ_OLH_LOG, CLS_METHOD_RD, rgw_bucket_read_olh_log, &h_rgw_bucket_read_olh_log);
- cls_register_cxx_method(h_class, RGW_BUCKET_TRIM_OLH_LOG, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_trim_olh_log, &h_rgw_bucket_trim_olh_log);
- cls_register_cxx_method(h_class, RGW_BUCKET_CLEAR_OLH, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_clear_olh, &h_rgw_bucket_clear_olh);
-
- cls_register_cxx_method(h_class, RGW_OBJ_REMOVE, CLS_METHOD_RD | CLS_METHOD_WR, rgw_obj_remove, &h_rgw_obj_remove);
- cls_register_cxx_method(h_class, RGW_OBJ_STORE_PG_VER, CLS_METHOD_WR, rgw_obj_store_pg_ver, &h_rgw_obj_store_pg_ver);
- cls_register_cxx_method(h_class, RGW_OBJ_CHECK_ATTRS_PREFIX, CLS_METHOD_RD, rgw_obj_check_attrs_prefix, &h_rgw_obj_check_attrs_prefix);
- cls_register_cxx_method(h_class, RGW_OBJ_CHECK_MTIME, CLS_METHOD_RD, rgw_obj_check_mtime, &h_rgw_obj_check_mtime);
-
- cls_register_cxx_method(h_class, RGW_BI_GET, CLS_METHOD_RD, rgw_bi_get_op, &h_rgw_bi_get_op);
- cls_register_cxx_method(h_class, RGW_BI_PUT, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bi_put_op, &h_rgw_bi_put_op);
- cls_register_cxx_method(h_class, RGW_BI_PUT_ENTRIES, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bi_put_entries, &h_rgw_bi_put_entries_op);
- cls_register_cxx_method(h_class, RGW_BI_LIST, CLS_METHOD_RD, rgw_bi_list_op, &h_rgw_bi_list_op);
- cls_register_cxx_method(h_class, RGW_RESHARD_LOG_TRIM, CLS_METHOD_RD | CLS_METHOD_WR, rgw_reshard_log_trim_op, &h_rgw_reshard_log_trim_op);
-
- cls_register_cxx_method(h_class, RGW_BI_LOG_LIST, CLS_METHOD_RD, rgw_bi_log_list, &h_rgw_bi_log_list_op);
- cls_register_cxx_method(h_class, RGW_BI_LOG_TRIM, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bi_log_trim, &h_rgw_bi_log_trim_op);
- cls_register_cxx_method(h_class, RGW_DIR_SUGGEST_CHANGES, CLS_METHOD_RD | CLS_METHOD_WR, rgw_dir_suggest_changes, &h_rgw_dir_suggest_changes);
-
- cls_register_cxx_method(h_class, RGW_BI_LOG_RESYNC, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bi_log_resync, &h_rgw_bi_log_resync_op);
- cls_register_cxx_method(h_class, RGW_BI_LOG_STOP, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bi_log_stop, &h_rgw_bi_log_stop_op);
-
- /* usage logging */
- cls_register_cxx_method(h_class, RGW_USER_USAGE_LOG_ADD, CLS_METHOD_RD | CLS_METHOD_WR, rgw_user_usage_log_add, &h_rgw_user_usage_log_add);
- cls_register_cxx_method(h_class, RGW_USER_USAGE_LOG_READ, CLS_METHOD_RD, rgw_user_usage_log_read, &h_rgw_user_usage_log_read);
- cls_register_cxx_method(h_class, RGW_USER_USAGE_LOG_TRIM, CLS_METHOD_RD | CLS_METHOD_WR, rgw_user_usage_log_trim, &h_rgw_user_usage_log_trim);
- cls_register_cxx_method(h_class, RGW_USAGE_LOG_CLEAR, CLS_METHOD_WR, rgw_usage_log_clear, &h_rgw_usage_log_clear);
-
- /* garbage collection */
- cls_register_cxx_method(h_class, RGW_GC_SET_ENTRY, CLS_METHOD_RD | CLS_METHOD_WR, rgw_cls_gc_set_entry, &h_rgw_gc_set_entry);
- cls_register_cxx_method(h_class, RGW_GC_DEFER_ENTRY, CLS_METHOD_RD | CLS_METHOD_WR, rgw_cls_gc_defer_entry, &h_rgw_gc_defer_entry);
- cls_register_cxx_method(h_class, RGW_GC_LIST, CLS_METHOD_RD, rgw_cls_gc_list, &h_rgw_gc_list);
- cls_register_cxx_method(h_class, RGW_GC_REMOVE, CLS_METHOD_RD | CLS_METHOD_WR, rgw_cls_gc_remove, &h_rgw_gc_remove);
-
- /* lifecycle bucket list */
- cls_register_cxx_method(h_class, RGW_LC_GET_ENTRY, CLS_METHOD_RD, rgw_cls_lc_get_entry, &h_rgw_lc_get_entry);
- cls_register_cxx_method(h_class, RGW_LC_SET_ENTRY, CLS_METHOD_RD | CLS_METHOD_WR, rgw_cls_lc_set_entry, &h_rgw_lc_set_entry);
- cls_register_cxx_method(h_class, RGW_LC_RM_ENTRY, CLS_METHOD_RD | CLS_METHOD_WR, rgw_cls_lc_rm_entry, &h_rgw_lc_rm_entry);
- cls_register_cxx_method(h_class, RGW_LC_GET_NEXT_ENTRY, CLS_METHOD_RD, rgw_cls_lc_get_next_entry, &h_rgw_lc_get_next_entry);
- cls_register_cxx_method(h_class, RGW_LC_PUT_HEAD, CLS_METHOD_RD| CLS_METHOD_WR, rgw_cls_lc_put_head, &h_rgw_lc_put_head);
- cls_register_cxx_method(h_class, RGW_LC_GET_HEAD, CLS_METHOD_RD, rgw_cls_lc_get_head, &h_rgw_lc_get_head);
- cls_register_cxx_method(h_class, RGW_LC_LIST_ENTRIES, CLS_METHOD_RD, rgw_cls_lc_list_entries, &h_rgw_lc_list_entries);
-
- /* multipart */
- cls_register_cxx_method(h_class, RGW_MP_UPLOAD_PART_INFO_UPDATE, CLS_METHOD_RD | CLS_METHOD_WR, rgw_mp_upload_part_info_update, &h_rgw_mp_upload_part_info_update);
-
- /* resharding */
- cls_register_cxx_method(h_class, RGW_RESHARD_ADD, CLS_METHOD_RD | CLS_METHOD_WR, rgw_reshard_add, &h_rgw_reshard_add);
- cls_register_cxx_method(h_class, RGW_RESHARD_LIST, CLS_METHOD_RD, rgw_reshard_list, &h_rgw_reshard_list);
- cls_register_cxx_method(h_class, RGW_RESHARD_GET, CLS_METHOD_RD,rgw_reshard_get, &h_rgw_reshard_get);
- cls_register_cxx_method(h_class, RGW_RESHARD_REMOVE, CLS_METHOD_RD | CLS_METHOD_WR, rgw_reshard_remove, &h_rgw_reshard_remove);
-
- /* resharding attribute */
- cls_register_cxx_method(h_class, RGW_SET_BUCKET_RESHARDING, CLS_METHOD_RD | CLS_METHOD_WR,
- rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding);
- cls_register_cxx_method(h_class, RGW_CLEAR_BUCKET_RESHARDING, CLS_METHOD_RD | CLS_METHOD_WR,
- rgw_clear_bucket_resharding, &h_rgw_clear_bucket_resharding);
- cls_register_cxx_method(h_class, RGW_GUARD_BUCKET_RESHARDING, CLS_METHOD_RD ,
- rgw_guard_bucket_resharding, &h_rgw_guard_bucket_resharding);
- cls_register_cxx_method(h_class, RGW_GET_BUCKET_RESHARDING, CLS_METHOD_RD ,
- rgw_get_bucket_resharding, &h_rgw_get_bucket_resharding);
+
+ using namespace cls::rgw;
+
+ cls_register(ClassId::name, &h_class);
+
+ ClassRegistrar<ClassId> cls(h_class);
+
+ using namespace method;
+
+ // Bucket Index
+ cls.register_cxx_method(bucket_init_index, rgw_bucket_init_index, &h_rgw_bucket_init_index);
+ cls.register_cxx_method(bucket_init_index2, rgw_bucket_init_index, &h_rgw_bucket_init_index);
+ cls.register_cxx_method(bucket_set_tag_timeout, rgw_bucket_set_tag_timeout, &h_rgw_bucket_set_tag_timeout);
+ cls.register_cxx_method(bucket_list, rgw_bucket_list, &h_rgw_bucket_list);
+ cls.register_cxx_method(bucket_check_index, rgw_bucket_check_index, &h_rgw_bucket_check_index);
+ cls.register_cxx_method(bucket_rebuild_index, rgw_bucket_rebuild_index, &h_rgw_bucket_rebuild_index);
+ cls.register_cxx_method(bucket_update_stats, rgw_bucket_update_stats, &h_rgw_bucket_update_stats);
+ cls.register_cxx_method(bucket_prepare_op, rgw_bucket_prepare_op, &h_rgw_bucket_prepare_op);
+ cls.register_cxx_method(bucket_complete_op, rgw_bucket_complete_op, &h_rgw_bucket_complete_op);
+ cls.register_cxx_method(bucket_link_olh, rgw_bucket_link_olh, &h_rgw_bucket_link_olh);
+ cls.register_cxx_method(bucket_unlink_instance, rgw_bucket_unlink_instance, &h_rgw_bucket_unlink_instance_op);
+ cls.register_cxx_method(bucket_read_olh_log, rgw_bucket_read_olh_log, &h_rgw_bucket_read_olh_log);
+ cls.register_cxx_method(bucket_trim_olh_log, rgw_bucket_trim_olh_log, &h_rgw_bucket_trim_olh_log);
+ cls.register_cxx_method(bucket_clear_olh, rgw_bucket_clear_olh, &h_rgw_bucket_clear_olh);
+
+ // Object
+ cls.register_cxx_method(obj_remove, rgw_obj_remove, &h_rgw_obj_remove);
+ cls.register_cxx_method(obj_store_pg_ver, rgw_obj_store_pg_ver, &h_rgw_obj_store_pg_ver);
+ cls.register_cxx_method(obj_check_attrs_prefix, rgw_obj_check_attrs_prefix, &h_rgw_obj_check_attrs_prefix);
+ cls.register_cxx_method(obj_check_mtime, rgw_obj_check_mtime, &h_rgw_obj_check_mtime);
+
+ // Bucket Index (BI) / Resharding
+ cls.register_cxx_method(bi_get, rgw_bi_get_op, &h_rgw_bi_get_op);
+ cls.register_cxx_method(bi_put, rgw_bi_put_op, &h_rgw_bi_put_op);
+ cls.register_cxx_method(bi_put_entries, rgw_bi_put_entries, &h_rgw_bi_put_entries_op);
+ cls.register_cxx_method(bi_list, rgw_bi_list_op, &h_rgw_bi_list_op);
+ cls.register_cxx_method(reshard_log_trim, rgw_reshard_log_trim_op, &h_rgw_reshard_log_trim_op);
+
+ cls.register_cxx_method(bi_log_list, rgw_bi_log_list, &h_rgw_bi_log_list_op);
+ cls.register_cxx_method(bi_log_trim, rgw_bi_log_trim, &h_rgw_bi_log_trim_op);
+ cls.register_cxx_method(dir_suggest_changes, rgw_dir_suggest_changes, &h_rgw_dir_suggest_changes);
+
+ cls.register_cxx_method(bi_log_resync, rgw_bi_log_resync, &h_rgw_bi_log_resync_op);
+ cls.register_cxx_method(bi_log_stop, rgw_bi_log_stop, &h_rgw_bi_log_stop_op);
+
+ // Usage Logging
+ cls.register_cxx_method(user_usage_log_add, rgw_user_usage_log_add, &h_rgw_user_usage_log_add);
+ cls.register_cxx_method(user_usage_log_read, rgw_user_usage_log_read, &h_rgw_user_usage_log_read);
+ cls.register_cxx_method(user_usage_log_trim, rgw_user_usage_log_trim, &h_rgw_user_usage_log_trim);
+ cls.register_cxx_method(usage_log_clear, rgw_usage_log_clear, &h_rgw_usage_log_clear);
+
+ // Garbage Collection
+ cls.register_cxx_method(gc_set_entry, rgw_cls_gc_set_entry, &h_rgw_gc_set_entry);
+ cls.register_cxx_method(method::gc_defer_entry, rgw_cls_gc_defer_entry, &h_rgw_gc_defer_entry);
+ cls.register_cxx_method(gc_list, rgw_cls_gc_list, &h_rgw_gc_list);
+ cls.register_cxx_method(method::gc_remove, rgw_cls_gc_remove, &h_rgw_gc_remove);
+
+ // Lifecycle Bucket List
+ cls.register_cxx_method(lc_get_entry, rgw_cls_lc_get_entry, &h_rgw_lc_get_entry);
+ cls.register_cxx_method(lc_set_entry, rgw_cls_lc_set_entry, &h_rgw_lc_set_entry);
+ cls.register_cxx_method(lc_rm_entry, rgw_cls_lc_rm_entry, &h_rgw_lc_rm_entry);
+ cls.register_cxx_method(lc_get_next_entry, rgw_cls_lc_get_next_entry, &h_rgw_lc_get_next_entry);
+ cls.register_cxx_method(lc_put_head, rgw_cls_lc_put_head, &h_rgw_lc_put_head);
+ cls.register_cxx_method(lc_get_head, rgw_cls_lc_get_head, &h_rgw_lc_get_head);
+ cls.register_cxx_method(lc_list_entries, rgw_cls_lc_list_entries, &h_rgw_lc_list_entries);
+
+ // Multipart
+ cls.register_cxx_method(mp_upload_part_info_update, rgw_mp_upload_part_info_update, &h_rgw_mp_upload_part_info_update);
+
+ // Resharding
+ cls.register_cxx_method(reshard_add, rgw_reshard_add, &h_rgw_reshard_add);
+ cls.register_cxx_method(reshard_list, rgw_reshard_list, &h_rgw_reshard_list);
+ cls.register_cxx_method(reshard_get, rgw_reshard_get, &h_rgw_reshard_get);
+ cls.register_cxx_method(reshard_remove, rgw_reshard_remove, &h_rgw_reshard_remove);
+
+ // Resharding Attribute
+ cls.register_cxx_method(set_bucket_resharding, rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding);
+ cls.register_cxx_method(clear_bucket_resharding, rgw_clear_bucket_resharding, &h_rgw_clear_bucket_resharding);
+ cls.register_cxx_method(method::guard_bucket_resharding, rgw_guard_bucket_resharding, &h_rgw_guard_bucket_resharding);
+ cls.register_cxx_method(get_bucket_resharding, rgw_get_bucket_resharding, &h_rgw_get_bucket_resharding);
return;
}
using ceph::real_time;
using namespace librados;
+using namespace cls::rgw;
const string BucketIndexShardsManager::KEY_VALUE_SEPARATOR = "#";
const string BucketIndexShardsManager::SHARDS_SEPARATOR = ",";
void cls_rgw_bucket_init_index(ObjectWriteOperation& o)
{
bufferlist in;
- o.exec(RGW_CLASS, RGW_BUCKET_INIT_INDEX, in);
+ o.exec(method::bucket_init_index, in);
}
void cls_rgw_bucket_init_index2(ObjectWriteOperation& o)
{
bufferlist in;
- o.exec(RGW_CLASS, RGW_BUCKET_INIT_INDEX2, in);
+ o.exec(method::bucket_init_index2, in);
}
void cls_rgw_bucket_set_tag_timeout(librados::ObjectWriteOperation& op,
const auto call = rgw_cls_tag_timeout_op{.tag_timeout = timeout};
bufferlist in;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_SET_TAG_TIMEOUT, in);
+ op.exec(method::bucket_set_tag_timeout, in);
}
void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o,
call.dec_stats = *dec_stats;
bufferlist in;
encode(call, in);
- o.exec(RGW_CLASS, RGW_BUCKET_UPDATE_STATS, in);
+ o.exec(method::bucket_update_stats, in);
}
void cls_rgw_bucket_prepare_op(ObjectWriteOperation& o, RGWModifyOp op, const string& tag,
call.locator = locator;
bufferlist in;
encode(call, in);
- o.exec(RGW_CLASS, RGW_BUCKET_PREPARE_OP, in);
+ o.exec(method::bucket_prepare_op, in);
}
void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, const string& tag,
call.zones_trace = *zones_trace;
}
encode(call, in);
- o.exec(RGW_CLASS, RGW_BUCKET_COMPLETE_OP, in);
+ o.exec(method::bucket_complete_op, in);
}
void cls_rgw_bucket_list_op(librados::ObjectReadOperation& op,
call.list_versions = list_versions;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_LIST, in,
+ op.exec(method::bucket_list, in,
new ClsBucketIndexOpCtx<rgw_cls_list_ret>(result, NULL));
}
rgw_cls_obj_remove_op call;
call.keep_attr_prefixes = keep_attr_prefixes;
encode(call, in);
- o.exec(RGW_CLASS, RGW_OBJ_REMOVE, in);
+ o.exec(method::obj_remove, in);
}
void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& attr)
rgw_cls_obj_store_pg_ver_op call;
call.attr = attr;
encode(call, in);
- o.exec(RGW_CLASS, RGW_OBJ_STORE_PG_VER, in);
+ o.exec(method::obj_store_pg_ver, in);
}
void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string& prefix, bool fail_if_exist)
call.check_prefix = prefix;
call.fail_if_exist = fail_if_exist;
encode(call, in);
- o.exec(RGW_CLASS, RGW_OBJ_CHECK_ATTRS_PREFIX, in);
+ o.exec(method::obj_check_attrs_prefix, in);
}
void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const real_time& mtime, bool high_precision_time, RGWCheckMTimeType type)
call.high_precision_time = high_precision_time;
call.type = type;
encode(call, in);
- o.exec(RGW_CLASS, RGW_OBJ_CHECK_MTIME, in);
+ o.exec(method::obj_check_mtime, in);
}
int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid,
call.key = key;
call.type = index_type;
encode(call, in);
- int r = io_ctx.exec(oid, RGW_CLASS, RGW_BI_GET, in, out);
+ int r = io_ctx.exec(oid, method::bi_get, in, out);
if (r < 0)
return r;
call.entry = entry;
encode(call, in);
librados::ObjectWriteOperation op;
- op.exec(RGW_CLASS, RGW_BI_PUT, in);
+ op.exec(method::bi_put, in);
int r = io_ctx.operate(oid, &op);
if (r < 0)
return r;
rgw_cls_bi_put_op call;
call.entry = entry;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BI_PUT, in);
+ op.exec(method::bi_put, in);
}
void cls_rgw_bi_put_entries(librados::ObjectWriteOperation& op,
bufferlist in;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BI_PUT_ENTRIES, in);
+ op.exec(method::bi_put_entries, in);
}
/* nb: any entries passed in are replaced with the results of the cls
call.max = max;
call.reshardlog = reshardlog;
encode(call, in);
- int r = io_ctx.exec(oid, RGW_CLASS, RGW_BI_LIST, in, out);
+ int r = io_ctx.exec(oid, method::bi_list, in, out);
if (r < 0)
return r;
call.high_precision_time = high_precision_time;
call.zones_trace = zones_trace;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_LINK_OLH, in);
+ op.exec(method::bucket_link_olh, in);
}
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid,
call.zones_trace = zones_trace;
call.bilog_flags = bilog_flags;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_UNLINK_INSTANCE, in);
+ op.exec(method::bucket_unlink_instance, in);
}
void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const string& olh_tag, rgw_cls_read_olh_log_ret& log_ret, int& op_ret)
call.ver_marker = ver_marker;
call.olh_tag = olh_tag;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_READ_OLH_LOG, in, new ClsBucketIndexOpCtx<rgw_cls_read_olh_log_ret>(&log_ret, &op_ret));
+ op.exec(method::bucket_read_olh_log, in, new ClsBucketIndexOpCtx<rgw_cls_read_olh_log_ret>(&log_ret, &op_ret));
}
int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker,
call.ver = ver;
call.olh_tag = olh_tag;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_TRIM_OLH_LOG, in);
+ op.exec(method::bucket_trim_olh_log, in);
}
int cls_rgw_clear_olh(IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag)
call.key = olh;
call.olh_tag = olh_tag;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_CLEAR_OLH, in);
+ op.exec(method::bucket_clear_olh, in);
}
void cls_rgw_bilog_list(librados::ObjectReadOperation& op,
bufferlist in;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BI_LOG_LIST, in, new ClsBucketIndexOpCtx<cls_rgw_bi_log_list_ret>(pdata, ret));
+ op.exec(method::bi_log_list, in, new ClsBucketIndexOpCtx<cls_rgw_bi_log_list_ret>(pdata, ret));
}
void cls_rgw_bilog_trim(librados::ObjectWriteOperation& op,
bufferlist in;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BI_LOG_TRIM, in);
+ op.exec(method::bi_log_trim, in);
}
void cls_rgw_bucket_reshard_log_trim(librados::ObjectWriteOperation& op)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_RESHARD_LOG_TRIM, in);
+ op.exec(method::reshard_log_trim, in);
}
void cls_rgw_bucket_check_index(librados::ObjectReadOperation& op,
bufferlist& out)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_BUCKET_CHECK_INDEX, in, &out, nullptr);
+ op.exec(method::bucket_check_index, in, &out, nullptr);
}
void cls_rgw_bucket_check_index_decode(const bufferlist& out,
void cls_rgw_bucket_rebuild_index(librados::ObjectWriteOperation& op)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_BUCKET_REBUILD_INDEX, in);
+ op.exec(method::bucket_rebuild_index, in);
}
void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist& updates)
void cls_rgw_suggest_changes(ObjectWriteOperation& o, bufferlist& updates)
{
- o.exec(RGW_CLASS, RGW_DIR_SUGGEST_CHANGES, updates);
+ o.exec(method::dir_suggest_changes, updates);
}
void cls_rgw_bilog_start(ObjectWriteOperation& op)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_BI_LOG_RESYNC, in);
+ op.exec(method::bi_log_resync, in);
}
void cls_rgw_bilog_stop(ObjectWriteOperation& op)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_BI_LOG_STOP, in);
+ op.exec(method::bi_log_stop, in);
}
class GetDirHeaderCompletion : public ObjectOperationCompletion {
call.num_entries = 0;
encode(call, in);
ObjectReadOperation op;
- op.exec(RGW_CLASS, RGW_BUCKET_LIST, in,
+ op.exec(method::bucket_list, in,
new GetDirHeaderCompletion(std::move(cb)));
AioCompletion *c = librados::Rados::aio_create_completion(nullptr, nullptr);
int r = io_ctx.aio_operate(oid, c, &op, NULL);
call.bucket = bucket;
call.iter = read_iter;
encode(call, in);
- int r = io_ctx.exec(oid, RGW_CLASS, RGW_USER_USAGE_LOG_READ, in, out);
+ int r = io_ctx.exec(oid, method::user_usage_log_read, in, out);
if (r < 0)
return r;
bool done = false;
do {
ObjectWriteOperation op;
- op.exec(RGW_CLASS, RGW_USER_USAGE_LOG_TRIM, in);
+ op.exec(method::user_usage_log_trim, in);
int r = io_ctx.operate(oid, &op);
if (r == -ENODATA)
done = true;
call.bucket = bucket;
encode(call, in);
- op.exec(RGW_CLASS, RGW_USER_USAGE_LOG_TRIM, in);
+ op.exec(method::user_usage_log_trim, in);
}
void cls_rgw_usage_log_clear(ObjectWriteOperation& op)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_USAGE_LOG_CLEAR, in);
+ op.exec(method::usage_log_clear, in);
}
void cls_rgw_usage_log_add(ObjectWriteOperation& op, rgw_usage_log_info& info)
rgw_cls_usage_log_add_op call;
call.info = info;
encode(call, in);
- op.exec(RGW_CLASS, RGW_USER_USAGE_LOG_ADD, in);
+ op.exec(method::user_usage_log_add, in);
}
/* garbage collection */
call.expiration_secs = expiration_secs;
call.info = info;
encode(call, in);
- op.exec(RGW_CLASS, RGW_GC_SET_ENTRY, in);
+ op.exec(method::gc_set_entry, in);
}
void cls_rgw_gc_defer_entry(ObjectWriteOperation& op, uint32_t expiration_secs, const string& tag)
call.expiration_secs = expiration_secs;
call.tag = tag;
encode(call, in);
- op.exec(RGW_CLASS, RGW_GC_DEFER_ENTRY, in);
+ op.exec(method::gc_defer_entry, in);
}
void cls_rgw_gc_list(ObjectReadOperation& op, const string& marker,
call.max = max;
call.expired_only = expired_only;
encode(call, in);
- op.exec(RGW_CLASS, RGW_GC_LIST, in, &out, nullptr);
+ op.exec(method::gc_list, in, &out, nullptr);
}
int cls_rgw_gc_list_decode(const bufferlist& out,
cls_rgw_gc_remove_op call;
call.tags = tags;
encode(call, in);
- op.exec(RGW_CLASS, RGW_GC_REMOVE, in);
+ op.exec(method::gc_remove, in);
}
void cls_rgw_lc_get_head(ObjectReadOperation& op, bufferlist& out)
{
bufferlist in;
- op.exec(RGW_CLASS, RGW_LC_GET_HEAD, in, &out, nullptr);
+ op.exec(method::lc_get_head, in, &out, nullptr);
}
int cls_rgw_lc_get_head_decode(const bufferlist& out, cls_rgw_lc_obj_head& head)
cls_rgw_lc_put_head_op call;
call.head = head;
encode(call, in);
- op.exec(RGW_CLASS, RGW_LC_PUT_HEAD, in);
+ op.exec(method::lc_put_head, in);
}
void cls_rgw_lc_get_next_entry(ObjectReadOperation& op, const string& marker,
cls_rgw_lc_get_next_entry_op call;
call.marker = marker;
encode(call, in);
- op.exec(RGW_CLASS, RGW_LC_GET_NEXT_ENTRY, in, &out, nullptr);
+ op.exec(method::lc_get_next_entry, in, &out, nullptr);
}
int cls_rgw_lc_get_next_entry_decode(const bufferlist& out, cls_rgw_lc_entry& entry)
cls_rgw_lc_rm_entry_op call;
call.entry = entry;
encode(call, in);
- op.exec(RGW_CLASS, RGW_LC_RM_ENTRY, in);
+ op.exec(method::lc_rm_entry, in);
}
void cls_rgw_lc_set_entry(ObjectWriteOperation& op,
cls_rgw_lc_set_entry_op call;
call.entry = entry;
encode(call, in);
- op.exec(RGW_CLASS, RGW_LC_SET_ENTRY, in);
+ op.exec(method::lc_set_entry, in);
}
void cls_rgw_lc_get_entry(ObjectReadOperation& op, const std::string& marker,
bufferlist in;
cls_rgw_lc_get_entry_op call{marker};
encode(call, in);
- op.exec(RGW_CLASS, RGW_LC_GET_ENTRY, in, &out, nullptr);
+ op.exec(method::lc_get_entry, in, &out, nullptr);
}
int cls_rgw_lc_get_entry_decode(const bufferlist& out, cls_rgw_lc_entry& entry)
encode(call, in);
- op.exec(RGW_CLASS, RGW_LC_LIST_ENTRIES, in, &out, nullptr);
+ op.exec(method::lc_list_entries, in, &out, nullptr);
}
int cls_rgw_lc_list_decode(const bufferlist& out, std::vector<cls_rgw_lc_entry>& entries)
buffer::list in;
encode(call, in);
- op.exec(RGW_CLASS, RGW_MP_UPLOAD_PART_INFO_UPDATE, in);
+ op.exec(method::mp_upload_part_info_update, in);
}
void cls_rgw_reshard_add(librados::ObjectWriteOperation& op,
call.entry = entry;
call.create_only = create_only;
encode(call, in);
- op.exec(RGW_CLASS, RGW_RESHARD_ADD, in);
+ op.exec(method::reshard_add, in);
}
int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& marker, uint32_t max,
call.marker = marker;
call.max = max;
encode(call, in);
- int r = io_ctx.exec(oid, RGW_CLASS, RGW_RESHARD_LIST, in, out);
+ int r = io_ctx.exec(oid, method::reshard_list, in, out);
if (r < 0)
return r;
cls_rgw_reshard_get_op call;
call.entry = entry;
encode(call, in);
- int r = io_ctx.exec(oid, RGW_CLASS, RGW_RESHARD_GET, in, out);
+ int r = io_ctx.exec(oid, method::reshard_get, in, out);
if (r < 0)
return r;
call.bucket_name = entry.bucket_name;
call.bucket_id = entry.bucket_id;
encode(call, in);
- op.exec(RGW_CLASS, RGW_RESHARD_REMOVE, in);
+ op.exec(method::reshard_remove, in);
}
void cls_rgw_clear_bucket_resharding(librados::ObjectWriteOperation& op)
bufferlist in;
cls_rgw_clear_bucket_resharding_op call;
encode(call, in);
- op.exec(RGW_CLASS, RGW_CLEAR_BUCKET_RESHARDING, in);
+ op.exec(method::clear_bucket_resharding, in);
}
void cls_rgw_get_bucket_resharding(librados::ObjectReadOperation& op,
bufferlist in;
cls_rgw_get_bucket_resharding_op call;
encode(call, in);
- op.exec(RGW_CLASS, RGW_GET_BUCKET_RESHARDING, in, &out, nullptr);
+ op.exec(method::get_bucket_resharding, in, &out, nullptr);
}
void cls_rgw_get_bucket_resharding_decode(const bufferlist& out,
cls_rgw_guard_bucket_resharding_op call;
call.ret_err = ret_err;
encode(call, in);
- op.exec(RGW_CLASS, RGW_GUARD_BUCKET_RESHARDING, in);
+ op.exec(method::guard_bucket_resharding, in);
}
void cls_rgw_set_bucket_resharding(librados::ObjectWriteOperation& op,
encode(call, in);
op.assert_exists(); // the shard must exist; if not fail rather than recreate
- op.exec(RGW_CLASS, RGW_SET_BUCKET_RESHARDING, in);
+ op.exec(method::set_bucket_resharding, in);
}
void dump(ceph::Formatter *f) const;
};
WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_ret)
+
+namespace cls::rgw {
+struct ClassId {
+ static constexpr auto name = "rgw";
+};
+namespace method {
+// Bucket Index
+constexpr auto bucket_init_index = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_INIT_INDEX);
+constexpr auto bucket_init_index2 = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_INIT_INDEX2);
+constexpr auto bucket_set_tag_timeout = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_SET_TAG_TIMEOUT);
+constexpr auto bucket_list = ClsMethod<RdTag, ClassId>(RGW_BUCKET_LIST);
+constexpr auto bucket_check_index = ClsMethod<RdTag, ClassId>(RGW_BUCKET_CHECK_INDEX);
+constexpr auto bucket_rebuild_index = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_REBUILD_INDEX);
+constexpr auto bucket_update_stats = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_UPDATE_STATS);
+constexpr auto bucket_prepare_op = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_PREPARE_OP);
+constexpr auto bucket_complete_op = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_COMPLETE_OP);
+constexpr auto bucket_link_olh = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_LINK_OLH);
+constexpr auto bucket_unlink_instance = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_UNLINK_INSTANCE);
+constexpr auto bucket_read_olh_log = ClsMethod<RdTag, ClassId>(RGW_BUCKET_READ_OLH_LOG);
+constexpr auto bucket_trim_olh_log = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_TRIM_OLH_LOG);
+constexpr auto bucket_clear_olh = ClsMethod<RdWrTag, ClassId>(RGW_BUCKET_CLEAR_OLH);
+
+// Object
+constexpr auto obj_remove = ClsMethod<RdWrTag, ClassId>(RGW_OBJ_REMOVE);
+constexpr auto obj_store_pg_ver = ClsMethod<WrTag, ClassId>(RGW_OBJ_STORE_PG_VER);
+constexpr auto obj_check_attrs_prefix = ClsMethod<RdTag, ClassId>(RGW_OBJ_CHECK_ATTRS_PREFIX);
+constexpr auto obj_check_mtime = ClsMethod<RdTag, ClassId>(RGW_OBJ_CHECK_MTIME);
+
+// Bucket Index (BI) / Resharding
+constexpr auto bi_get = ClsMethod<RdTag, ClassId>(RGW_BI_GET);
+constexpr auto bi_put = ClsMethod<RdWrTag, ClassId>(RGW_BI_PUT);
+constexpr auto bi_put_entries = ClsMethod<RdWrTag, ClassId>(RGW_BI_PUT_ENTRIES);
+constexpr auto bi_list = ClsMethod<RdTag, ClassId>(RGW_BI_LIST);
+constexpr auto reshard_log_trim = ClsMethod<RdWrTag, ClassId>(RGW_RESHARD_LOG_TRIM);
+constexpr auto bi_log_list = ClsMethod<RdTag, ClassId>(RGW_BI_LOG_LIST);
+constexpr auto bi_log_trim = ClsMethod<RdWrTag, ClassId>(RGW_BI_LOG_TRIM);
+constexpr auto dir_suggest_changes = ClsMethod<RdWrTag, ClassId>(RGW_DIR_SUGGEST_CHANGES);
+constexpr auto bi_log_resync = ClsMethod<RdWrTag, ClassId>(RGW_BI_LOG_RESYNC);
+constexpr auto bi_log_stop = ClsMethod<RdWrTag, ClassId>(RGW_BI_LOG_STOP);
+
+// Usage Logging
+constexpr auto user_usage_log_add = ClsMethod<RdWrTag, ClassId>(RGW_USER_USAGE_LOG_ADD);
+constexpr auto user_usage_log_read = ClsMethod<RdTag, ClassId>(RGW_USER_USAGE_LOG_READ);
+constexpr auto user_usage_log_trim = ClsMethod<RdWrTag, ClassId>(RGW_USER_USAGE_LOG_TRIM);
+constexpr auto usage_log_clear = ClsMethod<WrTag, ClassId>(RGW_USAGE_LOG_CLEAR);
+
+// Garbage Collection
+constexpr auto gc_set_entry = ClsMethod<RdWrTag, ClassId>(RGW_GC_SET_ENTRY);
+constexpr auto gc_defer_entry = ClsMethod<RdWrTag, ClassId>(RGW_GC_DEFER_ENTRY);
+constexpr auto gc_list = ClsMethod<RdTag, ClassId>(RGW_GC_LIST);
+constexpr auto gc_remove = ClsMethod<RdWrTag, ClassId>(RGW_GC_REMOVE);
+
+// Lifecycle Bucket List
+constexpr auto lc_get_entry = ClsMethod<RdTag, ClassId>(RGW_LC_GET_ENTRY);
+constexpr auto lc_set_entry = ClsMethod<RdWrTag, ClassId>(RGW_LC_SET_ENTRY);
+constexpr auto lc_rm_entry = ClsMethod<RdWrTag, ClassId>(RGW_LC_RM_ENTRY);
+constexpr auto lc_get_next_entry = ClsMethod<RdTag, ClassId>(RGW_LC_GET_NEXT_ENTRY);
+constexpr auto lc_put_head = ClsMethod<RdWrTag, ClassId>(RGW_LC_PUT_HEAD);
+constexpr auto lc_get_head = ClsMethod<RdTag, ClassId>(RGW_LC_GET_HEAD);
+constexpr auto lc_list_entries = ClsMethod<RdTag, ClassId>(RGW_LC_LIST_ENTRIES);
+
+// Multipart
+constexpr auto mp_upload_part_info_update = ClsMethod<RdWrTag, ClassId>(RGW_MP_UPLOAD_PART_INFO_UPDATE);
+
+// Resharding
+constexpr auto reshard_add = ClsMethod<RdWrTag, ClassId>(RGW_RESHARD_ADD);
+constexpr auto reshard_list = ClsMethod<RdTag, ClassId>(RGW_RESHARD_LIST);
+constexpr auto reshard_get = ClsMethod<RdTag, ClassId>(RGW_RESHARD_GET);
+constexpr auto reshard_remove = ClsMethod<RdWrTag, ClassId>(RGW_RESHARD_REMOVE);
+
+// Resharding Attribute
+constexpr auto set_bucket_resharding = ClsMethod<RdWrTag, ClassId>(RGW_SET_BUCKET_RESHARDING);
+constexpr auto clear_bucket_resharding = ClsMethod<RdWrTag, ClassId>(RGW_CLEAR_BUCKET_RESHARDING);
+constexpr auto guard_bucket_resharding = ClsMethod<RdTag, ClassId>(RGW_GUARD_BUCKET_RESHARDING);
+constexpr auto get_bucket_resharding = ClsMethod<RdTag, ClassId>(RGW_GET_BUCKET_RESHARDING);
+}
+}
#include "rgw/rgw_basic_types.h"
+#include "include/rados/cls_traits.h"
+
+#include "cls_rgw_const.h"
+
#define CEPH_RGW_REMOVE 'r' // value 114
#define CEPH_RGW_UPDATE 'u' // value 117
#define CEPH_RGW_DIR_SUGGEST_LOG_OP 0x80
cls_method_handle_t h_rgw_gc_queue_remove_entries;
cls_method_handle_t h_rgw_gc_queue_update_entry;
- cls_register(RGW_GC_CLASS, &h_class);
-
- /* gc */
- cls_register_cxx_method(h_class, RGW_GC_QUEUE_INIT, CLS_METHOD_RD | CLS_METHOD_WR, cls_rgw_gc_queue_init, &h_rgw_gc_queue_init);
- cls_register_cxx_method(h_class, RGW_GC_QUEUE_ENQUEUE, CLS_METHOD_RD | CLS_METHOD_WR, cls_rgw_gc_queue_enqueue, &h_rgw_gc_queue_enqueue);
- cls_register_cxx_method(h_class, RGW_GC_QUEUE_LIST_ENTRIES, CLS_METHOD_RD, cls_rgw_gc_queue_list_entries, &h_rgw_gc_queue_list_entries);
- cls_register_cxx_method(h_class, RGW_GC_QUEUE_REMOVE_ENTRIES, CLS_METHOD_RD | CLS_METHOD_WR, cls_rgw_gc_queue_remove_entries, &h_rgw_gc_queue_remove_entries);
- cls_register_cxx_method(h_class, RGW_GC_QUEUE_UPDATE_ENTRY, CLS_METHOD_RD | CLS_METHOD_WR, cls_rgw_gc_queue_update_entry, &h_rgw_gc_queue_update_entry);
+ using namespace cls::rgw_gc;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::init, cls_rgw_gc_queue_init, &h_rgw_gc_queue_init);
+ cls.register_cxx_method(method::enqueue, cls_rgw_gc_queue_enqueue, &h_rgw_gc_queue_enqueue);
+ cls.register_cxx_method(method::list_entries, cls_rgw_gc_queue_list_entries, &h_rgw_gc_queue_list_entries);
+ cls.register_cxx_method(method::remove_entries, cls_rgw_gc_queue_remove_entries, &h_rgw_gc_queue_remove_entries);
+ cls.register_cxx_method(method::update_entry, cls_rgw_gc_queue_update_entry, &h_rgw_gc_queue_update_entry);
return;
}
using ceph::encode;
using namespace librados;
+using namespace cls::rgw_gc;
void cls_rgw_gc_queue_init(ObjectWriteOperation& op, uint64_t size, uint64_t num_deferred_entries)
{
call.size = size;
call.num_deferred_entries = num_deferred_entries;
encode(call, in);
- op.exec(RGW_GC_CLASS, RGW_GC_QUEUE_INIT, in);
+ op.exec(method::init, in);
}
int cls_rgw_gc_queue_get_capacity(IoCtx& io_ctx, const string& oid, uint64_t& size)
{
bufferlist in, out;
- int r = io_ctx.exec(oid, QUEUE_CLASS, QUEUE_GET_CAPACITY, in, out);
+ int r = io_ctx.exec(oid, cls::queue::method::get_capacity, in, out);
if (r < 0)
return r;
call.expiration_secs = expiration_secs;
call.info = info;
encode(call, in);
- op.exec(RGW_GC_CLASS, RGW_GC_QUEUE_ENQUEUE, in);
+ op.exec(method::enqueue, in);
}
int cls_rgw_gc_queue_list_entries(IoCtx& io_ctx, const string& oid, const string& marker, uint32_t max, bool expired_only,
op.expired_only = expired_only;
encode(op, in);
- int r = io_ctx.exec(oid, RGW_GC_CLASS, RGW_GC_QUEUE_LIST_ENTRIES, in, out);
+ int r = io_ctx.exec(oid, method::list_entries, in, out);
if (r < 0)
return r;
cls_rgw_gc_queue_remove_entries_op rem_op;
rem_op.num_entries = num_entries;
encode(rem_op, in);
- op.exec(RGW_GC_CLASS, RGW_GC_QUEUE_REMOVE_ENTRIES, in);
+ op.exec(method::remove_entries, in);
}
void cls_rgw_gc_queue_defer_entry(ObjectWriteOperation& op, uint32_t expiration_secs, const cls_rgw_gc_obj_info& info)
defer_op.expiration_secs = expiration_secs;
defer_op.info = info;
encode(defer_op, in);
- op.exec(RGW_GC_CLASS, RGW_GC_QUEUE_UPDATE_ENTRY, in);
+ op.exec(method::update_entry, in);
}
#pragma once
#include "cls/rgw/cls_rgw_types.h"
+#include "cls_rgw_gc_const.h"
+#include "include/rados/cls_traits.h"
struct cls_rgw_gc_queue_init_op {
uint64_t size;
}
};
WRITE_CLASS_ENCODER(cls_rgw_gc_queue_defer_entry_op)
+
+namespace cls::rgw_gc {
+struct ClassId {
+ static constexpr auto name = RGW_GC_CLASS;
+};
+namespace method {
+constexpr auto init = ClsMethod<RdWrTag, ClassId>(RGW_GC_QUEUE_INIT);
+constexpr auto enqueue = ClsMethod<RdWrTag, ClassId>(RGW_GC_QUEUE_ENQUEUE);
+constexpr auto list_entries = ClsMethod<RdTag, ClassId>(RGW_GC_QUEUE_LIST_ENTRIES);
+constexpr auto remove_entries = ClsMethod<RdWrTag, ClassId>(RGW_GC_QUEUE_REMOVE_ENTRIES);
+constexpr auto update_entry = ClsMethod<RdWrTag, ClassId>(RGW_GC_QUEUE_UPDATE_ENTRY);
+}
+}
\ No newline at end of file
* This is an example RADOS object class built using only the Ceph SDK interface.
*/
#include "include/rados/objclass.h"
+#include "cls_sdk_ops.h"
CLS_VER(1,0)
CLS_NAME(sdk)
return 0;
}
-CLS_INIT(sdk)
-{
+CLS_INIT(sdk) {
CLS_LOG(0, "loading cls_sdk");
- cls_register("sdk", &h_class);
+ using namespace cls::sdk;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
- cls_register_cxx_method(h_class, "test_coverage_write",
- CLS_METHOD_RD|CLS_METHOD_WR,
- test_coverage_write, &h_test_coverage_write);
-
- cls_register_cxx_method(h_class, "test_coverage_replay",
- CLS_METHOD_RD|CLS_METHOD_WR,
- test_coverage_replay, &h_test_coverage_replay);
+ cls.register_cxx_method(method::test_coverage_write, test_coverage_write, &h_test_coverage_write);
+ cls.register_cxx_method(method::test_coverage_replay, test_coverage_replay, &h_test_coverage_replay);
}
--- /dev/null
+#pragma once
+
+#include "include/rados/cls_traits.h"
+
+namespace cls::sdk {
+struct ClassId {
+ static constexpr auto name = "sdk";
+};
+namespace method {
+constexpr auto test_coverage_write = ClsMethod<RdWrTag, ClassId>("test_coverage_write");
+constexpr auto test_coverage_replay = ClsMethod<RdWrTag, ClassId>("test_coverage_replay");
+}
+}
\ No newline at end of file
cls_method_handle_t h_decrement;
cls_method_handle_t h_list;
- cls_register(ss::CLASS, &h_class);
- cls_register_cxx_method(h_class, ss::INCREMENT,
- CLS_METHOD_RD | CLS_METHOD_WR,
- &increment, &h_increment);
-
- cls_register_cxx_method(h_class, ss::DECREMENT,
- CLS_METHOD_RD | CLS_METHOD_WR,
- &decrement, &h_decrement);
-
- cls_register_cxx_method(h_class, ss::RESET,
- CLS_METHOD_RD | CLS_METHOD_WR,
- &reset, &h_decrement);
-
- cls_register_cxx_method(h_class, ss::LIST,
- CLS_METHOD_RD,
- &list, &h_list);
+ using namespace cls::sem_set;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::increment, &::increment, &h_increment);
+ cls.register_cxx_method(method::decrement, &::decrement, &h_decrement);
+ cls.register_cxx_method(method::reset, &::reset, &h_decrement);
+ cls.register_cxx_method(method::list, &::list, &h_list);
return;
}
#include <boost/container/flat_map.hpp>
#include "include/encoding.h"
+#include "include/rados/cls_traits.h"
namespace cls::sem_set {
using namespace std::literals;
inline constexpr auto RESET = "reset";
inline constexpr auto LIST = "list";
+struct ClassId {
+ static constexpr auto name = CLASS;
+};
+namespace method {
+constexpr auto increment = ClsMethod<RdWrTag, ClassId>(INCREMENT);
+constexpr auto decrement = ClsMethod<RdWrTag, ClassId>(DECREMENT);
+constexpr auto reset = ClsMethod<RdWrTag, ClassId>(RESET);
+constexpr auto list = ClsMethod<RdTag, ClassId>(LIST);
+}
+
} // namespace cls::sem_set
cls_method_handle_t h_timeindex_list;
cls_method_handle_t h_timeindex_trim;
- cls_register("timeindex", &h_class);
-
- /* timeindex */
- cls_register_cxx_method(h_class, "add", CLS_METHOD_RD | CLS_METHOD_WR,
- cls_timeindex_add, &h_timeindex_add);
- cls_register_cxx_method(h_class, "list", CLS_METHOD_RD,
- cls_timeindex_list, &h_timeindex_list);
- cls_register_cxx_method(h_class, "trim", CLS_METHOD_RD | CLS_METHOD_WR,
- cls_timeindex_trim, &h_timeindex_trim);
+ using namespace cls::timeindex;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::add, cls_timeindex_add, &h_timeindex_add);
+ cls.register_cxx_method(method::list, cls_timeindex_list, &h_timeindex_list);
+ cls.register_cxx_method(method::trim, cls_timeindex_trim, &h_timeindex_trim);
return;
}
#include "cls/timeindex/cls_timeindex_client.h"
#include "include/compat.h"
+using namespace cls::timeindex;
+
void cls_timeindex_add(
librados::ObjectWriteOperation& op,
std::list<cls_timeindex_entry>& entries)
call.entries = entries;
encode(call, in);
- op.exec("timeindex", "add", in);
+ op.exec(method::add, in);
}
void cls_timeindex_add(
call.entries.push_back(entry);
encode(call, in);
- op.exec("timeindex", "add", in);
+ op.exec(method::add, in);
}
void cls_timeindex_add_prepare_entry(
encode(call, in);
- op.exec("timeindex", "trim", in);
+ op.exec(method::trim, in);
}
int cls_timeindex_trim(
encode(call, in);
- op.exec("timeindex", "list", in,
+ op.exec(method::list, in,
new TimeindexListCtx(&entries, out_marker, truncated));
}
#include "common/ceph_json.h"
#include "cls_timeindex_types.h"
+#include "include/rados/cls_traits.h"
struct cls_timeindex_add_op {
std::list<cls_timeindex_entry> entries;
};
WRITE_CLASS_ENCODER(cls_timeindex_trim_op)
+namespace cls::timeindex {
+struct ClassId {
+ static constexpr auto name = "timeindex";
+};
+namespace method {
+constexpr auto add = ClsMethod<RdWrTag, ClassId>("add");
+constexpr auto list = ClsMethod<RdTag, ClassId>("list");
+constexpr auto trim = ClsMethod<RdWrTag, ClassId>("trim");
+}
+}
+
#endif /* CEPH_CLS_TIMEINDEX_OPS_H */
cls_method_handle_t h_user_reset_stats;
cls_method_handle_t h_user_reset_stats2;
- cls_register("user", &h_class);
-
- /* log */
- cls_register_cxx_method(h_class, "set_buckets_info", CLS_METHOD_RD | CLS_METHOD_WR,
- cls_user_set_buckets_info, &h_user_set_buckets_info);
- cls_register_cxx_method(h_class, "complete_stats_sync", CLS_METHOD_RD | CLS_METHOD_WR,
- cls_user_complete_stats_sync, &h_user_complete_stats_sync);
- cls_register_cxx_method(h_class, "remove_bucket", CLS_METHOD_RD | CLS_METHOD_WR, cls_user_remove_bucket, &h_user_remove_bucket);
- cls_register_cxx_method(h_class, "list_buckets", CLS_METHOD_RD, cls_user_list_buckets, &h_user_list_buckets);
- cls_register_cxx_method(h_class, "get_header", CLS_METHOD_RD, cls_user_get_header, &h_user_get_header);
- cls_register_cxx_method(h_class, "reset_user_stats", CLS_METHOD_RD | CLS_METHOD_WR, cls_user_reset_stats, &h_user_reset_stats);
- cls_register_cxx_method(h_class, "reset_user_stats2", CLS_METHOD_RD | CLS_METHOD_WR, cls_user_reset_stats2, &h_user_reset_stats2);
+ using namespace cls::user;
+ cls_register(ClassId::name, &h_class);
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::set_buckets_info, cls_user_set_buckets_info, &h_user_set_buckets_info);
+ cls.register_cxx_method(method::complete_stats_sync, cls_user_complete_stats_sync, &h_user_complete_stats_sync);
+ cls.register_cxx_method(method::remove_bucket, cls_user_remove_bucket, &h_user_remove_bucket);
+ cls.register_cxx_method(method::list_buckets, cls_user_list_buckets, &h_user_list_buckets);
+ cls.register_cxx_method(method::get_header, cls_user_get_header, &h_user_get_header);
+ cls.register_cxx_method(method::reset_user_stats, cls_user_reset_stats, &h_user_reset_stats);
+ cls.register_cxx_method(method::reset_user_stats2, cls_user_reset_stats2, &h_user_reset_stats2);
// account
cls_method_handle_t h_account_resource_add;
cls_method_handle_t h_account_resource_rm;
cls_method_handle_t h_account_resource_list;
- cls_register_cxx_method(h_class, "account_resource_add", CLS_METHOD_RD | CLS_METHOD_WR,
- cls_account_resource_add, &h_account_resource_add);
- cls_register_cxx_method(h_class, "account_resource_get", CLS_METHOD_RD,
- cls_account_resource_get, &h_account_resource_get);
- cls_register_cxx_method(h_class, "account_resource_rm", CLS_METHOD_RD | CLS_METHOD_WR,
- cls_account_resource_rm, &h_account_resource_rm);
- cls_register_cxx_method(h_class, "account_resource_list", CLS_METHOD_RD,
- cls_account_resource_list, &h_account_resource_list);
+ cls.register_cxx_method(method::account_resource_add, cls_account_resource_add, &h_account_resource_add);
+ cls.register_cxx_method(method::account_resource_get, cls_account_resource_get, &h_account_resource_get);
+ cls.register_cxx_method(method::account_resource_rm, cls_account_resource_rm, &h_account_resource_rm);
+ cls.register_cxx_method(method::account_resource_list, cls_account_resource_list, &h_account_resource_list);
}
using librados::IoCtx;
using librados::ObjectOperationCompletion;
using librados::ObjectReadOperation;
+using namespace cls::user;
void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_bucket_entry>& entries, bool add)
{
call.add = add;
call.time = real_clock::now();
encode(call, in);
- op.exec("user", "set_buckets_info", in);
+ op.exec(method::set_buckets_info, in);
}
void cls_user_complete_stats_sync(librados::ObjectWriteOperation& op)
cls_user_complete_stats_sync_op call;
call.time = real_clock::now();
encode(call, in);
- op.exec("user", "complete_stats_sync", in);
+ op.exec(method::complete_stats_sync, in);
}
void cls_user_remove_bucket(librados::ObjectWriteOperation& op, const cls_user_bucket& bucket)
cls_user_remove_bucket_op call;
call.bucket = bucket;
encode(call, in);
- op.exec("user", "remove_bucket", in);
+ op.exec(method::remove_bucket, in);
}
class ClsUserListCtx : public ObjectOperationCompletion {
encode(call, inbl);
- op.exec("user", "list_buckets", inbl, new ClsUserListCtx(&entries, out_marker, truncated, pret));
+ op.exec(method::list_buckets, inbl, new ClsUserListCtx(&entries, out_marker, truncated, pret));
}
class ClsUserGetHeaderCtx : public ObjectOperationCompletion {
encode(call, inbl);
- op.exec("user", "get_header", inbl, new ClsUserGetHeaderCtx(header, NULL, pret));
+ op.exec(method::get_header, inbl, new ClsUserGetHeaderCtx(header, NULL, pret));
}
void cls_user_reset_stats(librados::ObjectWriteOperation &op)
cls_user_reset_stats_op call;
call.time = real_clock::now();
encode(call, inbl);
- op.exec("user", "reset_user_stats", inbl);
+ op.exec(method::reset_user_stats, inbl);
}
int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx)
cls_user_get_header_op call;
encode(call, in);
ObjectReadOperation op;
- op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx, NULL)); /* no need to pass pret, as we'll call ctx->handle_response() with correct error */
+ op.exec(method::get_header, in, new ClsUserGetHeaderCtx(NULL, ctx, NULL)); /* no need to pass pret, as we'll call ctx->handle_response() with correct error */
auto c = librados::Rados::aio_create_completion(nullptr, nullptr);
int r = io_ctx.aio_operate(oid, c, &op, NULL);
c->release();
bufferlist inbl;
encode(call, inbl);
- op.exec("user", "account_resource_add", inbl);
+ op.exec(method::account_resource_add, inbl);
}
class ResourceGetCB : public librados::ObjectOperationCompletion {
bufferlist inbl;
encode(call, inbl);
- op.exec("user", "account_resource_get", inbl,
+ op.exec(method::account_resource_get, inbl,
new ResourceGetCB(&entry, pret));
}
bufferlist inbl;
encode(call, inbl);
- op.exec("user", "account_resource_rm", inbl);
+ op.exec(method::account_resource_rm, inbl);
}
class ResourceListCB : public librados::ObjectOperationCompletion {
bufferlist inbl;
encode(call, inbl);
- op.exec("user", "account_resource_list", inbl,
+ op.exec(method::account_resource_list, inbl,
new ResourceListCB(&entries, truncated, next_marker, pret));
}
#define CEPH_CLS_USER_OPS_H
#include "cls_user_types.h"
+#include "include/rados/cls_traits.h"
struct cls_user_set_buckets_op {
std::list<cls_user_bucket_entry> entries;
};
WRITE_CLASS_ENCODER(cls_user_account_resource_list_ret)
+namespace cls::user {
+struct ClassId {
+ static constexpr auto name = "user";
+};
+namespace method {
+constexpr auto set_buckets_info = ClsMethod<RdWrTag, ClassId>("set_buckets_info");
+constexpr auto complete_stats_sync = ClsMethod<RdWrTag, ClassId>("complete_stats_sync");
+constexpr auto remove_bucket = ClsMethod<RdWrTag, ClassId>("remove_bucket");
+constexpr auto list_buckets = ClsMethod<RdTag, ClassId>("list_buckets");
+constexpr auto get_header = ClsMethod<RdTag, ClassId>("get_header");
+constexpr auto reset_user_stats = ClsMethod<RdWrTag, ClassId>("reset_user_stats");
+constexpr auto reset_user_stats2 = ClsMethod<RdWrTag, ClassId>("reset_user_stats2");
+constexpr auto account_resource_add = ClsMethod<RdWrTag, ClassId>("account_resource_add");
+constexpr auto account_resource_get = ClsMethod<RdTag, ClassId>("account_resource_get");
+constexpr auto account_resource_rm = ClsMethod<RdWrTag, ClassId>("account_resource_rm");
+constexpr auto account_resource_list = ClsMethod<RdTag, ClassId>("account_resource_list");
+}
+}
+
#endif
cls_method_handle_t h_version_read;
cls_method_handle_t h_version_check_conds;
- cls_register("version", &h_class);
-
- /* version */
- cls_register_cxx_method(h_class, "set", CLS_METHOD_RD | CLS_METHOD_WR, cls_version_set, &h_version_set);
- cls_register_cxx_method(h_class, "inc", CLS_METHOD_RD | CLS_METHOD_WR, cls_version_inc, &h_version_inc);
- cls_register_cxx_method(h_class, "inc_conds", CLS_METHOD_RD | CLS_METHOD_WR, cls_version_inc, &h_version_inc_conds);
- cls_register_cxx_method(h_class, "read", CLS_METHOD_RD, cls_version_read, &h_version_read);
- cls_register_cxx_method(h_class, "check_conds", CLS_METHOD_RD, cls_version_check, &h_version_check_conds);
+ using namespace cls::version;
+ cls_register(ClassId::name, &h_class);
+
+ ClassRegistrar<ClassId> cls(h_class);
+
+ cls.register_cxx_method(method::set, cls_version_set, &h_version_set);
+ cls.register_cxx_method(method::inc, cls_version_inc, &h_version_inc);
+ cls.register_cxx_method(method::inc_conds, cls_version_inc, &h_version_inc_conds);
+ cls.register_cxx_method(method::read, cls_version_read, &h_version_read);
+ cls.register_cxx_method(method::check_conds, cls_version_check, &h_version_check_conds);
return;
}
using namespace librados;
-
+using namespace cls::version;
void cls_version_set(librados::ObjectWriteOperation& op, obj_version& objv)
{
cls_version_set_op call;
call.objv = objv;
encode(call, in);
- op.exec("version", "set", in);
+ op.exec(method::set, in);
}
void cls_version_inc(librados::ObjectWriteOperation& op)
bufferlist in;
cls_version_inc_op call;
encode(call, in);
- op.exec("version", "inc", in);
+ op.exec(method::inc, in);
}
void cls_version_inc(librados::ObjectWriteOperation& op, obj_version& objv, VersionCond cond)
call.conds.push_back(c);
encode(call, in);
- op.exec("version", "inc_conds", in);
+ op.exec(method::inc_conds, in);
}
+// This function is deprecated, but calls other deprecated functions.
void cls_version_check(librados::ObjectOperation& op, obj_version& objv, VersionCond cond)
{
bufferlist in;
call.conds.push_back(c);
encode(call, in);
- op.exec("version", "check_conds", in);
+ op.exec(method::check_conds, in);
}
class VersionReadCtx : public ObjectOperationCompletion {
void cls_version_read(librados::ObjectReadOperation& op, obj_version *objv)
{
bufferlist inbl;
- op.exec("version", "read", inbl, new VersionReadCtx(objv));
+ op.exec(method::read, inbl, new VersionReadCtx(objv));
}
int cls_version_read(librados::IoCtx& io_ctx, std::string& oid, obj_version *ver)
{
bufferlist in, out;
- int r = io_ctx.exec(oid, "version", "read", in, out);
+ int r = io_ctx.exec(oid, method::read, in, out);
if (r < 0)
return r;
int cls_version_read(librados::IoCtx& io_ctx, std::string& oid, obj_version *ver);
#endif
+[[deprecated("in favor of read/write variants")]]
void cls_version_check(librados::ObjectOperation& op, obj_version& ver, VersionCond cond);
+template <typename ObjectOperation>
+void cls_version_check(ObjectOperation& op, obj_version& objv, VersionCond cond)
+{
+ bufferlist in;
+ cls_version_check_op call;
+ call.objv = objv;
+
+ obj_version_cond c;
+ c.cond = cond;
+ c.ver = objv;
+
+ call.conds.push_back(c);
+
+ encode(call, in);
+ op.exec(cls::version::method::check_conds, in);
+}
+
#endif
#include "cls_version_types.h"
#include "common/ceph_json.h"
+#include "include/rados/cls_traits.h"
struct cls_version_set_op {
obj_version objv;
};
WRITE_CLASS_ENCODER(cls_version_read_ret)
+namespace cls::version {
+struct ClassId {
+ static constexpr auto name = "version";
+};
+
+namespace method {
+constexpr auto set = ClsMethod<RdWrTag, ClassId>("set");
+constexpr auto inc = ClsMethod<RdWrTag, ClassId>("inc");
+constexpr auto inc_conds = ClsMethod<RdWrTag, ClassId>("inc_conds");
+constexpr auto read = ClsMethod<RdTag, ClassId>("read");
+constexpr auto check_conds = ClsMethod<RdTag, ClassId>("check_conds");
+}
+}
#endif
#include "common/Formatter.h"
#include "include/encoding.h"
#include "include/types.h"
+#include "include/rados/cls_traits.h"
class JSONObj;
};
WRITE_CLASS_ENCODER(obj_version_cond)
-
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmismatched-new-delete"
template<std::default_initializable Rep, typename Req,
- std::invocable<Rep&&> F,
- std::default_initializable Ret = std::invoke_result_t<F&&, Rep&&>,
- boost::asio::completion_token_for<
- detail::return_sig_t<Ret>> CompletionToken>
+ std::invocable<Rep&&> F,
+ std::default_initializable Ret = std::invoke_result_t<F&&, Rep&&>,
+ boost::asio::completion_token_for<
+ detail::return_sig_t<Ret>> CompletionToken,
+ typename Tag, typename ClassID>
auto exec(
RADOS& r,
Object oid,
IOContext ioc,
- std::string cls,
- std::string method,
+ const ClsMethod<Tag, ClassID>& method,
const Req& req,
F&& f,
CompletionToken&& token)
}
return asio::async_initiate<CompletionToken, detail::return_sig_t<Ret>>
(asio::experimental::co_composed<detail::return_sig_t<Ret>>
- ([](auto state, RADOS& r, Object oid, IOContext ioc, std::string cls,
- std::string method, buffer::list in, F&& f) -> void {
+ ([](auto state, RADOS& r, Object oid, IOContext ioc,
+ const ClsMethod<Tag, ClassID>& method, buffer::list in, F&& f) -> void {
try {
- ReadOp op;
- buffer::list out;
- error_code ec;
- op.exec(cls, method, std::move(in), &out, &ec);
- co_await r.execute(std::move(oid), std::move(ioc), std::move(op),
- nullptr, asio::deferred);
- if (ec) {
- co_return detail::maybecat(ec, Ret{});
- }
- Rep rep;
- decode(rep, out);
- co_return detail::maybecat(error_code{},
- std::invoke(std::forward<F>(f),
- std::move(rep)));
+ ReadOp op;
+ buffer::list out;
+ error_code ec;
+ op.exec(method, std::move(in), &out, &ec);
+ co_await r.execute(std::move(oid), std::move(ioc), std::move(op),
+ nullptr, asio::deferred);
+ if (ec) {
+ co_return detail::maybecat(ec, Ret{});
+ }
+ Rep rep;
+ decode(rep, out);
+ co_return detail::maybecat(error_code{},
+ std::invoke(std::forward<F>(f),
+ std::move(rep)));
} catch (const system_error& e) {
- co_return detail::maybecat(e.code(), Ret{});
+ co_return detail::maybecat(e.code(), Ret{});
}
}, r.get_executor()),
- token, std::ref(r), std::move(oid), std::move(ioc), std::move(cls),
- std::move(method), std::move(in), std::forward<F>(f));
+ token, std::ref(r), std::move(oid), std::move(ioc),
+ method, std::move(in), std::forward<F>(f));
}
+
#pragma GCC diagnostic pop
} // namespace neorados::cls
namespace async = ceph::async;
namespace buffer = ceph::buffer;
-namespace fifo = rados::cls::fifo;
+namespace fifo = ::rados::cls::fifo;
using neorados::RADOS;
using neorados::Object;
gm.version = objv;
return exec<fifo::op::get_meta_reply>(
rados, std::move(obj), std::move(ioc),
- fifo::op::CLASS, fifo::op::GET_META, std::move(gm),
+ fifo::method::get_meta, std::move(gm),
[](fifo::op::get_meta_reply&& ret) {
return std::make_tuple(std::move(ret.info),
ret.part_header_size,
encode(gm, in);
ReadOp op;
buffer::list out;
- op.exec(fifo::op::CLASS, fifo::op::GET_META, in, &out);
+ op.exec(fifo::method::get_meta, in, &out);
co_await r.execute(std::move(obj), std::move(ioc), std::move(op), nullptr,
asio::deferred);
fifo::op::get_meta_reply ret;
return exec<fifo::op::get_part_info_reply>(
rados, std::move(std::move(part_oid)), ioc,
- fifo::op::CLASS, fifo::op::GET_PART_INFO,
+ fifo::method::get_part_info,
fifo::op::get_part_info{},
[](fifo::op::get_part_info_reply&& ret) {
return std::move(ret.header);
encode(gpi, in);
ReadOp op;
buffer::list out;
- op.exec(fifo::op::CLASS, fifo::op::GET_PART_INFO, in, &out);
+ op.exec(fifo::method::get_part_info, in, &out);
co_await f->rados.execute(std::move(part_oid), f->ioc, std::move(op),
nullptr, asio::deferred);
ip.params = info.params;
buffer::list in;
encode(ip, in);
- op.exec(fifo::op::CLASS, fifo::op::INIT_PART, std::move(in));
+ op.exec(fifo::method::init_part, std::move(in));
auto oid = info.part_oid(part_num);
l.unlock();
return rados.execute(oid, ioc, std::move(op),
buffer::list in;
encode(um, in);
- op.exec(fifo::op::CLASS, fifo::op::UPDATE_META, std::move(in));
+ op.exec(fifo::method::update_meta, std::move(in));
return rados.execute(obj, ioc, std::move(op),
std::forward<CompletionToken>(token));
}
buffer::list in;
encode(cm, in);
- op.exec(fifo::op::CLASS, fifo::op::CREATE_META, in);
+ op.exec(fifo::method::create_meta, in);
return rados.execute(std::move(obj), std::move(ioc), std::move(op),
std::forward<CompletionToken>(token));
}
buffer::list in;
encode(pp, in);
int pushes;
- op.exec(fifo::op::CLASS, fifo::op::PUSH_PART, in,
+ op.exec(fifo::method::push_part, in,
[&pushes](sys::error_code, int r, const buffer::list &) {
pushes = r;
});
buffer::list in;
encode(lp, in);
buffer::list bl;
- op.exec(fifo::op::CLASS, fifo::op::LIST_PART, in, &bl, nullptr);
+ op.exec(fifo::method::list_part, in, &bl, nullptr);
co_await f->rados.execute(oid, f->ioc, std::move(op), nullptr,
asio::deferred);
bool more, full_part;
buffer::list in;
encode(tp, in);
- op.exec(fifo::op::CLASS, fifo::op::TRIM_PART, in);
+ op.exec(fifo::method::trim_part, in);
co_await f->rados.execute(std::move(oid), f->ioc, std::move(op),
asio::deferred);
co_return sys::error_code{};
namespace neorados::cls::log {
using ::cls::log::entry;
using ::cls::log::header;
+using namespace ::cls::log;
static constexpr auto max_list_entries = 1000u;
/// \brief Push entries to the log
call.entries = std::move(entries);
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("log", "add", in);
+ op.exec(method::add, in);
}};
}
call.entries.push_back(std::move(e));
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("log", "add", in);
+ op.exec(method::add, in);
}};
}
std::move(name), std::move(bl));
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("log", "add", in);
+ op.exec(method::add, in);
}};
}
encode(call, in);
return ClsReadOp{[entries, result, out_marker,
in = std::move(in)](ReadOp& op) {
- op.exec("log", "list", in,
+ op.exec(method::list, in,
[entries, result, out_marker](error_code ec, const buffer::list& bl) {
::cls::log::ops::list_ret ret;
if (!ec) {
encode(call, in);
return ClsReadOp{[header, in = std::move(in)](ReadOp& op) {
- op.exec("log", "info", in,
+ op.exec(method::info, in,
[header](error_code ec,
const buffer::list& bl) {
::cls::log::ops::info_ret ret;
call.to_time = to_time;
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("log", "trim", in);
+ op.exec(method::trim, in);
}};
}
call.to_marker = std::string{to_marker};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("log", "trim", in);
+ op.exec(method::trim, in);
}};
}
ss::increment call{std::move(key)};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::INCREMENT, in);
+ op.exec(ss::method::increment, in);
}};
}
ss::increment call{keys};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::INCREMENT, in);
+ op.exec(ss::method::increment, in);
}};
}
ss::increment call{std::move(keys)};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::INCREMENT, in);
+ op.exec(ss::method::increment, in);
}};
}
ss::increment call{begin, end};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::INCREMENT, in);
+ op.exec(ss::method::increment, in);
}};
}
ss::decrement call{std::move(key), grace};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::DECREMENT, in);
+ op.exec(ss::method::decrement, in);
}};
}
ss::decrement call{keys, grace};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::DECREMENT, in);
+ op.exec(ss::method::decrement, in);
}};
}
ss::decrement call{std::move(keys), grace};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::DECREMENT, in);
+ op.exec(ss::method::decrement, in);
}};
}
ss::decrement call{begin, end, grace};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::DECREMENT, in);
+ op.exec(ss::method::decrement, in);
}};
}
ss::reset call{std::move(key), val};
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec(ss::CLASS, ss::RESET, in);
+ op.exec(ss::method::reset, in);
}};
}
encode(call, in);
return ClsReadOp{[entries, new_cursor,
in = std::move(in)](ReadOp& op) {
- op.exec(ss::CLASS, ss::LIST, in,
+ op.exec(ss::method::list, in,
[entries, new_cursor](sys::error_code ec, const buffer::list& bl) {
ss::list_ret ret;
if (!ec) {
encode(call, in);
return ClsReadOp{[output, new_cursor,
in = std::move(in)](ReadOp& op) {
- op.exec(ss::CLASS, ss::LIST, in,
+ op.exec(ss::method::list, in,
[output, new_cursor](error_code ec, const buffer::list& bl) {
ss::list_ret ret;
if (!ec) {
#include "neorados/cls/common.h"
+using namespace cls::version;
namespace neorados::cls::version {
/// \brief Set the object version
///
call.objv = ver;
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("version", "set", in);
+ op.exec(method::set, in);
}};
}
cls_version_inc_op call;
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("version", "inc", in);
+ op.exec(method::inc, in);
}};
}
encode(call, in);
return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
- op.exec("version", "inc_conds", in);
+ op.exec(method::inc_conds, in);
}};
}
encode(call, in);
return ClsOp{[in = std::move(in)](Op& op) {
- op.exec("version", "check_conds", in);
+ op.exec(method::check_conds, in);
}};
}
[[nodiscard]] inline auto read(obj_version* const objv)
{
using boost::system::error_code;
- return ClsReadOp{[objv](Op& op) {
+ return ClsReadOp{[objv](ReadOp& op) {
namespace sys = boost::system;
- op.exec("version", "read", {},
+ bufferlist inbl;
+ op.exec(method::read, std::move(inbl),
[objv](error_code ec,
const buffer::list& bl) {
cls_version_read_ret ret;
using namespace std::literals;
return exec<cls_version_read_ret>(
r, std::move(o), std::move(ioc),
- "version"s, "read"s, nullptr,
+ method::read, nullptr,
[](cls_version_read_ret&& ret) {
return std::move(ret.objv);
}, std::forward<CompletionToken>(token));
cls_queue_remove_op rem_op;
rem_op.end_marker = end_marker;
encode(rem_op, in);
- wop.exec(TPC_QUEUE_CLASS, TPC_QUEUE_REMOVE_ENTRIES, in);
+ wop.exec(cls::tpc_queue::method::remove_entries, in);
};
while (truncated) {
#include <errno.h>
#include <string>
+#include "cls/hello/cls_hello_ops.h"
#include "include/rados/librados.hpp"
#include "include/encoding.h"
#include "test/librados/test_cxx.h"
#include "json_spirit/json_spirit.h"
using namespace librados;
+using namespace cls::hello;
TEST(ClsHello, SayHello) {
Rados cluster;
cluster.ioctx_create(pool_name.c_str(), ioctx);
bufferlist in, out;
- ASSERT_EQ(-ENOENT, ioctx.exec("myobject", "hello", "say_hello", in, out));
+ ASSERT_EQ(-ENOENT, ioctx.exec("myobject", method::say_hello, in, out));
ASSERT_EQ(0, ioctx.write_full("myobject", in));
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "say_hello", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::say_hello, in, out));
ASSERT_EQ(std::string("Hello, world!"), std::string(out.c_str(), out.length()));
out.clear();
in.append("Tester");
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "say_hello", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::say_hello, in, out));
ASSERT_EQ(std::string("Hello, Tester!"), std::string(out.c_str(), out.length()));
out.clear();
char buf[4096];
memset(buf, 1, sizeof(buf));
in.append(buf, sizeof(buf));
- ASSERT_EQ(-EINVAL, ioctx.exec("myobject", "hello", "say_hello", in, out));
+ ASSERT_EQ(-EINVAL, ioctx.exec("myobject", method::say_hello, in, out));
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
}
cluster.ioctx_create(pool_name.c_str(), ioctx);
bufferlist in, out;
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "record_hello", in, out));
- ASSERT_EQ(-EEXIST, ioctx.exec("myobject", "hello", "record_hello", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::record_hello, in, out));
+ ASSERT_EQ(-EEXIST, ioctx.exec("myobject", method::record_hello, in, out));
in.append("Tester");
- ASSERT_EQ(0, ioctx.exec("myobject2", "hello", "record_hello", in, out));
- ASSERT_EQ(-EEXIST, ioctx.exec("myobject2", "hello", "record_hello", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject2", method::record_hello, in, out));
+ ASSERT_EQ(-EEXIST, ioctx.exec("myobject2", method::record_hello, in, out));
ASSERT_EQ(0u, out.length());
in.clear();
out.clear();
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "replay", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::replay, in, out));
ASSERT_EQ(std::string("Hello, world!"), std::string(out.c_str(), out.length()));
out.clear();
- ASSERT_EQ(0, ioctx.exec("myobject2", "hello", "replay", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject2", method::replay, in, out));
ASSERT_EQ(std::string("Hello, Tester!"), std::string(out.c_str(), out.length()));
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
// this will return nothing -- no flag is set
bufferlist in, out;
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "write_return_data", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::write_return_data, in, out));
ASSERT_EQ(std::string(), std::string(out.c_str(), out.length()));
// this will return an error due to unexpected input.
in.append(buf, sizeof(buf));
int rval;
ObjectWriteOperation o;
- o.exec("hello", "write_return_data", in, &out, &rval);
+ o.exec(method::write_return_data, in, &out, &rval);
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &o,
librados::OPERATION_RETURNVEC));
out.clear();
int rval;
ObjectWriteOperation o;
- o.exec("hello", "write_return_data", in, &out, &rval);
+ o.exec(method::write_return_data, in, &out, &rval);
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &o,
librados::OPERATION_RETURNVEC));
out.clear();
int rval;
ObjectWriteOperation o;
- o.exec("hello", "write_return_data", in, &out, &rval);
+ o.exec(method::write_return_data, in, &out, &rval);
ASSERT_EQ(42, ioctx.operate("foo", &o,
librados::OPERATION_RETURNVEC));
ASSERT_EQ(42, rval);
out.clear();
int rval;
ObjectWriteOperation o;
- o.exec("hello", "write_too_much_return_data", in, &out, &rval);
+ o.exec(method::write_too_much_return_data, in, &out, &rval);
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate("foo", completion, &o,
librados::OPERATION_RETURNVEC));
cluster.ioctx_create(pool_name.c_str(), ioctx);
bufferlist in, out;
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "record_hello", in, out));
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "replay", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::record_hello, in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::replay, in, out));
ASSERT_EQ(std::string("Hello, world!"), std::string(out.c_str(), out.length()));
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "turn_it_to_11", in, out));
- ASSERT_EQ(0, ioctx.exec("myobject", "hello", "replay", in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::turn_it_to_11, in, out));
+ ASSERT_EQ(0, ioctx.exec("myobject", method::replay, in, out));
ASSERT_EQ(std::string("HELLO, WORLD!"), std::string(out.c_str(), out.length()));
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
bufferlist in, out;
ASSERT_EQ(0, ioctx.write_full("myobject", in));
- ASSERT_EQ(-EIO, ioctx.exec("myobject", "hello", "bad_reader", in, out));
- ASSERT_EQ(-EIO, ioctx.exec("myobject", "hello", "bad_writer", in, out));
+ ASSERT_EQ(-EIO, ioctx.exec("myobject", method::bad_reader, in, out));
+ ASSERT_EQ(-EIO, ioctx.exec("myobject", method::bad_writer, in, out));
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
}
#include "test/librados/test_cxx.h"
#include "cls/lua/cls_lua_client.h"
#include "cls/lua/cls_lua.h"
+#include "cls/lua/cls_lua_ops.h"
using namespace std;
librados::ObjectWriteOperation wop;
int rval;
- wop.exec("lua", "eval_json", inbl, &outbl, &rval);
+ wop.exec(cls::lua::method::eval_json, inbl, &outbl, &rval);
int ret = ioctx.operate(oid, &wop);
ASSERT_EQ(ret, 0);
#include "test/librados/test_cxx.h"
using namespace librados;
+using namespace rados::cls::numops;
TEST(ClsNumOps, Add) {
Rados cluster;
bufferlist in, out;
- ASSERT_EQ(-EINVAL, ioctx.exec("myobject", "numops", "add", in, out));
+ ASSERT_EQ(-EINVAL, ioctx.exec("myobject", method::add, in, out));
// add a number to a non-existing key
bufferlist in, out;
- ASSERT_EQ(-EINVAL, ioctx.exec("myobject", "numops", "mul", in, out));
+ ASSERT_EQ(-EINVAL, ioctx.exec("myobject", method::mul, in, out));
// multiply a number to a non-existing key
123));
bufferlist inbl, outbl;
- ASSERT_EQ(-EINVAL, ioctx.exec(oid, "rbd", "create", inbl, outbl));
+ ASSERT_EQ(-EINVAL, ioctx.exec(oid, cls::rbd::method::create, inbl, outbl));
ioctx.close();
}
#include "test/librados/test_cxx.h"
#include "gtest/gtest.h"
+#include "cls/sdk/cls_sdk_ops.h"
using namespace librados;
+using namespace cls::sdk;
TEST(ClsSDK, TestSDKCoverageWrite) {
Rados cluster;
bufferlist in;
librados::ObjectWriteOperation op;
- op.exec("sdk", "test_coverage_write", in);
+ op.exec(method::test_coverage_write, in);
ASSERT_EQ(0, ioctx.operate("myobject", &op));
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
bufferlist in;
librados::ObjectWriteOperation op;
- op.exec("sdk", "test_coverage_write", in);
+ op.exec(method::test_coverage_write, in);
ASSERT_EQ(0, ioctx.operate("myobject", &op));
librados::ObjectWriteOperation op2;
- op2.exec("sdk", "test_coverage_replay", in);
+ op2.exec(method::test_coverage_replay, in);
ASSERT_EQ(0, ioctx.operate("myobject", &op2));
ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));