]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls rgw: implement a method to get a single LC entry
authorAbhishek Lekshmanan <abhishek@suse.com>
Tue, 5 Mar 2019 12:37:00 +0000 (13:37 +0100)
committerAbhishek Lekshmanan <abhishek@suse.com>
Fri, 12 Apr 2019 16:08:27 +0000 (18:08 +0200)
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
(cherry picked from commit 64c5d6f880cf6d4d7a93cf4961f14f067d275736)

src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/cls/rgw/cls_rgw_const.h
src/cls/rgw/cls_rgw_ops.h

index 122a72525afd5e0e4a8b6366f10a4bd7940d5dd2..f81ca2ced3e23e0eaee311115a167ecccb07e6bd 100644 (file)
@@ -3497,6 +3497,29 @@ static int rgw_cls_gc_remove(cls_method_context_t hctx, bufferlist *in, bufferli
   return gc_remove(hctx, op.tags);
 }
 
+static int rgw_cls_lc_get_entry(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+{
+  auto in_iter = in->cbegin();
+
+  cls_rgw_lc_get_entry_op op;
+  try {
+    decode(op, in_iter);
+  } catch (buffer::error& err) {
+    CLS_LOG(1, "ERROR: rgw_cls_lc_set_entry(): failed to decode entry\n");
+    return -EINVAL;
+  }
+
+  rgw_lc_entry_t lc_entry;
+  int ret = read_omap_entry(hctx, op.marker, &lc_entry);
+  if (ret < 0)
+    return ret;
+
+  cls_rgw_lc_get_entry_ret op_ret(std::move(lc_entry));
+  encode(op_ret, *out);
+  return 0;
+}
+
+
 static int rgw_cls_lc_set_entry(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 {
   auto in_iter = in->cbegin();
@@ -3904,6 +3927,7 @@ CLS_INIT(rgw)
   cls_method_handle_t h_rgw_gc_set_entry;
   cls_method_handle_t h_rgw_gc_list;
   cls_method_handle_t h_rgw_gc_remove;
+  cls_method_handle_t h_rgw_lc_get_entry;
   cls_method_handle_t h_rgw_lc_set_entry;
   cls_method_handle_t h_rgw_lc_rm_entry;
   cls_method_handle_t h_rgw_lc_get_next_entry;
@@ -3966,6 +3990,7 @@ CLS_INIT(rgw)
   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);
index c5fde8cf298a92ff001cc4607df040bb31a41baf..1f25068f9f3cc5e329da39bbe32efea05475109a 100644 (file)
@@ -816,6 +816,29 @@ int cls_rgw_lc_set_entry(IoCtx& io_ctx, const string& oid, const pair<string, in
   return r;
 }
 
+int cls_rgw_lc_get_entry(IoCtx& io_ctx, const string& oid, const std::string& marker, rgw_lc_entry_t& entry)
+{
+  bufferlist in, out;
+  cls_rgw_lc_get_entry_op call{marker};;
+  encode(call, in);
+  int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_GET_ENTRY, in, out);
+
+  if (r < 0) {
+    return r;
+  }
+
+  cls_rgw_lc_get_entry_ret ret;
+  try {
+    auto iter = out.cbegin();
+    decode(ret, iter);
+  } catch (buffer::error& err) {
+    return -EIO;
+  }
+
+  entry = std::move(ret.entry);
+  return r;
+}
+
 int cls_rgw_lc_list(IoCtx& io_ctx, const string& oid,
                     const string& marker,
                     uint32_t max_entries,
index dcfb7043116ba4518d590179a50e3e8c54a8140a..3ac3ea4cf69a655786e511ccbb2ae8a380d50eb9 100644 (file)
@@ -553,6 +553,7 @@ int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_o
 int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const string& oid, string& marker, pair<string, int>& entry);
 int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const string& oid, const pair<string, int>& entry);
 int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const string& oid, const pair<string, int>& entry);
+int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const string& oid, const std::string& marker, rgw_lc_entry_t& entry);
 int cls_rgw_lc_list(librados::IoCtx& io_ctx, const string& oid,
                     const string& marker,
                     uint32_t max_entries,
index 1d920abff8d0e7cef69b60d1f94e4f16f7b3d448..fc3537ea880c2a652fbe1e321a5035ca32531719 100644 (file)
@@ -52,6 +52,7 @@
 #define RGW_GC_REMOVE "gc_remove"
 
 /* lifecycle bucket list */
+#define RGW_LC_GET_ENTRY "lc_get_entry"
 #define RGW_LC_SET_ENTRY "lc_set_entry"
 #define RGW_LC_RM_ENTRY "lc_rm_entry"
 #define RGW_LC_GET_NEXT_ENTRY "lc_get_next_entry"
index 30e82a9e20f85b772d716fb405c1b06489960822..86f08bcf6770a6f4a7ed7a265784d4fe67035b12 100644 (file)
@@ -1031,6 +1031,46 @@ struct cls_rgw_lc_get_next_entry_ret {
 };
 WRITE_CLASS_ENCODER(cls_rgw_lc_get_next_entry_ret)
 
+struct cls_rgw_lc_get_entry_op {
+  string marker;
+  cls_rgw_lc_get_entry_op() {}
+  cls_rgw_lc_get_entry_op(const std::string& _marker) : marker(_marker) {}
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    encode(marker, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::const_iterator& bl) {
+    DECODE_START(1, bl);
+    decode(marker, bl);
+    DECODE_FINISH(bl);
+  }
+};
+WRITE_CLASS_ENCODER(cls_rgw_lc_get_entry_op)
+
+struct cls_rgw_lc_get_entry_ret {
+  rgw_lc_entry_t entry;
+  cls_rgw_lc_get_entry_ret() {}
+  cls_rgw_lc_get_entry_ret(rgw_lc_entry_t&& _entry) : entry(std::move(_entry)) {}
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    encode(entry, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::const_iterator& bl) {
+    DECODE_START(1, bl);
+    decode(entry, bl);
+    DECODE_FINISH(bl);
+  }
+
+};
+WRITE_CLASS_ENCODER(cls_rgw_lc_get_entry_ret)
+
+
 struct cls_rgw_lc_rm_entry_op {
   rgw_lc_entry_t entry;
   cls_rgw_lc_rm_entry_op() {}