DECODE_FINISH(bl);
}
+ void update_bucket_id(const string& new_bucket_id) {
+ bucket_id = new_bucket_id;
+ oid.clear();
+ }
+
// format a key for the bucket/instance. pass delim=0 to skip a field
std::string get_key(char tenant_delim = '/',
char id_delim = ':') const;
}
+int RGWRados::Bucket::update_bucket_id(const string& new_bucket_id)
+{
+ rgw_bucket bucket = bucket_info.bucket;
+ bucket.update_bucket_id(new_bucket_id);
+
+ RGWObjectCtx obj_ctx(store);
+
+ int ret = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, nullptr, nullptr);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return 0;
+}
+
/**
* get listing of the objects in a bucket.
*
return 0;
}
-int RGWRados::Bucket::update_bucket_id(const string& new_bucket_id)
-{
- rgw_bucket& bucket = bucket_info.bucket;
- bucket.bucket_id = new_bucket_id;
-
- int ret = get_bucket_instance_info(ctx, bucket, bucket_info, nullptr, nullptr);
- if (ret < 0) {
- return ret;
- }
- obj.bucket = bucket;
- bucket_shard.bucket = bucket;
- bs_initialized = false
-
- return 0;
-}
-
int RGWRados::Object::Read::get_attr(const char *name, bufferlist& dest)
{
RGWObjState *state;
int r;
-#define NUM_RESHARD_RETRIES 3
+#define NUM_RESHARD_RETRIES 10
for (int i = 0; i < NUM_RESHARD_RETRIES; ++i) {
BucketShard *bs;
RGWReshard reshard(store);
string new_bucket_id;
r = reshard.block_while_resharding(bs, &new_bucket_id);
- if (r != -EAGAIN) {
- if (r < 0) {
- return r;
- }
- r = target->update_bucket_id(new_bucket_id);
- break;
+ if (r == -ERR_BUSY_RESHARDING) {
+ continue;
+ }
+ if (r < 0) {
+ return r;
+ }
+ ldout(store->ctx(), 20) << "reshard completion identified, new_bucket_id=" << new_bucket_id << dendl;
+ i = 0; /* resharding is finished, make sure we can retry */
+ r = target->update_bucket_id(new_bucket_id);
+ if (r < 0) {
+ ldout(store->ctx(), 0) << "ERROR: update_bucket_id() new_bucket_id=" << new_bucket_id << " returned r=" << r << dendl;
+ return r;
}
+ invalidate_bs();
}
if (r < 0) {
RGWBucketInfo& get_bucket_info() { return bucket_info; }
int get_manifest(RGWObjManifest **pmanifest);
- void update_bucket_id(const string& new_bucket_id);
-
int get_bucket_shard(BucketShard **pbs) {
if (!bs_initialized) {
int r = bs.init(bucket_info.bucket, obj);
rgw_bucket& get_bucket() { return bucket; }
RGWBucketInfo& get_bucket_info() { return bucket_info; }
+ int update_bucket_id(const string& new_bucket_id);
+
int get_shard_id() { return shard_id; }
void set_shard_id(int id) {
shard_id = id;
return ret;
}
- ret = set_resharding_status(bucket_info.bucket.bucket_id, CLS_RGW_RESHARD_IN_PROGRESS);
+ ret = set_resharding_status(new_bucket_info.bucket.bucket_id, CLS_RGW_RESHARD_IN_PROGRESS);
if (ret < 0) {
unlock_bucket();
return ret;
return ret;
}
- ret = set_resharding_status(bucket_info.bucket.bucket_id, CLS_RGW_RESHARD_DONE);
+ ret = set_resharding_status(new_bucket_info.bucket.bucket_id, CLS_RGW_RESHARD_DONE);
if (ret < 0) {
unlock_bucket();
return ret;
sleep(default_reshard_sleep_duration);
}
ldout(store->ctx(), 0) << "RGWReshard::" << __func__ << " ERROR: bucket is still resharding, please retry" << dendl;
- return -EAGAIN;
+ return -ERR_BUSY_RESHARDING;
}
BucketIndexLockGuard::BucketIndexLockGuard(CephContext *_cct, RGWRados* _store, const string& bucket_instance_id, const string& _oid, const librados::IoCtx& _io_ctx) :