]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add cls_rgw_get_resharding
authorOrit Wasserman <owasserm@redhat.com>
Fri, 14 Apr 2017 11:35:54 +0000 (14:35 +0300)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:34 +0000 (13:17 -0700)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
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_ops.cc
src/cls/rgw/cls_rgw_ops.h

index c27f7b295679dd584c0d2d556bec678eeb4b38af..6149f688cf7e82da6bd5c0808150f49e1745909f 100644 (file)
@@ -3674,6 +3674,38 @@ static int rgw_clear_bucket_resharding(cls_method_context_t hctx, bufferlist *in
   return 0;
 }
 
+static int rgw_get_bucket_resharding(cls_method_context_t hctx, bufferlist *in,  bufferlist *out)
+{
+  cls_rgw_get_bucket_resharding_op op;
+
+  bufferlist::iterator in_iter = in->begin();
+  try {
+    ::decode(op, in_iter);
+  } catch (buffer::error& err) {
+    CLS_LOG(1, "ERROR: cls_rgw_clear_bucket_resharding: failed to decode entry\n");
+    return -EINVAL;
+  }
+
+  bufferlist bl;
+  int ret = cls_cxx_getxattr(hctx, resharding_attr.c_str(), &bl);
+  if (ret < 0) {
+    CLS_LOG(0, "ERROR: %s(): cls_cxx_getxattr (attr=%s) returned %d", __func__, resharding_attr.c_str(), ret);
+    return ret;
+  }
+
+  cls_rgw_get_bucket_resharding_ret op_ret;
+  try {
+    ::decode(op_ret.resharding, bl);
+  } catch (buffer::error& err) {
+    CLS_LOG(1, "ERROR: cls_rgw_get_bucket_resharding: failed to decode entry\n");
+    return -EINVAL;
+  }
+
+  ::encode(op_ret, *out);
+
+  return 0;
+}
+
 CLS_INIT(rgw)
 {
   CLS_LOG(1, "Loaded rgw class!");
@@ -3720,6 +3752,7 @@ CLS_INIT(rgw)
   cls_method_handle_t h_rgw_reshard_remove;
   cls_method_handle_t h_rgw_set_bucket_resharding;
   cls_method_handle_t h_rgw_clear_bucket_resharding;
+  cls_method_handle_t h_rgw_get_bucket_resharding;
 
 
   cls_register(RGW_CLASS, &h_class);
@@ -3779,6 +3812,8 @@ CLS_INIT(rgw)
                          rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding);
   cls_register_cxx_method(h_class, "clear_bucket_resharding", CLS_METHOD_RD | CLS_METHOD_WR,
                          rgw_clear_bucket_resharding, &h_rgw_clear_bucket_resharding);
+  cls_register_cxx_method(h_class, "get_bucket_resharding", CLS_METHOD_RD ,
+                         rgw_get_bucket_resharding, &h_rgw_get_bucket_resharding);
   return;
 }
 
index 81165b5aa9174e41c3bcce91eaace833986d885f..5fb997448facda9a14440cd988db6fbdeaf632b0 100644 (file)
@@ -887,3 +887,26 @@ int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
   return io_ctx.exec(oid, "rgw", "clear_bucket_resharding", in, out);
 }
 
+int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
+                                 const cls_rgw_bucket_instance_entry& entry, bool& resharding)
+{
+  bufferlist in, out;
+  struct cls_rgw_get_bucket_resharding_op call;
+  call.entry = entry;
+  ::encode(call, in);
+  int r= io_ctx.exec(oid, "rgw", "get_bucket_resharding", in, out);
+  if (r < 0)
+    return r;
+
+  struct cls_rgw_get_bucket_resharding_ret op_ret;
+  bufferlist::iterator iter = out.begin();
+  try {
+    ::decode(op_ret, iter);
+  } catch (buffer::error& err) {
+    return -EIO;
+  }
+
+  resharding = op_ret.resharding;
+
+  return 0;
+}
index 63097a4f2c4d4aa7a978a51e8a68316f1940ad28..46340ca32d4d7bb43a0d66f04ff6e858d28e6a34 100644 (file)
@@ -506,5 +506,7 @@ int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
                                   const cls_rgw_bucket_instance_entry& entry);
 int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
                                     const cls_rgw_bucket_instance_entry& entry);
+int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
+                                  const cls_rgw_bucket_instance_entry& entry, bool& resharding);
 
 #endif
index 81c9af9c05b1afec9e524d5077e97c681012b201..8cc72464bbcac097e9768c91aeb22d0c26d06d87 100644 (file)
@@ -538,6 +538,19 @@ void cls_rgw_clear_bucket_resharding_op::dump(Formatter *f) const
   ::encode_json("entry", entry, f);
 }
 
+void cls_rgw_get_bucket_resharding_op::generate_test_instances(
+  list<cls_rgw_get_bucket_resharding_op*>& ls)
+{
+  ls.push_back(new cls_rgw_get_bucket_resharding_op);
+  ls.push_back(new cls_rgw_get_bucket_resharding_op);
+}
+
+void cls_rgw_get_bucket_resharding_op::dump(Formatter *f) const
+{
+  ::encode_json("entry", entry, f);
+}
+
+
 
 
 
index 178dc9d86df802dd21cfbbb2eff6167a23c5b61f..f7663562472bb86eaf581eeeaffa6e5fc4e26f20 100644 (file)
@@ -1358,4 +1358,44 @@ struct cls_rgw_clear_bucket_resharding_op {
 };
 WRITE_CLASS_ENCODER(cls_rgw_clear_bucket_resharding_op)
 
+struct cls_rgw_get_bucket_resharding_op  {
+  cls_rgw_bucket_instance_entry entry;
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(entry, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(entry, bl);
+    DECODE_FINISH(bl);
+  }
+
+  static void generate_test_instances(list<cls_rgw_get_bucket_resharding_op*>& o);
+  void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_op)
+
+struct cls_rgw_get_bucket_resharding_ret  {
+  bool resharding;
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(resharding, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(resharding, bl);
+    DECODE_FINISH(bl);
+  }
+
+  static void generate_test_instances(list<cls_rgw_get_bucket_resharding_ret*>& o);
+  void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_ret)
+
 #endif /* CEPH_CLS_RGW_OPS_H */