]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cls: Refactor cls subdir and tests to use new API.
authorAlex Ainscow <aainscow@uk.ibm.com>
Mon, 24 Nov 2025 16:47:43 +0000 (16:47 +0000)
committerAlex Ainscow <aainscow@uk.ibm.com>
Thu, 4 Dec 2025 15:53:34 +0000 (15:53 +0000)
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
87 files changed:
src/cls/2pc_queue/cls_2pc_queue.cc
src/cls/2pc_queue/cls_2pc_queue_client.cc
src/cls/2pc_queue/cls_2pc_queue_client.h
src/cls/2pc_queue/cls_2pc_queue_types.h
src/cls/cas/cls_cas.cc
src/cls/cas/cls_cas_client.cc
src/cls/cas/cls_cas_client.h
src/cls/cas/cls_cas_ops.h
src/cls/cas/cls_cas_types.h [new file with mode: 0644]
src/cls/cephfs/cls_cephfs.cc
src/cls/cephfs/cls_cephfs.h
src/cls/cephfs/cls_cephfs_client.cc
src/cls/cephfs/cls_cephfs_client.h
src/cls/cephfs/cls_cephfs_types.h [new file with mode: 0644]
src/cls/cmpomap/client.cc
src/cls/cmpomap/ops.h
src/cls/cmpomap/server.cc
src/cls/fifo/cls_fifo.cc
src/cls/fifo/cls_fifo_ops.h
src/cls/hello/cls_hello.cc
src/cls/hello/cls_hello_ops.h [new file with mode: 0644]
src/cls/journal/cls_journal.cc
src/cls/journal/cls_journal_client.cc
src/cls/journal/cls_journal_client.h
src/cls/journal/cls_journal_ops.h [new file with mode: 0644]
src/cls/lock/cls_lock.cc
src/cls/lock/cls_lock_client.cc
src/cls/lock/cls_lock_ops.h
src/cls/lock/cls_lock_types.cc
src/cls/lock/cls_lock_types.h
src/cls/log/cls_log.cc
src/cls/log/cls_log_client.cc
src/cls/log/cls_log_ops.h
src/cls/lua/cls_lua.cc
src/cls/lua/cls_lua_client.cc
src/cls/lua/cls_lua_ops.h
src/cls/numops/cls_numops.cc
src/cls/numops/cls_numops_client.cc
src/cls/numops/cls_numops_client.h
src/cls/numops/cls_numops_ops.h [new file with mode: 0644]
src/cls/otp/cls_otp.cc
src/cls/otp/cls_otp_client.cc
src/cls/otp/cls_otp_ops.h
src/cls/queue/cls_queue.cc
src/cls/queue/cls_queue_client.cc
src/cls/queue/cls_queue_ops.h
src/cls/rbd/cls_rbd.cc
src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h
src/cls/rbd/cls_rbd_ops.h [new file with mode: 0644]
src/cls/rbd/cls_rbd_types.h
src/cls/refcount/cls_refcount.cc
src/cls/refcount/cls_refcount_client.cc
src/cls/refcount/cls_refcount_ops.h
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_ops.h
src/cls/rgw/cls_rgw_types.h
src/cls/rgw_gc/cls_rgw_gc.cc
src/cls/rgw_gc/cls_rgw_gc_client.cc
src/cls/rgw_gc/cls_rgw_gc_ops.h
src/cls/sdk/cls_sdk.cc
src/cls/sdk/cls_sdk_ops.h [new file with mode: 0644]
src/cls/sem_set/module.cc
src/cls/sem_set/ops.h
src/cls/timeindex/cls_timeindex.cc
src/cls/timeindex/cls_timeindex_client.cc
src/cls/timeindex/cls_timeindex_ops.h
src/cls/user/cls_user.cc
src/cls/user/cls_user_client.cc
src/cls/user/cls_user_ops.h
src/cls/version/cls_version.cc
src/cls/version/cls_version_client.cc
src/cls/version/cls_version_client.h
src/cls/version/cls_version_ops.h
src/cls/version/cls_version_types.h
src/neorados/cls/common.h
src/neorados/cls/fifo/detail/fifo.h
src/neorados/cls/log.h
src/neorados/cls/sem_set.h
src/neorados/cls/version.h
src/test/cls_2pc_queue/test_cls_2pc_queue.cc
src/test/cls_hello/test_cls_hello.cc
src/test/cls_lua/test_cls_lua.cc
src/test/cls_numops/test_cls_numops.cc
src/test/cls_rbd/test_cls_rbd.cc
src/test/cls_sdk/test_cls_sdk.cc

index ddc7891bcabd350b723d8cdd3fd00ce8f796284a..53be1bfe36e38d80054dbb43e204bdab260ccf30 100644 (file)
@@ -663,18 +663,21 @@ CLS_INIT(2pc_queue)
   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;
 }
index 51f11e7c718438c21763cb48bdc2d18d19b4923e..9d666c22a063d79004b80f9084fd8d02fe6e0dc2 100644 (file)
@@ -8,13 +8,14 @@
 #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) {
@@ -49,7 +50,7 @@ int cls_2pc_queue_get_topic_stats_result(const bufferlist& bl, uint32_t& committ
 #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;
   }
@@ -62,13 +63,13 @@ int cls_2pc_queue_get_capacity(IoCtx& io_ctx, const std::string& queue_name, uin
 // 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;
   }
@@ -81,7 +82,7 @@ int cls_2pc_queue_get_topic_stats(IoCtx& io_ctx, const std::string& queue_name,
 // 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);
 }
 
 
