From dfdc2b2cc0c4b2859d26b1d91c3ae9d5bab714e1 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Sun, 14 May 2017 09:05:49 +0300 Subject: [PATCH] rgw: remove cct from RGWReshard and BucketIndexLockGuard Signed-off-by: Orit Wasserman --- src/rgw/rgw_admin.cc | 1 + src/rgw/rgw_rados.cc | 8 ++++++++ src/rgw/rgw_reshard.cc | 11 +++++------ src/rgw/rgw_reshard.h | 3 +-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 3a49fb637a98f..ab14c950a414e 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -5628,6 +5628,7 @@ next: return 0; } + if (opt_cmd == OPT_RESHARD_STATUS) { if (bucket_name.empty()) { cerr << "ERROR: bucket not specified" << std::endl; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 90b3f040afbe4..c49c3391bd1f6 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -10809,12 +10809,20 @@ int RGWRados::bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjStat 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); diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 67ffe30f311fe..d91367cf3e4a1 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -481,7 +481,6 @@ RGWReshard::RGWReshard(RGWRados* _store): store(_store), instance_lock(bucket_in 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); @@ -755,9 +754,9 @@ void RGWReshard::ReshardWorker::stop() 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) { @@ -768,7 +767,7 @@ int BucketIndexLockGuard::lock() 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) { @@ -777,7 +776,7 @@ int BucketIndexLockGuard::lock() locked = true; return ret; } else { - ldout(cct,0) << " % alread lock" << oid << dendl; + ldout(store->ctx(), 0) << " % alread lock" << oid << dendl; return -EBUSY; } } @@ -787,7 +786,7 @@ int BucketIndexLockGuard::unlock() 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; } diff --git a/src/rgw/rgw_reshard.h b/src/rgw/rgw_reshard.h index 50c9a784592ff..3c146f6fe74ea 100644 --- a/src/rgw/rgw_reshard.h +++ b/src/rgw/rgw_reshard.h @@ -16,7 +16,6 @@ class RGWRados; /* gets a locked lock , release it when exiting context */ class BucketIndexLockGuard { - CephContext *cct; RGWRados *store; rados::cls::lock::Lock l; string oid; @@ -24,7 +23,7 @@ class BucketIndexLockGuard 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(); -- 2.39.5