So that we can differentiate between in-progress and complete status.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
return rc;
}
- header.new_instance.set(op.entry.new_bucket_instance_id);
+ header.new_instance.set_status(op.entry.new_bucket_instance_id, op.entry.reshard_status);
return write_bucket_header(hctx, &header);
}
void cls_rgw_bucket_instance_entry::dump(Formatter *f) const
{
- encode_json("resharding", resharding, f);
+ encode_json("reshard_status", (int)reshard_status, f);
encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
}
{
ls.push_back(new cls_rgw_bucket_instance_entry);
ls.push_back(new cls_rgw_bucket_instance_entry);
- ls.back()->resharding = true;
+ ls.back()->reshard_status = CLS_RGW_RESHARD_IN_PROGRESS;
ls.back()->new_bucket_instance_id = "new_instance_id";
}
};
WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
+enum cls_rgw_reshard_status {
+ CLS_RGW_RESHARD_NONE = 0,
+ CLS_RGW_RESHARD_IN_PROGRESS = 1,
+ CLS_RGW_RESHARD_DONE = 2,
+};
+
struct cls_rgw_bucket_instance_entry {
- bool resharding{false};
+ cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NONE};
string new_bucket_instance_id;
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- ::encode(resharding, bl);
+ ::encode((uint8_t)reshard_status, bl);
::encode(new_bucket_instance_id, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START(1, bl);
- ::decode(resharding, bl);
+ uint8_t s;
+ ::decode(s, bl);
+ reshard_status = (cls_rgw_reshard_status)s;
::decode(new_bucket_instance_id, bl);
DECODE_FINISH(bl);
}
static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
void clear() {
- resharding = false;
+ reshard_status = CLS_RGW_RESHARD_NONE;
new_bucket_instance_id.clear();
}
- void set(const string& new_instance_id) {
- resharding = true;
+ void set_status(const string& new_instance_id, cls_rgw_reshard_status s) {
+ reshard_status = s;
new_bucket_instance_id = new_instance_id;
}
+
+ bool resharding() const {
+ return reshard_status != CLS_RGW_RESHARD_NONE;
+ }
};
WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
static void generate_test_instances(list<rgw_bucket_dir_header*>& o);
bool resharding() const {
- return new_instance.resharding;
+ return new_instance.resharding();
}
};
WRITE_CLASS_ENCODER(rgw_bucket_dir_header)
}
cls_rgw_bucket_instance_entry instance_entry;
- instance_entry.set(new_instance_id);
+ instance_entry.set_status(new_instance_id, CLS_RGW_RESHARD_IN_PROGRESS);
int ret = store->bucket_set_reshard(bucket_info, instance_entry);
if (ret < 0) {
const int num_retries = 10;
const int default_reshard_sleep_duration = 30;
-int RGWReshard::block_while_resharding(const string& bucket_instance_oid,
- BucketIndexLockGuard& guard)
+int RGWReshard::block_while_resharding(const string& bucket_instance_oid)
{
int ret = 0;
cls_rgw_bucket_instance_entry entry;
for (int i=0; i< num_retries;i++) {
- ret = guard.lock();
- if (ret < 0) {
- return ret;
- }
-
ret = cls_rgw_get_bucket_resharding(store->reshard_pool_ctx, bucket_instance_oid, &entry);
if (ret < 0) {
ldout(store->ctx(), 0) << "RGWReshard::" << __func__ << " ERROR: failed to get bucket resharding :" <<
cpp_strerror(-ret)<< dendl;
return ret;
}
-
- ret = guard.unlock();
- if (ret < 0) {
- return ret;
- }
- if (!entry.resharding) {
+ if (!entry.resharding()) {
return 0;
}
/* needed to unlock as clear resharding uses the same lock */
+#warning replace sleep with interruptible condition
sleep(default_reshard_sleep_duration);
}
ldout(store->ctx(), 0) << "RGWReshard::" << __func__ << " ERROR: bucket is still resharding, please retry" << dendl;
if succefull, keeps the bucket index locked. It will be unlocked
in the guard dtor.
*/
- int block_while_resharding(const string& bucket_instance_oid, BucketIndexLockGuard& guard);
+ int block_while_resharding(const string& bucket_instance_oid);
};
#endif