return ret;
}
+const string resharding_attr = "resharding";
+
+static int cls_rgw_set_bucket_resharding(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+{
+ cls_rgw_set_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_set_bucket_resharding: failed to decode entry\n");
+ return -EINVAL;
+ }
+
+ bufferlist bl;
+ ::encode(true, bl);
+ int ret = cls_cxx_setxattr(hctx, resharding_attr.c_str(), &bl);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_setxattr (attr=%s) returned %d", __func__, resharding_attr.c_str(), ret);
+ return ret;
+ }
+
+ ret = cls_cxx_write(hctx, 0, op.entry.data.length(), &op.entry.data);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_write returned %d", __func__, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int cls_rgw_clear_bucket_resharding(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+{
+ cls_rgw_set_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;
+ ::encode(false, bl);
+ int ret = cls_cxx_setxattr(hctx, resharding_attr.c_str(), &bl);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_setxattr (attr=%s) returned %d", __func__, resharding_attr.c_str(), ret);
+ return ret;
+ }
+
+ ret = cls_cxx_write(hctx, 0, op.entry.data.length(), &op.entry.data);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_write returned %d", __func__, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
CLS_INIT(rgw)
{
cls_method_handle_t h_rgw_reshard_get;
cls_method_handle_t h_rgw_reshard_get_head;
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_register(RGW_CLASS, &h_class);
::encode(call, in);
op.exec("rgw", "reshard_remove", in);
}
+
+int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
+ const cls_rgw_bucket_instance_entry& entry)
+{
+ bufferlist in, out;
+ struct cls_rgw_set_bucket_resharding_op call;
+ call.entry = entry;
+ ::encode(call, in);
+ return io_ctx.exec(oid, "rgw", "set_bucket_resharding", in, out);
+}
+
+int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
+ const cls_rgw_bucket_instance_entry& entry)
+{
+ bufferlist in, out;
+ struct cls_rgw_clear_bucket_resharding_op call;
+ call.entry = entry;
+ ::encode(call, in);
+ return io_ctx.exec(oid, "rgw", "clear_bucket_resharding", in, out);
+}
+
int cls_rgw_reshard_get_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry);
void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry);
+/* resharding attribute */
+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);
+
#endif
}
+void cls_rgw_set_bucket_resharding_op::generate_test_instances(
+ list<cls_rgw_set_bucket_resharding_op*>& ls)
+{
+ ls.push_back(new cls_rgw_set_bucket_resharding_op);
+ ls.push_back(new cls_rgw_set_bucket_resharding_op);
+}
+
+void cls_rgw_set_bucket_resharding_op::dump(Formatter *f) const
+{
+ ::encode_json("entry", entry, f);
+}
+
+void cls_rgw_clear_bucket_resharding_op::generate_test_instances(
+ list<cls_rgw_clear_bucket_resharding_op*>& ls)
+{
+ ls.push_back(new cls_rgw_clear_bucket_resharding_op);
+ ls.push_back(new cls_rgw_clear_bucket_resharding_op);
+}
+
+void cls_rgw_clear_bucket_resharding_op::dump(Formatter *f) const
+{
+ ::encode_json("entry", entry, f);
+}
+
+
};
WRITE_CLASS_ENCODER(cls_rgw_reshard_remove_op)
+struct cls_rgw_set_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_set_bucket_resharding_op*>& o);
+ void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(cls_rgw_set_bucket_resharding_op)
+
+struct cls_rgw_clear_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_clear_bucket_resharding_op*>& o);
+ void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(cls_rgw_clear_bucket_resharding_op)
+
#endif /* CEPH_CLS_RGW_OPS_H */
ls.back()->old_num_shards = 8;
ls.back()->new_num_shards = 64;
}
+
+void cls_rgw_bucket_instance_entry::dump(Formatter *f) const
+{
+ encode_json("data", data, f);
+ encode_json("resharding", resharding, f);
+ encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
+
+}
+
+void cls_rgw_bucket_instance_entry::generate_test_instances(list<cls_rgw_bucket_instance_entry*>& ls)
+{
+ ls.push_back(new cls_rgw_bucket_instance_entry);
+ ls.push_back(new cls_rgw_bucket_instance_entry);
+ ls.back()->resharding = true;
+ ls.back()->new_bucket_instance_id = "new_instance_id";
+}
};
WRITE_CLASS_ENCODER(cls_rgw_reshard_entry)
+struct cls_rgw_bucket_instance_entry {
+ bool resharding;
+ string new_bucket_instance_id;
+ bufferlist data;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode(resharding, bl);
+ ::encode(new_bucket_instance_id, bl);
+ ::encode(data, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::iterator& bl) {
+ DECODE_START(1, bl);
+ ::decode(resharding, bl);
+ ::decode(new_bucket_instance_id, bl);
+ ::decode(data, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
+};
+WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
+
#endif
TYPE(cls_rgw_reshard_get_head_op)
TYPE(cls_rgw_reshard_get_head_ret)
TYPE(cls_rgw_reshard_remove_op)
+TYPE(cls_rgw_set_bucket_resharding_op)
+TYPE(cls_rgw_clear_bucket_resharding_op)
#include "cls/rgw/cls_rgw_client.h"
TYPE(rgw_bi_log_entry)
TYPE(cls_rgw_reshard_entry)
+TYPE(cls_rgw_bucket_instance_entry)
#include "cls/user/cls_user_types.h"
TYPE(cls_user_bucket)