@@ -108,7 +109,7 @@ int cls_2pc_queue_reserve(IoCtx& io_ctx, const std::string& queue_name,
   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) {
@@ -125,7 +126,7 @@ void cls_2pc_queue_reserve(ObjectWriteOperation& op, uint64_t res_size,
   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, 
@@ -135,7 +136,7 @@ void cls_2pc_queue_commit(ObjectWriteOperation& op, std::vector<bufferlist> bl_d
   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) {
@@ -143,7 +144,7 @@ void cls_2pc_queue_abort(ObjectWriteOperation& op, cls_2pc_reservation::id_t res
   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,
@@ -176,7 +177,7 @@ int cls_2pc_queue_list_entries(IoCtx& io_ctx,
   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;
   }
@@ -191,7 +192,17 @@ void cls_2pc_queue_list_entries(ObjectReadOperation& op, const std::string& mark
   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) {
@@ -212,7 +223,7 @@ int cls_2pc_queue_list_reservations_result(const bufferlist& bl, cls_2pc_reserva
 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;
   }
@@ -223,7 +234,7 @@ int cls_2pc_queue_list_reservations(IoCtx& io_ctx, const std::string& queue_name
 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) {
@@ -232,7 +243,7 @@ void cls_2pc_queue_remove_entries(ObjectWriteOperation& op, const std::string& e
   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) {
@@ -240,6 +251,6 @@ void cls_2pc_queue_expire_reservations(librados::ObjectWriteOperation& op, ceph:
   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);
 }
 
index 0ba3f1e5de9fd0ee4ac0e296d9829fda0a8fe77e..a22c7a16ee0561a63eeb8528df0d7614fcee6815 100644 (file)
@@ -72,6 +72,7 @@ void cls_2pc_queue_abort(librados::ObjectWriteOperation& op,
 // 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);
index af4ef0ef17a4e6ab652f63e039668a86d006d92f..af90050b4d8c4d4e29cdaeb3259d9dd02195d00a 100644 (file)
@@ -7,6 +7,8 @@
 #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>
 
@@ -116,3 +118,22 @@ struct cls_2pc_urgent_data
   }
 };
 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);
+}
+}
+
index 26b96f0adb0af5373e1332734e0cdf87b225a1fa..5ea991943976c2a0a0b1c44ae825d0dcecdb96d1 100644 (file)
@@ -10,6 +10,7 @@
 #include "include/compat.h"
 #include "osd/osd_types.h"
 
+
 using ceph::bufferlist;
 using ceph::decode;
 
@@ -216,23 +217,15 @@ CLS_INIT(cas)
   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;
 }
index 8474b676ce136c3d3e90dd0f5bd95f3aa7b98543..fdd90e33383af6be318a6e0d6541cadded4493cd 100644 (file)
@@ -14,6 +14,8 @@ using ceph::bufferlist;
 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,
@@ -28,7 +30,7 @@ void cls_cas_chunk_create_or_get_ref(
   }
   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(
@@ -39,7 +41,7 @@ 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(
@@ -50,7 +52,7 @@ 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(
@@ -60,6 +62,6 @@ 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;
 }
index 8f44e49e8220968c35610f5191e87a4be80d939b..a0dacf3740b26f46a7f443685062de3b89e07898 100644 (file)
@@ -7,6 +7,7 @@
 #include "include/types.h"
 #include "include/rados/librados_fwd.hpp"
 #include "common/hobject.h"
+#include "cls_cas_types.h"
 
 //
 // basic methods
index 3a0dff8bbebbf9768c563e5c7e77c11b316a1982..29efcb27704d687a6d9cb48599ff9a37a7b59dc7 100644 (file)
@@ -7,6 +7,7 @@
 #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 {
diff --git a/src/cls/cas/cls_cas_types.h b/src/cls/cas/cls_cas_types.h
new file mode 100644 (file)
index 0000000..68cfbc1
--- /dev/null
@@ -0,0 +1,14 @@
+#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
index 581ea2d3dcfb24049499a7fad17785b575fb0d4c..6a4c0748246227e2fe75c18927a22af95dff0f09 100644 (file)
@@ -204,10 +204,13 @@ CLS_INIT(cephfs)
   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);
index b5930465ba21fe4eb1a6fdda3d63709224130758..05a7513ac2912734702018593a571e169ddef963 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include "include/encoding.h"
+#include "cls_cephfs_types.h"
 
 /**
  * Value class for the xattr we'll use to accumulate
index 3546de9222a86a028d1f04941c94044cad22ded3..db58b62ce3545442ab73e92be65e7cbe8613c1ee 100644 (file)
@@ -23,6 +23,8 @@
 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"
@@ -51,7 +53,7 @@ int ClsCephFSClient::accumulate_inode_metadata(
   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;
index df523529c40c36ac55b6c86c8d03baef3f8b7fdc..4cd8c6ddbfdf0d5d3ad97d2a9713ab87e4d03cf8 100644 (file)
@@ -4,6 +4,7 @@
 #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;
diff --git a/src/cls/cephfs/cls_cephfs_types.h b/src/cls/cephfs/cls_cephfs_types.h
new file mode 100644 (file)
index 0000000..44298a1
--- /dev/null
@@ -0,0 +1,10 @@
+#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
index 54ba17ca6a18aeacff963822c8c498aa18724169..946f33518d11dccd4a0e75b8f424cc89b09908ba 100644 (file)
@@ -33,7 +33,7 @@ int cmp_vals(librados::ObjectReadOperation& op,
 
   bufferlist in;
   encode(call, in);
-  op.exec("cmpomap", "cmp_vals", in);
+  op.exec(method::cmp_vals, in);
   return 0;
 }
 
@@ -52,7 +52,7 @@ int cmp_set_vals(librados::ObjectWriteOperation& op,
 
   bufferlist in;
   encode(call, in);
-  op.exec("cmpomap", "cmp_set_vals", in);
+  op.exec(method::cmp_set_vals, in);
   return 0;
 }
 
@@ -69,7 +69,7 @@ int cmp_rm_keys(librados::ObjectWriteOperation& op,
 
   bufferlist in;
   encode(call, in);
-  op.exec("cmpomap", "cmp_rm_keys", in);
+  op.exec(method::cmp_rm_keys, in);
   return 0;
 }
 
index 58c2a460f4ec16f1a0077c61a7fd8d5c2648306d..6220fae87f6285389c7d1cd671df22a1ab5c1a41 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "types.h"
 #include "include/encoding.h"
+#include "include/rados/cls_traits.h"
 
 namespace cls::cmpomap {
 
@@ -97,4 +98,13 @@ inline void decode(cmp_rm_keys_op& o, ceph::bufferlist::const_iterator& bl)
   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
index cc2742ecba3275451c33b9c19e12da5a1d3cce61..916b9ea59e3074c015c474dfa4e0df00330e7e3c 100644 (file)
@@ -291,12 +291,11 @@ CLS_INIT(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);
 }
index 232436d3501a0054c6356858f4515c2882505e80..9438dc972ab4d257f2ee4ad66eef2ed17e6cb2fa 100644 (file)
@@ -925,38 +925,18 @@ CLS_INIT(fifo)
   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;
index bc8e9e59de25efb73a096abd9ea23fe7a2fcc6a1..0e1bac824aa3102cc0ca562b0c90c459513dcb6e 100644 (file)
 #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;
@@ -362,4 +364,19 @@ inline constexpr auto PUSH_PART = "push_part";
 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
index ac2bdf13a4ab0521e128ff69717d3ada7a4521d8..2f4b408f299614838d1618d596a3d56f0ea21143 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "objclass/objclass.h"
 #include "osd/osd_types.h"
+#include "cls_hello_ops.h"
 
 using std::string;
 using std::ostringstream;
@@ -326,7 +327,9 @@ CLS_INIT(hello)
   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:
   //
@@ -337,36 +340,20 @@ CLS_INIT(hello)
   // 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);
diff --git a/src/cls/hello/cls_hello_ops.h b/src/cls/hello/cls_hello_ops.h
new file mode 100644 (file)
index 0000000..c66448d
--- /dev/null
@@ -0,0 +1,20 @@
+#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");
+}
+}
index e3bce1b1333fb5975ad43ba4b130b69babbd80b8..b6ba6471f8ede3ab5bb7b9502d8d7a055a45f621 100644 (file)
@@ -8,6 +8,7 @@
 #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>
@@ -1235,82 +1236,29 @@ CLS_INIT(journal)
   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);
 }
index b34bd5ec638da31a097d9bfc0dc65291ca503aa2..b1c64a41f6b77ec5231527a94edba906de0be7d2 100644 (file)
@@ -7,6 +7,7 @@
 #include "include/Context.h"
 #include "common/Cond.h"
 #include <errno.h>
+using namespace cls::journal;
 
 namespace cls {
 namespace journal {
@@ -16,6 +17,7 @@ using ceph::decode;
 
 namespace {
 
+
 struct C_AioExec : public Context {
   librados::IoCtx &ioctx;
   std::string oid;
@@ -46,7 +48,7 @@ struct C_ClientList : public C_AioExec {
     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 =
@@ -106,9 +108,9 @@ struct C_ImmutableMetadata : public C_AioExec {
   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);
@@ -147,8 +149,8 @@ struct C_MutableMetadata : public C_AioExec {
   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);
@@ -184,7 +186,7 @@ void create(librados::ObjectWriteOperation *op,
   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,
@@ -221,13 +223,13 @@ void get_mutable_metadata(librados::IoCtx &ioctx, const std::string &oid,
 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,
@@ -253,7 +255,7 @@ void get_client_start(librados::ObjectReadOperation *op,
                       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,
@@ -278,7 +280,7 @@ void client_register(librados::ObjectWriteOperation *op,
   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,
@@ -293,7 +295,7 @@ void client_update_data(librados::ObjectWriteOperation *op,
   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,
@@ -309,7 +311,7 @@ void client_update_state(librados::ObjectWriteOperation *op,
   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,
@@ -324,7 +326,7 @@ void client_unregister(librados::ObjectWriteOperation *op,
 
   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,
@@ -332,7 +334,7 @@ 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,
@@ -369,7 +371,7 @@ int get_next_tag_tid(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,
@@ -405,7 +407,7 @@ void get_tag_start(librados::ObjectReadOperation *op,
                    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) {
@@ -431,7 +433,7 @@ void tag_create(librados::ObjectWriteOperation *op, uint64_t tag_tid,
   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,
@@ -474,7 +476,7 @@ void tag_list_start(librados::ObjectReadOperation *op,
   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,
@@ -490,7 +492,7 @@ 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,
@@ -499,7 +501,7 @@ 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
index a625e65c1b9e8ffceb9fe177adf991ea0d762d3e..8b608702b2d02b43d9a84633afe740e8f32fce9d 100644 (file)
@@ -6,6 +6,7 @@
 
 #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>
 
diff --git a/src/cls/journal/cls_journal_ops.h b/src/cls/journal/cls_journal_ops.h
new file mode 100644 (file)
index 0000000..52a7f1b
--- /dev/null
@@ -0,0 +1,32 @@
+#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
index b497631df211a60ad6849e4a13b8cadfff7d99cb..6423d0422b3962c98c9901d6cb92aeae7e02b400 100644 (file)
@@ -621,28 +621,16 @@ CLS_INIT(lock)
   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;
 }
index 6baa39728e1b3594b9168885fd3e0882717f55df..caec6ca181fa62ce43fff33ac1c4e7a805a92f06 100644 (file)
@@ -46,7 +46,7 @@ namespace rados {
         op.flags = flags;
         bufferlist in;
         encode(op, in);
-        rados_op->exec("lock", "lock", in);
+        rados_op->exec(method::lock, in);
       }
 
       int lock(IoCtx *ioctx,
@@ -70,7 +70,7 @@ namespace rados {
         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,
@@ -100,7 +100,7 @@ namespace rados {
         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,
@@ -115,7 +115,7 @@ namespace rados {
       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;
 
@@ -139,7 +139,7 @@ namespace rados {
         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,
@@ -193,7 +193,7 @@ namespace rados {
         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,
@@ -209,7 +209,7 @@ namespace rados {
         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)
index b7694ac665163fe1def09b2145b5f0aa3a6098a1..72f453fa1f3ad75f089743624ee4026e13ce6fb7 100644 (file)
@@ -7,6 +7,7 @@
 #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
 {
@@ -242,4 +243,20 @@ struct cls_lock_set_cookie_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
index ab198ed4691d83805c9e7dc88f91fa0bf9bd3869..9e2306fdc51aafb39973ab1f7af55b8ff253f992 100644 (file)
@@ -14,8 +14,7 @@
  */
 
 #include "common/Formatter.h"
-
-#include "cls/lock/cls_lock_types.h"
+#include "cls_lock_types.h"
 
 using namespace rados::cls::lock;
 
index 59e62c0f747aab01e323c2b499f7e22aecd642ca..a2c94afb4f4439bb8fefdc16effa8451ea44d7dd 100644 (file)
@@ -8,6 +8,7 @@
 #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 */
index 3594c62bc3e18f0a73511df77766e131c2ca6b62..a940c15144a44a6dd35f8437a67b91e7b224b862 100644 (file)
@@ -313,13 +313,14 @@ CLS_INIT(log)
   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;
 }
index 0a3d51f870fefa26a8cbe37231a0783f84c5a4d4..e6f7f8f40c2cc82a75b6f97d0390584b0094ba3d 100644 (file)
@@ -14,7 +14,7 @@ using std::string;
 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)
