mirror of
https://github.com/ceph/ceph
synced 2025-04-07 18:17:22 +00:00
rgw: add cls_rgw_get_resharding
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
This commit is contained in:
parent
11e7cb1eb4
commit
2d23898b27
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user