]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove cct from RGWReshard and BucketIndexLockGuard
authorOrit Wasserman <owasserm@redhat.com>
Sun, 14 May 2017 06:05:49 +0000 (09:05 +0300)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:49 +0000 (13:17 -0700)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_reshard.cc
src/rgw/rgw_reshard.h

index 3a49fb637a98f04483671e88e4f075780ab32bed..ab14c950a414e6459c98fc682533eea2db3979ee 100644 (file)
@@ -5628,6 +5628,7 @@ next:
     return 0;
   }
 
+
   if (opt_cmd == OPT_RESHARD_STATUS) {
     if (bucket_name.empty()) {
       cerr << "ERROR: bucket not specified" << std::endl;
index 90b3f040afbe4d7f7322ccc0ba4f085db961253c..c49c3391bd1f6836894e9df2e73a9b8d57a185e9 100644 (file)
@@ -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);
index 67ffe30f311fed78246b2306e4c8050b972f7cb3..d91367cf3e4a126520658e1c826180b603c2ee4e 100644 (file)
@@ -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;
     }
index 50c9a784592ff551a779481bb21fc7db243a7aa3..3c146f6fe74eaa6932a87ce855010d0a77acda98 100644 (file)
@@ -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();