@@ -23,7 +23,7 @@ void cls_log_add(librados::ObjectWriteOperation& op, vector<cls::log::entry>& en
   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)
@@ -32,7 +32,7 @@ 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,
@@ -63,7 +63,7 @@ void cls_log_trim(librados::ObjectWriteOperation& op, ceph::real_time from_time,
   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,
@@ -129,7 +129,7 @@ void cls_log_list(librados::ObjectReadOperation& op, ceph::real_time from,
 
   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 {
@@ -158,5 +158,5 @@ void cls_log_info(librados::ObjectReadOperation& op, cls::log::header *header)
 
   encode(call, inbl);
 
-  op.exec("log", "info", inbl, new LogInfoCtx(header));
+  op.exec(method::info, inbl, new LogInfoCtx(header));
 }
index 58697ecaa2d228d7495281644c0f1be579e617e7..7cbbc3bf5df49c2e2a40aef7265c8a884f306e81 100644 (file)
@@ -11,6 +11,7 @@
 #include "common/ceph_time.h"
 
 #include "cls_log_types.h"
+#include "include/rados/cls_traits.h"
 
 namespace cls::log::ops {
 struct add_op {
@@ -246,4 +247,16 @@ struct info_ret {
 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
index dea5fe1a8248c33077d9084eeaae7e49f2f32111..d3790fd9a649ae9997d1e5b9c84d584fe208d719 100644 (file)
@@ -1044,11 +1044,10 @@ CLS_INIT(lua)
   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);
 }
index b19cfa9c7b331cc8e661bb3df5082dbc331e9026..e89b6fa43fd936e0836ec56ae4b56cabcef4e1c1 100644 (file)
@@ -10,6 +10,8 @@ using std::vector;
 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
@@ -31,7 +33,7 @@ namespace cls_lua_client {
 
     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);
   }
 }
index c4afbd8a2dddfcbfb878473765553f4b20737ec1..c7f77e5cb85ec700d4ee12fc3d663136ac9de79c 100644 (file)
@@ -4,6 +4,7 @@
 #include <string>
 
 #include "include/encoding.h"
+#include "include/rados/cls_traits.h"
 
 struct cls_lua_eval_op {
   std::string script;
@@ -28,4 +29,14 @@ struct cls_lua_eval_op {
 };
 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
index 6b89e98c28e83dee7242ffbce979201702425770..daace4efb9905dd66022a072e411d89a54d3e21d 100644 (file)
@@ -30,6 +30,8 @@
 #include <cstdio>
 #include <include/compat.h>
 
+#include "cls_numops_ops.h"
+
 #define DECIMAL_PRECISION 10
 
 using ceph::bufferlist;
@@ -158,13 +160,10 @@ CLS_INIT(numops)
   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);
 }
index a111a9b655bf62902cd70ab231a8a92ca87fd79b..40468e6a83272211acfbdb6343efd8b6c3f53dc8 100644 (file)
@@ -19,6 +19,8 @@
 #include <errno.h>
 #include <sstream>
 
