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;
+ struct rgw_bucket_dir_header header;
+ int rc = read_bucket_header(hctx, &header);
+ if (rc < 0) {
+ CLS_LOG(1, "ERROR: %s(): failed to read header\n", __func__);
+ return rc;
}
- 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;
- }
+ header.is_resharding = true;
+ header.new_bucket_instance_id = op.entry.new_bucket_instance_id;
- return 0;
+ return write_bucket_header(hctx, &header);
}
static int rgw_clear_bucket_resharding(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
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;
+ struct rgw_bucket_dir_header header;
+ int rc = read_bucket_header(hctx, &header);
+ if (rc < 0) {
+ CLS_LOG(1, "ERROR: %s(): failed to read header\n", __func__);
+ return rc;
}
+ header.is_resharding = false;
+ header.new_bucket_instance_id.clear();
- return 0;
+ return write_bucket_header(hctx, &header);
}
static int rgw_get_bucket_resharding(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
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;
+ struct rgw_bucket_dir_header header;
+ int rc = read_bucket_header(hctx, &header);
+ if (rc < 0) {
+ CLS_LOG(1, "ERROR: %s(): failed to read header\n", __func__);
+ return rc;
}
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;
- }
+ op_ret.resharding = header.is_resharding;
::encode(op_ret, *out);
uint64_t ver;
uint64_t master_ver;
string max_marker;
+ bool is_resharding;
+ string new_bucket_instance_id;
rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0) {}
void encode(bufferlist &bl) const {
- ENCODE_START(5, 2, bl);
+ ENCODE_START(6, 2, bl);
::encode(stats, bl);
::encode(tag_timeout, bl);
::encode(ver, bl);
::encode(master_ver, bl);
::encode(max_marker, bl);
+ ::encode(is_resharding, bl);
+ ::encode(new_bucket_instance_id, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator &bl) {
- DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
+ DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl);
::decode(stats, bl);
if (struct_v > 2) {
::decode(tag_timeout, bl);
if (struct_v >= 5) {
::decode(max_marker, bl);
}
+ if (struct_v >= 6) {
+ ::decode(is_resharding, bl);
+ ::decode(new_bucket_instance_id, bl);
+ } else {
+ is_resharding = false;
+ }
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;