return r;
}
+
rgw_zone_set zones_trace;
if (_zones_trace) {
zones_trace = *_zones_trace;
}
else {
zones_trace.insert(get_zone().id);
+
+ /* handle on going bucket resharding */
+ BucketIndexLockGuard guard(this, bucket_info.bucket.bucket_id, bucket_info.bucket.oid,
+ reshard_pool_ctx);
+ r = reshard->block_while_resharding(bucket_info.bucket.oid, guard);
+ if (r < 0) {
+ return r;
}
BucketShard bs(this);
max_jobs = store->ctx()->_conf->rgw_reshard_max_jobs;
}
-
int RGWReshard::add(cls_rgw_reshard_entry& entry)
{
rados::cls::lock::Lock l(reshard_lock_name);
cond.Signal();
}
-BucketIndexLockGuard::BucketIndexLockGuard(CephContext* _cct, RGWRados* _store,
+BucketIndexLockGuard::BucketIndexLockGuard(RGWRados* _store,
const string& bucket_instance_id, const string& _oid, const librados::IoCtx& _io_ctx) :
- cct(_cct),store(_store),
+ store(_store),
l(create_bucket_index_lock_name(bucket_instance_id)),
oid(_oid), io_ctx(_io_ctx),locked(false)
{
if (!locked) {
int ret = l.lock_shared(&store->reshard_pool_ctx, oid);
if (ret == -EBUSY) {
- ldout(cct,0) << "RGWReshardLog::add failed to acquire lock on " << oid << dendl;
+ ldout(store->ctx(), 0) << "RGWReshardLog::add failed to acquire lock on " << oid << dendl;
return 0;
}
if (ret < 0) {
locked = true;
return ret;
} else {
- ldout(cct,0) << " % alread lock" << oid << dendl;
+ ldout(store->ctx(), 0) << " % alread lock" << oid << dendl;
return -EBUSY;
}
}
if (locked) {
int ret = l.unlock(&io_ctx, oid);
if (ret <0) {
- ldout(cct, 0) << "failed to unlock " << oid << dendl;
+ ldout(store->ctx(), 0) << "failed to unlock " << oid << dendl;
} else {
locked = false;
}
/* gets a locked lock , release it when exiting context */
class BucketIndexLockGuard
{
- CephContext *cct;
RGWRados *store;
rados::cls::lock::Lock l;
string oid;
bool locked;
public:
- BucketIndexLockGuard(CephContext* cct, RGWRados* store, const string& bucket_instance_id,
+ BucketIndexLockGuard(RGWRados* store, const string& bucket_instance_id,
const string& oid, const librados::IoCtx& io_ctx);
/* unlocks the lock */
~BucketIndexLockGuard();