+using namespace rados::cls::numops;
+
 namespace rados {
   namespace cls {
     namespace numops {
@@ -37,7 +39,7 @@ namespace rados {
         encode(stream.str(), in);
 
         librados::ObjectWriteOperation op;
-        op.exec("numops", "add", in);
+        op.exec(method::add, in);
 
         return ioctx->operate(oid, &op);
       }
@@ -64,7 +66,7 @@ namespace rados {
         encode(stream.str(), in);
 
         librados::ObjectWriteOperation op;
-        op.exec("numops", "mul", in);
+        op.exec(method::mul, in);
 
         return ioctx->operate(oid, &op);
       }
index 0b0ccbe5bf6d289b7b796a0dfd7ffb8eb87afdbd..5916897fb4abd56d04ff01a7db11e92868195555 100644 (file)
@@ -16,6 +16,7 @@
 #define CEPH_LIBRBD_CLS_NUMOPS_CLIENT_H
 
 #include "include/rados/librados_fwd.hpp"
+#include "cls_numops_ops.h"
 #include <string>
 
 namespace rados {
diff --git a/src/cls/numops/cls_numops_ops.h b/src/cls/numops/cls_numops_ops.h
new file mode 100644 (file)
index 0000000..1499c5c
--- /dev/null
@@ -0,0 +1,13 @@
+#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
index 4dfca82556bf28269ca86c23265c96443160a313..716a1054bfd0fe74a8b11e1341a3fd891cb4dfef 100644 (file)
@@ -554,25 +554,16 @@ CLS_INIT(otp)
   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;
 }
index b99af2588e205cfe0baf1ffa52d08672c13f8456..e5b185aef60635658d903bc92133acac274759e8 100644 (file)
@@ -37,7 +37,7 @@ namespace rados {
         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,
@@ -46,7 +46,7 @@ namespace rados {
         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,
@@ -55,7 +55,7 @@ namespace rados {
         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,
@@ -70,7 +70,7 @@ namespace rados {
         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;
@@ -81,7 +81,7 @@ namespace rados {
         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;
         }
@@ -115,7 +115,7 @@ namespace rados {
         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;
@@ -168,7 +168,7 @@ namespace rados {
         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;
index 5acb3c437768104528bd7124f4f1043873754fcb..e4363d46d5c682d93b33eb847148d7a282eea105 100644 (file)
@@ -7,6 +7,7 @@
 #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
 {
@@ -166,4 +167,18 @@ struct cls_otp_get_current_time_reply
 };
 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
index 0d78c0bb38c8f597534154c57f570c1e5948e83f..54b198837ca79ab780092d16fc27cb7672170e09 100644 (file)
@@ -131,15 +131,15 @@ CLS_INIT(queue)
   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;
 }
 
index 157d747378d000ef24d8e3201b9ba23d9e077075..ad552a13effaab3d94f076e733d07d30a86ee4dc 100644 (file)
@@ -9,6 +9,7 @@
 
 using namespace std;
 using namespace librados;
+using namespace cls::queue;
 
 void cls_queue_init(ObjectWriteOperation& op, const string& queue_name, uint64_t size)
 {
@@ -17,13 +18,13 @@ void cls_queue_init(ObjectWriteOperation& op, const string& queue_name, uint64_t
   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;
 
@@ -46,13 +47,13 @@ void cls_queue_enqueue(ObjectWriteOperation& op, uint32_t expiration_secs, vecto
   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;
 
@@ -105,5 +106,5 @@ void cls_queue_remove_entries(ObjectWriteOperation& op, const string& end_marker
   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);
 }
index 0b0edca965faf35c76c08cbca8dbb0a840b08e55..e4417c0eba1d81663066b148f95b4b0aa64e825f 100644 (file)
@@ -5,7 +5,9 @@
 #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};
@@ -245,4 +247,18 @@ struct cls_queue_get_stats_ret {
 };
 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 */
index f327d8baac5e70d76fd1eb08787d5d139a60a933..5cabca4161f7d3a205a7e23e9f203501511120e9 100644 (file)
@@ -8390,426 +8390,169 @@ CLS_INIT(rbd)
   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);
 }
index 47d5ecf042642d7663af08fde05dfe23b0af12a7..a453a784c4d91ac2d3c1875566620f04bffe051d 100644 (file)
@@ -22,6 +22,8 @@ using ceph::bufferlist;
 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)
@@ -33,7 +35,7 @@ void create_image(librados::ObjectWriteOperation *op, uint64_t size,
   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,
@@ -51,7 +53,7 @@ void get_features_start(librados::ObjectReadOperation *op, bool read_only)
   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,
@@ -91,7 +93,7 @@ void set_features(librados::ObjectWriteOperation *op, 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,
@@ -106,7 +108,7 @@ 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,
@@ -138,7 +140,7 @@ int get_object_prefix(librados::IoCtx *ioctx, const std::string &oid,
 
 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) {
@@ -169,7 +171,7 @@ void get_size_start(librados::ObjectReadOperation *op, snapid_t snap_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,
@@ -212,13 +214,13 @@ void set_size(librados::ObjectWriteOperation *op, 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) {
@@ -253,13 +255,13 @@ void set_flags(librados::ObjectWriteOperation *op, snapid_t snap_id,
   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)
@@ -294,7 +296,7 @@ void op_features_set(librados::ObjectWriteOperation *op,
   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,
@@ -310,7 +312,7 @@ void get_parent_start(librados::ObjectReadOperation *op, snapid_t snap_id)
 {
   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,
@@ -365,7 +367,7 @@ void set_parent(librados::ObjectWriteOperation *op,
   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)
@@ -378,12 +380,12 @@ 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,
@@ -419,7 +421,7 @@ void parent_overlap_get_start(librados::ObjectReadOperation* op,
                               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,
@@ -459,7 +461,7 @@ void parent_attach(librados::ObjectWriteOperation* op,
   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,
@@ -472,7 +474,7 @@ 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) {
@@ -502,7 +504,7 @@ void add_child(librados::ObjectWriteOperation *op,
   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,
@@ -516,7 +518,7 @@ 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,
@@ -534,7 +536,7 @@ void get_children_start(librados::ObjectReadOperation *op,
   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,
@@ -567,7 +569,7 @@ void snapshot_get_start(librados::ObjectReadOperation *op, snapid_t snap_id)
 {
   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,
@@ -605,14 +607,14 @@ void snapshot_add(librados::ObjectWriteOperation *op, snapid_t snap_id,
   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,
@@ -622,7 +624,7 @@ 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,
@@ -630,13 +632,13 @@ 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,
@@ -674,7 +676,7 @@ void get_snapshot_name_start(librados::ObjectReadOperation *op,
 {
   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,
@@ -709,7 +711,7 @@ void get_snapshot_timestamp_start(librados::ObjectReadOperation *op,
 {
   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,
@@ -745,7 +747,7 @@ void old_snapshot_add(librados::ObjectWriteOperation *op,
   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,
@@ -753,7 +755,7 @@ 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,
@@ -762,12 +764,12 @@ 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,
@@ -813,7 +815,7 @@ int old_snapshot_list(librados::IoCtx *ioctx, const std::string &oid,
 
 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,
@@ -843,7 +845,7 @@ int get_all_features(librados::IoCtx *ioctx, const std::string &oid,
 
 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) {
@@ -867,7 +869,7 @@ void sparse_copyup(O* op, const E& extent_map, 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,
@@ -896,7 +898,7 @@ void get_protection_status_start(librados::ObjectReadOperation *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,
@@ -941,13 +943,13 @@ void set_protection_status(librados::ObjectWriteOperation *op,
   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)
@@ -980,12 +982,12 @@ void snapshot_set_limit(librados::ObjectWriteOperation *op, 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,
@@ -1026,7 +1028,7 @@ void set_stripe_unit_count(librados::ObjectWriteOperation *op,
   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,
@@ -1040,7 +1042,7 @@ 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,
@@ -1073,7 +1075,7 @@ int get_create_timestamp(librados::IoCtx *ioctx, const std::string &oid,
 
 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,
@@ -1107,7 +1109,7 @@ int get_access_timestamp(librados::IoCtx *ioctx, const std::string &oid,
 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)
@@ -1119,7 +1121,7 @@ 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,
@@ -1153,7 +1155,7 @@ int get_modify_timestamp(librados::IoCtx *ioctx, const std::string &oid,
 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)
@@ -1168,7 +1170,7 @@ 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) {
@@ -1199,7 +1201,7 @@ void set_id(librados::ObjectWriteOperation *op, const 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)
@@ -1217,7 +1219,7 @@ void dir_get_id_start(librados::ObjectReadOperation *op,
   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) {
@@ -1249,7 +1251,7 @@ void dir_get_name_start(librados::ObjectReadOperation *op,
                         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) {
@@ -1283,7 +1285,7 @@ void dir_list_start(librados::ObjectReadOperation *op,
   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)
@@ -1319,7 +1321,7 @@ void dir_add_image(librados::ObjectWriteOperation *op,
   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,
@@ -1345,7 +1347,7 @@ void dir_state_assert(librados::ObjectOperation *op,
 {
   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,
@@ -1362,7 +1364,7 @@ void dir_state_set(librados::ObjectWriteOperation *op,
 {
   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,
@@ -1381,7 +1383,7 @@ void dir_remove_image(librados::ObjectWriteOperation *op,
   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,
@@ -1392,12 +1394,12 @@ 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,
@@ -1434,7 +1436,7 @@ void object_map_save(librados::ObjectWriteOperation *rados_op,
 
   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,
@@ -1443,7 +1445,7 @@ 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,
@@ -1456,13 +1458,13 @@ 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,
@@ -1473,7 +1475,7 @@ 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,
@@ -1482,7 +1484,7 @@ 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,
@@ -1500,7 +1502,7 @@ void metadata_remove(librados::ObjectWriteOperation *op,
   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,
@@ -1535,7 +1537,7 @@ void metadata_list_start(librados::ObjectReadOperation *op,
   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,
@@ -1555,7 +1557,7 @@ void metadata_get_start(librados::ObjectReadOperation* op,
   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,
@@ -1595,7 +1597,7 @@ void child_attach(librados::ObjectWriteOperation *op, snapid_t snap_id,
   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,
@@ -1618,7 +1620,7 @@ void child_detach(librados::ObjectWriteOperation *op, snapid_t snap_id,
   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,
@@ -1640,7 +1642,7 @@ void children_list_start(librados::ObjectReadOperation *op,
 {
   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,
@@ -1687,7 +1689,7 @@ void migration_set(librados::ObjectWriteOperation *op,
                    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,
@@ -1704,12 +1706,12 @@ void migration_set_state(librados::ObjectWriteOperation *op,
   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,
@@ -1749,7 +1751,7 @@ int migration_remove(librados::IoCtx *ioctx, const std::string &oid) {
 
 void migration_remove(librados::ObjectWriteOperation *op) {
   bufferlist bl;
-  op->exec("rbd", "migration_remove", bl);
+  op->exec(method::migration_remove, bl);
 }
 
 template <typename O>
@@ -1758,7 +1760,7 @@ void assert_snapc_seq(O* op, uint64_t snapc_seq,
   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,
@@ -1783,7 +1785,7 @@ int assert_snapc_seq(librados::IoCtx *ioctx, const std::string &oid,
 
 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,
@@ -1819,7 +1821,7 @@ int mirror_uuid_set(librados::IoCtx *ioctx, const std::string &uuid) {
   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;
@@ -1829,7 +1831,7 @@ int mirror_uuid_set(librados::IoCtx *ioctx, const std::string &uuid) {
 
 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,
@@ -1873,7 +1875,7 @@ int mirror_mode_set(librados::IoCtx *ioctx,
   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;
@@ -1886,7 +1888,7 @@ int mirror_remote_namespace_get(librados::IoCtx *ioctx,
   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;
@@ -1907,7 +1909,7 @@ int mirror_remote_namespace_set(librados::IoCtx *ioctx,
   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;
@@ -1917,7 +1919,7 @@ int mirror_remote_namespace_set(librados::IoCtx *ioctx,
 
 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,
@@ -1972,7 +1974,7 @@ void mirror_peer_ping(librados::ObjectWriteOperation *op,
   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,
@@ -1993,7 +1995,7 @@ void mirror_peer_add(librados::ObjectWriteOperation *op,
   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,
@@ -2002,7 +2004,7 @@ 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;
@@ -2018,7 +2020,7 @@ int mirror_peer_set_client(librados::IoCtx *ioctx,
   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;
@@ -2034,7 +2036,7 @@ int mirror_peer_set_cluster(librados::IoCtx *ioctx,
   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;
@@ -2050,7 +2052,7 @@ int mirror_peer_set_direction(
   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;
@@ -2064,7 +2066,7 @@ void mirror_image_list_start(librados::ObjectReadOperation *op,
   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,
@@ -2098,7 +2100,7 @@ void mirror_image_get_image_id_start(librados::ObjectReadOperation *op,
                                      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,
@@ -2151,7 +2153,7 @@ void mirror_image_get_start(librados::ObjectReadOperation *op,
   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,
@@ -2171,7 +2173,7 @@ void mirror_image_set(librados::ObjectWriteOperation *op,
   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,
@@ -2191,7 +2193,7 @@ void mirror_image_remove(librados::ObjectWriteOperation *op,
   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) {
@@ -2219,7 +2221,7 @@ void mirror_image_status_set(librados::ObjectWriteOperation *op,
   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,
@@ -2246,7 +2248,7 @@ void mirror_image_status_get_start(librados::ObjectReadOperation *op,
                                    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,
@@ -2286,7 +2288,7 @@ void mirror_image_status_list_start(librados::ObjectReadOperation *op,
   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,
@@ -2329,7 +2331,7 @@ void mirror_image_status_get_summary_start(
     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(
@@ -2354,7 +2356,7 @@ void mirror_image_status_remove(librados::ObjectWriteOperation *op,
                                 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) {
@@ -2365,7 +2367,7 @@ 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,
@@ -2392,7 +2394,7 @@ void mirror_image_instance_get_start(librados::ObjectReadOperation *op,
                                      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,
@@ -2431,7 +2433,7 @@ void mirror_image_instance_list_start(librados::ObjectReadOperation *op,
   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(
@@ -2448,7 +2450,7 @@ 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,
@@ -2485,7 +2487,7 @@ void mirror_instances_add(librados::ObjectWriteOperation *op,
                           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,
@@ -2499,7 +2501,7 @@ void mirror_instances_remove(librados::ObjectWriteOperation *op,
                              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,
@@ -2516,7 +2518,7 @@ void mirror_image_map_list_start(librados::ObjectReadOperation *op,
   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,
@@ -2553,7 +2555,7 @@ void mirror_image_map_update(librados::ObjectWriteOperation *op,
   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,
@@ -2561,7 +2563,7 @@ 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,
@@ -2571,7 +2573,7 @@ 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,
@@ -2591,7 +2593,7 @@ void mirror_image_snapshot_set_copy_progress(librados::ObjectWriteOperation *op,
   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,
@@ -2612,7 +2614,7 @@ int group_dir_list(librados::IoCtx *ioctx, const std::string &oid,
   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;
 
@@ -2633,7 +2635,7 @@ int group_dir_add(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2646,7 +2648,7 @@ int group_dir_rename(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2657,7 +2659,7 @@ int group_dir_remove(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2668,7 +2670,7 @@ int group_image_remove(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2682,7 +2684,7 @@ int group_image_list(librados::IoCtx *ioctx,
   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;
 
@@ -2703,7 +2705,7 @@ int group_image_set(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2714,7 +2716,7 @@ int image_group_add(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2725,14 +2727,14 @@ int image_group_remove(librados::IoCtx *ioctx, const std::string &oid,
   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,
@@ -2769,7 +2771,7 @@ int group_snap_set(librados::IoCtx *ioctx, const std::string &oid,
   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;
 }
@@ -2781,7 +2783,7 @@ int group_snap_remove(librados::IoCtx *ioctx, const std::string &oid,
   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);
 }
 
@@ -2794,7 +2796,7 @@ int group_snap_get_by_id(librados::IoCtx *ioctx, const std::string &oid,
   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;
   }
@@ -2817,7 +2819,7 @@ void group_snap_list_start(librados::ObjectReadOperation *op,
   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,
@@ -2856,7 +2858,7 @@ void group_snap_list_order_start(librados::ObjectReadOperation *op,
   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,
@@ -2895,7 +2897,7 @@ void trash_add(librados::ObjectWriteOperation *op,
   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,
@@ -2912,7 +2914,7 @@ void trash_remove(librados::ObjectWriteOperation *op,
 {
   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)
@@ -2929,7 +2931,7 @@ void trash_list_start(librados::ObjectReadOperation *op,
   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,
@@ -2968,7 +2970,7 @@ void trash_get_start(librados::ObjectReadOperation *op,
 {
   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,
@@ -3008,7 +3010,7 @@ void trash_state_set(librados::ObjectWriteOperation *op,
   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,
@@ -3026,7 +3028,7 @@ void namespace_add(librados::ObjectWriteOperation *op,
 {
   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)
@@ -3042,7 +3044,7 @@ void namespace_remove(librados::ObjectWriteOperation *op,
 {
   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)
@@ -3059,7 +3061,7 @@ void namespace_list_start(librados::ObjectReadOperation *op,
   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,
@@ -3099,7 +3101,7 @@ void sparsify(librados::ObjectWriteOperation *op, uint64_t sparse_size,
   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,
index 8369025b38ddad0d4faeb551d5c271f7ceb61a32..b767ea542144c63bfb5ae6c4be96009235888755 100644 (file)
@@ -331,8 +331,17 @@ void dir_remove_image(librados::ObjectWriteOperation *op,
 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,
diff --git a/src/cls/rbd/cls_rbd_ops.h b/src/cls/rbd/cls_rbd_ops.h
new file mode 100644 (file)
index 0000000..e4de4ba
--- /dev/null
@@ -0,0 +1,170 @@
+#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
index cd7cad2e88dca759c1e6531bcd4a581ed63e02bc..4232312987bba6cbcbf98e17ce43e30cfa2a74dd 100644 (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; }
@@ -1035,6 +1038,7 @@ std::ostream& operator<<(std::ostream& os, const AssertSnapcSeqState& state);
 
 void sanitize_entity_inst(entity_inst_t* entity_inst);
 
+
 } // namespace rbd
 } // namespace cls
 
index 0597c5999d13262d7390af60231e1f8a1ba0fb0b..8634191d6839809e9664e10fe9ff53e0ac3154a7 100644 (file)
@@ -204,13 +204,14 @@ CLS_INIT(refcount)
   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;
 }
index ac58a5c4ad666fd291da25bcae1f9a12203c2dcf..065c3e1ee2fcd9d9aee19f804223fd88ded3eec3 100644 (file)
@@ -11,6 +11,7 @@ using std::list;
 using std::string;
 
 using ceph::bufferlist;
+using namespace cls::refcount;
 
 void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref)
 {
@@ -19,7 +20,7 @@ void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, boo
   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)
@@ -29,7 +30,7 @@ void cls_refcount_put(librados::ObjectWriteOperation& op, const string& tag, boo
   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)
@@ -38,7 +39,7 @@ 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)
@@ -47,7 +48,7 @@ int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list<string> *refs,
   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;
 
index 1cd8bf20f772cbff0a17491ac36b058bf4f16d73..eda25365d25baade164e8520eccca4d9f2662311 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "include/types.h"
 #include "common/hobject.h"
+#include "include/rados/cls_traits.h"
 
 struct cls_refcount_get_op {
   std::string tag;
@@ -151,4 +152,15 @@ struct obj_refcount {
 };
 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
index c7912d7ef52da5e1c101040ec142687a3b22c662..bd388a9baec42690027b7532e9724972b3bc8b55 100644 (file)
@@ -5250,81 +5250,86 @@ CLS_INIT(rgw)
   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;
 }
index 0b590cd756d631f8c3d10ea0cb1d3b32f6424e25..a490e5a69189ba9d21eeb17d4fd4b42113592320 100644 (file)
@@ -17,6 +17,7 @@ using std::vector;
 using ceph::real_time;
 
 using namespace librados;
+using namespace cls::rgw;
 
 const string BucketIndexShardsManager::KEY_VALUE_SEPARATOR = "#";
 const string BucketIndexShardsManager::SHARDS_SEPARATOR = ",";
@@ -52,13 +53,13 @@ public:
 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,
@@ -67,7 +68,7 @@ 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,
@@ -82,7 +83,7 @@ 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,
@@ -95,7 +96,7 @@ void cls_rgw_bucket_prepare_op(ObjectWriteOperation& o, RGWModifyOp op, const st
   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,
@@ -124,7 +125,7 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, const s
     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,
@@ -144,7 +145,7 @@ 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));
 }
 
@@ -154,7 +155,7 @@ void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list<string>& keep_at
   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)
@@ -163,7 +164,7 @@ void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& a
   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)
@@ -173,7 +174,7 @@ void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string&
   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)
@@ -184,7 +185,7 @@ void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const real_time& mtim
   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,
@@ -196,7 +197,7 @@ 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;
 
@@ -220,7 +221,7 @@ int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, const rgw_cls_bi_e
   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;
@@ -234,7 +235,7 @@ void cls_rgw_bi_put(ObjectWriteOperation& op, const string oid, const rgw_cls_bi
   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,
@@ -249,7 +250,7 @@ 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
@@ -266,7 +267,7 @@ int cls_rgw_bi_list(librados::IoCtx& io_ctx, const std::string& oid,
   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;
 
@@ -318,7 +319,7 @@ void cls_rgw_bucket_link_olh(librados::ObjectWriteOperation& op, const cls_rgw_o
   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,
@@ -350,7 +351,7 @@ void cls_rgw_bucket_unlink_instance(librados::ObjectWriteOperation& op,
   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)
@@ -361,7 +362,7 @@ void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_ke
   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,
@@ -390,7 +391,7 @@ void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_
   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)
@@ -408,7 +409,7 @@ void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key
   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,
@@ -421,7 +422,7 @@ 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,
@@ -434,20 +435,20 @@ 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,
@@ -460,7 +461,7 @@ 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)
@@ -471,19 +472,19 @@ void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist
 
 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 {
@@ -512,7 +513,7 @@ int cls_rgw_get_dir_header_async(IoCtx& io_ctx, const string& oid,
   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);
@@ -540,7 +541,7 @@ int cls_rgw_usage_log_read(IoCtx& io_ctx, const string& oid, const string& user,
   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;
 
@@ -574,7 +575,7 @@ int cls_rgw_usage_log_trim(IoCtx& io_ctx, const string& oid, const string& user,
   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;
@@ -595,13 +596,13 @@ void cls_rgw_usage_log_trim(librados::ObjectWriteOperation& op, const string& us
   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)
@@ -610,7 +611,7 @@ 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 */
@@ -622,7 +623,7 @@ void cls_rgw_gc_set_entry(ObjectWriteOperation& op, uint32_t expiration_secs, cl
   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)
@@ -632,7 +633,7 @@ void cls_rgw_gc_defer_entry(ObjectWriteOperation& op, uint32_t expiration_secs,
   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,
@@ -644,7 +645,7 @@ 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,
@@ -673,13 +674,13 @@ void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const vector<string>&
   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)
@@ -702,7 +703,7 @@ void cls_rgw_lc_put_head(ObjectWriteOperation& op, const cls_rgw_lc_obj_head& he
   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,
@@ -712,7 +713,7 @@ 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)
@@ -736,7 +737,7 @@ void cls_rgw_lc_rm_entry(ObjectWriteOperation& op,
   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,
@@ -746,7 +747,7 @@ 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,
@@ -755,7 +756,7 @@ 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)
@@ -782,7 +783,7 @@ void cls_rgw_lc_list(ObjectReadOperation& op, const string& marker,
 
   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)
@@ -813,7 +814,7 @@ void cls_rgw_mp_upload_part_info_update(librados::ObjectWriteOperation& op,
   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,
@@ -825,7 +826,7 @@ 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,
@@ -836,7 +837,7 @@ int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& mar
   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;
 
@@ -860,7 +861,7 @@ int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const string& oid, cls_rgw_resh
   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;
 
@@ -885,7 +886,7 @@ void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_re
   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)
@@ -893,7 +894,7 @@ 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,
@@ -902,7 +903,7 @@ 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,
@@ -921,7 +922,7 @@ void cls_rgw_guard_bucket_resharding(librados::ObjectOperation& op, int ret_err)
   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,
@@ -933,5 +934,5 @@ 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);
 }
index f3caada0b79f805cf8eef2fba1c57eb9ea9ba8e6..3daeb6ee9b2321113b7cbd52f44e1eeb575f7469 100644 (file)
@@ -1789,3 +1789,80 @@ struct cls_rgw_get_bucket_resharding_ret  {
   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);
+}
+}
index 6fe5e4e251d1c36380eb4cdf6c9cde17b0e9c8f7..0eff26df3f99d7e5bd4a367c683fc79e595a44d4 100644 (file)
 
 #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
index 7f24a6479937c37e289734ff8528d529cd25856d..6ab291c66903b6926460e6d5350b12cdc6235ade 100644 (file)
@@ -545,14 +545,15 @@ CLS_INIT(rgw_gc)
   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;
 }
index 91c4f2d40193fe667d9c47c6947c55f7c5f00d99..2702643a48cd342382f1df1477bd50ff14a8ecbb 100644 (file)
@@ -17,6 +17,7 @@ using ceph::decode;
 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)
 {
@@ -25,13 +26,13 @@ void cls_rgw_gc_queue_init(ObjectWriteOperation& op, uint64_t size, uint64_t num
   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;
 
@@ -55,7 +56,7 @@ void cls_rgw_gc_queue_enqueue(ObjectWriteOperation& op, uint32_t expiration_secs
   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,
@@ -68,7 +69,7 @@ int cls_rgw_gc_queue_list_entries(IoCtx& io_ctx, const string& oid, const string
   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;
 
@@ -95,7 +96,7 @@ void cls_rgw_gc_queue_remove_entries(ObjectWriteOperation& op, uint32_t num_entr
   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)
@@ -105,5 +106,5 @@ void cls_rgw_gc_queue_defer_entry(ObjectWriteOperation& op, uint32_t expiration_
   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);
 }
index 143a55b9470642523003da61ecc747af96d26c02..297e14a64a72899fed5286a0c5bb8ccfcf8f8cf8 100644 (file)
@@ -4,6 +4,8 @@
 #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;
@@ -79,3 +81,16 @@ struct cls_rgw_gc_queue_defer_entry_op {
   }
 };
 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
index 843369f1c4a8d5db55124daa13a68a4c14221fe2..6501c0f898a4e706ad3b6c13484333886f392ee2 100644 (file)
@@ -2,6 +2,7 @@
  * 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)
@@ -115,17 +116,13 @@ static int test_coverage_replay(cls_method_context_t hctx, ceph::buffer::list *i
   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);
 }
diff --git a/src/cls/sdk/cls_sdk_ops.h b/src/cls/sdk/cls_sdk_ops.h
new file mode 100644 (file)
index 0000000..d9e910e
--- /dev/null
@@ -0,0 +1,13 @@
+#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
index e891adabd0d59bd0ba4dea86b01347e1b84590f1..a0d4c64ac9a97184972b56a4b7e43faa5a473e07 100644 (file)
@@ -279,22 +279,14 @@ CLS_INIT(sem_set)
   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;
 }
index e57e3c85891b476ccab4162f66099e13c13fc0a8..fc4b294cf86c0ad2be57dc67f84aeb27444f31e7 100644 (file)
@@ -12,6 +12,7 @@
 #include <boost/container/flat_map.hpp>
 
 #include "include/encoding.h"
+#include "include/rados/cls_traits.h"
 
 namespace cls::sem_set {
 using namespace std::literals;
@@ -163,4 +164,14 @@ inline constexpr auto DECREMENT = "decrement";
 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
index c07da2cd1c2d47e0d776e44b4e7e5ccb548de9d8..a3ab7baa9c04ef3055d31e628c25514d56174871 100644 (file)
@@ -251,15 +251,13 @@ CLS_INIT(timeindex)
   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;
 }
index c53134650ef934fe83da261bbf6636f58c45b910..906373ddaf4e93ab89b52fe3290ad0a3ddc02c83 100644 (file)
@@ -7,6 +7,8 @@
 #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)
@@ -16,7 +18,7 @@ void cls_timeindex_add(
   call.entries = entries;
 
   encode(call, in);
-  op.exec("timeindex", "add", in);
+  op.exec(method::add, in);
 }
 
 void cls_timeindex_add(
@@ -28,7 +30,7 @@ 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(
@@ -69,7 +71,7 @@ void cls_timeindex_trim(
 
   encode(call, in);
 
-  op.exec("timeindex", "trim", in);
+  op.exec(method::trim, in);
 }
 
 int cls_timeindex_trim(
@@ -115,6 +117,6 @@ void cls_timeindex_list(
 
   encode(call, in);
 
-  op.exec("timeindex", "list", in,
+  op.exec(method::list, in,
           new TimeindexListCtx(&entries, out_marker, truncated));
 }
index 31801e6fb2b7e0d5f638702455870cd2567f43db..50c1600e7d381c1c9ce8c92a670b8e1247b6c235 100644 (file)
@@ -6,6 +6,7 @@
 
 #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;
@@ -154,4 +155,15 @@ struct cls_timeindex_trim_op {
 };
 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 */
index 24e7328c66b12fa9e30d014d177e8de720a04fa5..eb92451dd2660398a41ad13fac5eaffa57869e26 100644 (file)
@@ -733,18 +733,17 @@ CLS_INIT(user)
   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;
@@ -752,12 +751,8 @@ CLS_INIT(user)
   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);
 }
index 769bc5f6e9c7cd0808e0f1cbc8a024d14a591cfd..12f2d64d2497ef44ac60c714d90d7b61724f4317 100644 (file)
@@ -15,6 +15,7 @@ using ceph::real_clock;
 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)
 {
@@ -24,7 +25,7 @@ void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_buck
   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)
@@ -33,7 +34,7 @@ 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)
@@ -42,7 +43,7 @@ void cls_user_remove_bucket(librados::ObjectWriteOperation& op, const cls_user_b
   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 {
@@ -92,7 +93,7 @@ void cls_user_bucket_list(librados::ObjectReadOperation& op,
 
   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 {
@@ -135,7 +136,7 @@ void cls_user_get_header(librados::ObjectReadOperation& op,
 
   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)
@@ -144,7 +145,7 @@ 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)
@@ -153,7 +154,7 @@ int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *c
   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();
@@ -175,7 +176,7 @@ void cls_user_account_resource_add(librados::ObjectWriteOperation& op,
 
   bufferlist inbl;
   encode(call, inbl);
-  op.exec("user", "account_resource_add", inbl);
+  op.exec(method::account_resource_add, inbl);
 }
 
 class ResourceGetCB : public librados::ObjectOperationCompletion {
@@ -214,7 +215,7 @@ void cls_user_account_resource_get(librados::ObjectReadOperation& op,
 
   bufferlist inbl;
   encode(call, inbl);
-  op.exec("user", "account_resource_get", inbl,
+  op.exec(method::account_resource_get, inbl,
           new ResourceGetCB(&entry, pret));
 }
 
@@ -226,7 +227,7 @@ void cls_user_account_resource_rm(librados::ObjectWriteOperation& op,
 
   bufferlist inbl;
   encode(call, inbl);
-  op.exec("user", "account_resource_rm", inbl);
+  op.exec(method::account_resource_rm, inbl);
 }
 
 class ResourceListCB : public librados::ObjectOperationCompletion {
@@ -280,6 +281,6 @@ void cls_user_account_resource_list(librados::ObjectReadOperation& op,
 
   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));
 }
index f69f9642592f68fa8377bd165adfa9a40fb25043..10bde7f10660e5cdd8be4f82c514fb024da81b6b 100644 (file)
@@ -5,6 +5,7 @@
 #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;
@@ -395,4 +396,23 @@ struct cls_user_account_resource_list_ret {
 };
 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
index b57571025ab0551e5d1f07d2f9d11c4f051cf5e1..60bdb878e564ca4fc88d5575ea90aec815180f33 100644 (file)
@@ -224,14 +224,16 @@ CLS_INIT(version)
   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;
 }
index 70fcc2f053f7c38605a903c2e322f5b47eee43a1..196d96bb515d0183dc7808952281cfcfcfddb9f0 100644 (file)
@@ -8,7 +8,7 @@
 
 
 using namespace librados;
-
+using namespace cls::version;
 
 void cls_version_set(librados::ObjectWriteOperation& op, obj_version& objv)
 {
@@ -16,7 +16,7 @@ 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)
@@ -24,7 +24,7 @@ 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)
@@ -40,9 +40,10 @@ void cls_version_inc(librados::ObjectWriteOperation& op, obj_version& objv, Vers
   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;
@@ -56,7 +57,7 @@ void cls_version_check(librados::ObjectOperation& op, obj_version& objv, Version
   call.conds.push_back(c);
 
   encode(call, in);
-  op.exec("version", "check_conds", in);
+  op.exec(method::check_conds, in);
 }
 
 class VersionReadCtx : public ObjectOperationCompletion {
@@ -80,13 +81,13 @@ public:
 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;
 
index 8cc474a68cce610ec78e987d13a61eb27c4b8eaf..a8e1c9ea8d49694395e3912ed29a53255e7b61e7 100644 (file)
@@ -27,6 +27,24 @@ void cls_version_read(librados::ObjectReadOperation& op, obj_version *objv);
 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
index 03212fbad64e3e247f1d68c5b592fa7b0a6426a3..eff2392780a34f70ee81e7117f683c726e52d99e 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "cls_version_types.h"
 #include "common/ceph_json.h"
+#include "include/rados/cls_traits.h"
 
 struct cls_version_set_op {
   obj_version objv;
@@ -151,5 +152,18 @@ struct cls_version_read_ret {
 };
 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
index 66043a91738c06e34719e8fcc25aa938f9d4f53e..05db3fd77c4cfd7dc384073bd6d3607128890a5d 100644 (file)
@@ -12,6 +12,7 @@
 #include "common/Formatter.h"
 #include "include/encoding.h"
 #include "include/types.h"
+#include "include/rados/cls_traits.h"
 
 
 class JSONObj;
@@ -125,5 +126,4 @@ struct obj_version_cond {
 };
 WRITE_CLASS_ENCODER(obj_version_cond)
 
-
 #endif
index 2caa596f10c460f4e5edd839c7d682e053a9f363..f49862bb1a73c0150b04aacdff94d58a8cee1e60 100644 (file)
@@ -113,16 +113,16 @@ auto maybecat(boost::system::error_code ec,
 #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)
@@ -138,29 +138,30 @@ auto exec(
   }
   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
index cddc9b2235f5aa3e823c6777286dbcbf719031ff..9af7bc4ac85133204ab66b35d6c892ff18f69612 100644 (file)
@@ -57,7 +57,7 @@ namespace sys = boost::system;
 
 namespace async = ceph::async;
 namespace buffer = ceph::buffer;
-namespace fifo = rados::cls::fifo;
+namespace fifo = ::rados::cls::fifo;
 
 using neorados::RADOS;
 using neorados::Object;
@@ -175,7 +175,7 @@ public:
     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,
@@ -214,7 +214,7 @@ public:
           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;
@@ -248,7 +248,7 @@ public:
 
     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);
@@ -282,7 +282,7 @@ public:
           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);
 
@@ -316,7 +316,7 @@ private:
     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),
@@ -365,7 +365,7 @@ private:
 
     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));
   }
@@ -404,7 +404,7 @@ private:
 
     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));
   }
@@ -449,7 +449,7 @@ private:
            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;
                    });
@@ -508,7 +508,7 @@ private:
           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;
@@ -581,7 +581,7 @@ private:
 
           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{};
index b4cd238f4851d9178fe048b5a0957a531a844887..458d93df4a257420ebce3fb93563dfcbaef71425 100644 (file)
@@ -48,6 +48,7 @@
 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
@@ -64,7 +65,7 @@ static constexpr auto max_list_entries = 1000u;
   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);
   }};
 }
 
@@ -82,7 +83,7 @@ static constexpr auto max_list_entries = 1000u;
   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);
   }};
 }
 
@@ -105,7 +106,7 @@ static constexpr auto max_list_entries = 1000u;
                            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);
   }};
 }
 
@@ -139,7 +140,7 @@ static constexpr auto max_list_entries = 1000u;
   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) {
@@ -219,7 +220,7 @@ auto list(RADOS& r, Object o, IOContext ioc, ceph::real_time from,
   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;
@@ -283,7 +284,7 @@ auto info(RADOS& r, Object o, IOContext ioc, CompletionToken&& token)
   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);
   }};
 }
 
@@ -325,7 +326,7 @@ inline constexpr std::string_view end_marker{"9"};
   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);
   }};
 }
 
index 5bf3bbc9dac9127585d2992acaed1ceac4a939c2..8eda323b799712ff5111e9cd6445aac1ece02308 100644 (file)
@@ -54,7 +54,7 @@ using ::cls::sem_set::max_keys;
   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);
   }};
 }
 
@@ -74,7 +74,7 @@ using ::cls::sem_set::max_keys;
   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);
   }};
 }
 
@@ -94,7 +94,7 @@ using ::cls::sem_set::max_keys;
   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);
   }};
 }
 
@@ -117,7 +117,7 @@ template<std::input_iterator I>
   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);
   }};
 }
 
@@ -139,7 +139,7 @@ decrement(std::string key, ceph::timespan grace = 0ns)
   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);
   }};
 }
 
@@ -161,7 +161,7 @@ decrement(std::initializer_list<std::string> keys, ceph::timespan grace = 0ns)
   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);
   }};
 }
 
@@ -183,7 +183,7 @@ decrement(boost::container::flat_set<std::string> keys, ceph::timespan grace = 0
   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);
   }};
 }
 
@@ -207,7 +207,7 @@ decrement(I begin, I end, ceph::timespan grace = 0ns)
   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);
   }};
 }
 
@@ -231,7 +231,7 @@ decrement(I begin, I end, ceph::timespan grace = 0ns)
   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);
   }};
 }
 
@@ -263,7 +263,7 @@ decrement(I begin, I end, ceph::timespan grace = 0ns)
   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) {
@@ -323,7 +323,7 @@ template<std::output_iterator<std::pair<std::string, std::uint64_t>> I>
   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) {
index 460217631c6ce71328fbc47c2221ef602b0f587e..de73090cea5a6746fb316cae1d6accb091deea48 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "neorados/cls/common.h"
 
+using namespace cls::version;
 namespace neorados::cls::version {
 /// \brief Set the object version
 ///
@@ -51,7 +52,7 @@ namespace neorados::cls::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);
   }};
 }
 
@@ -67,7 +68,7 @@ namespace neorados::cls::version {
   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);
   }};
 }
 
@@ -95,7 +96,7 @@ namespace neorados::cls::version {
 
   encode(call, in);
   return ClsWriteOp{[in = std::move(in)](WriteOp& op) {
-    op.exec("version", "inc_conds", in);
+    op.exec(method::inc_conds, in);
   }};
 }
 
@@ -124,7 +125,7 @@ namespace neorados::cls::version {
 
   encode(call, in);
   return ClsOp{[in = std::move(in)](Op& op) {
-    op.exec("version", "check_conds", in);
+    op.exec(method::check_conds, in);
   }};
 }
 
@@ -138,9 +139,10 @@ namespace neorados::cls::version {
 [[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;
@@ -186,7 +188,7 @@ inline auto read(RADOS& r, Object o, IOContext ioc,
   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));
index 96028c5e0420cfa75a7ff78b9f024085b5a1a914..579030b8d4acf50dc7c5adce573d3b51de7df051 100644 (file)
@@ -270,7 +270,7 @@ TEST_F(TestCls2PCQueue, UpgradeFromReef)
     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) {
index a21b504f5f26e6bf249039b34a1364efa2f54e67..667b67ee8f9f7e9498a3050cc32d2cc3abf53ed5 100644 (file)
@@ -17,6 +17,7 @@
 #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"
@@ -24,6 +25,7 @@
 #include "json_spirit/json_spirit.h"
 
 using namespace librados;
+using namespace cls::hello;
 
 TEST(ClsHello, SayHello) {
   Rados cluster;
@@ -33,14 +35,14 @@ TEST(ClsHello, SayHello) {
   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();
@@ -48,7 +50,7 @@ TEST(ClsHello, SayHello) {
   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));
 }
@@ -61,20 +63,20 @@ TEST(ClsHello, RecordHello) {
   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));
@@ -120,7 +122,7 @@ TEST(ClsHello, WriteReturnData) {
 
   // 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.
@@ -135,7 +137,7 @@ TEST(ClsHello, WriteReturnData) {
     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));
@@ -153,7 +155,7 @@ TEST(ClsHello, WriteReturnData) {
     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));
@@ -169,7 +171,7 @@ TEST(ClsHello, WriteReturnData) {
     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);
@@ -183,7 +185,7 @@ TEST(ClsHello, WriteReturnData) {
     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));
@@ -204,12 +206,12 @@ TEST(ClsHello, Loud) {
   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));
@@ -225,8 +227,8 @@ TEST(ClsHello, BadMethods) {
   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));
 }
index e7c0f80d23eca47424319773785372e38a0744ac..a724bb4c5bfb3a160a68e7551b6920bfb62a28a5 100644 (file)
@@ -7,6 +7,7 @@
 #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;
 
@@ -1103,7 +1104,7 @@ TEST_F(ClsLua, Json) {
 
   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);
 
index ebb2256208b605aec3a8e0c5d632a1f993f50f7c..09848ecd40a5c8e6c966e9bd2c1302ecd9f08fe6 100644 (file)
@@ -24,6 +24,7 @@
 #include "test/librados/test_cxx.h"
 
 using namespace librados;
+using namespace rados::cls::numops;
 
 TEST(ClsNumOps, Add) {
   Rados cluster;
@@ -36,7 +37,7 @@ TEST(ClsNumOps, Add) {
 
   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
 
@@ -220,7 +221,7 @@ TEST(ClsNumOps, Mul) {
 
   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
 
index 9fc1e3cd3a0db590ed5844f183b72b457c0772e9..b77c5dde3ea627360a2d132f10d842058ce6f6d6 100644 (file)
@@ -478,7 +478,7 @@ TEST_F(TestClsRbd, create)
                                   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();
 }
index 775c8c3ff371e6f132603bb65801364d4abc58ff..192cbbacff27911596863e953edc8409c7c79848 100644 (file)
@@ -3,8 +3,10 @@
 
 #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;
@@ -15,7 +17,7 @@ TEST(ClsSDK, TestSDKCoverageWrite) {
 
   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));
@@ -30,11 +32,11 @@ TEST(ClsSDK, TestSDKCoverageReplay) {
 
   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));