]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use the same lock when resharding
authorOrit Wasserman <owasserm@redhat.com>
Fri, 21 Sep 2018 13:26:41 +0000 (16:26 +0300)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 29 Nov 2018 12:03:59 +0000 (13:03 +0100)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
(cherry picked from commit 173bfc87544e4f349e2d51e8e34acb83c6067897)

src/rgw/rgw_reshard.cc
src/rgw/rgw_reshard.h

index 76f5b76e659adb4d9bf4f825ce7858d9e8de2c8b..b2f53bf1e4a0b9a6711f223418ea9693c2023c48 100644 (file)
@@ -206,6 +206,14 @@ RGWBucketReshard::RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucke
   reshard_lock.set_duration(lock_duration);
 }
 
+RGWBucketReshard::RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucket_info, const map<string, bufferlist>& _bucket_attrs, rados::cls::lock::Lock& _reshard_lock, const utime_t& _lock_start_time) :
+                                                     store(_store), bucket_info(_bucket_info), bucket_attrs(_bucket_attrs),
+                                                     reshard_lock(_reshard_lock), lock_start_time(_lock_start_time), locked_bucket(true)
+{
+  const rgw_bucket& b = bucket_info.bucket;
+  reshard_oid = b.tenant + (b.tenant.empty() ? "" : ":") + b.name + ":" + b.bucket_id;
+}
+
 int RGWBucketReshard::lock_bucket()
 {
   int ret = reshard_lock.lock_exclusive(&store->reshard_pool_ctx, reshard_oid);
@@ -807,7 +815,7 @@ int RGWReshard::process_single_logshard(int logshard_num)
 
   CephContext *cct = store->ctx();
   int max_entries = 1000;
-  int max_secs = 60;
+  int max_secs = store->ctx()->_conf->rgw_reshard_bucket_lock_duration;
 
   rados::cls::lock::Lock l(reshard_lock_name);
 
@@ -856,7 +864,7 @@ int RGWReshard::process_single_logshard(int logshard_num)
          return -ret;
        }
 
-       RGWBucketReshard br(store, bucket_info, attrs);
+       RGWBucketReshard br(store, bucket_info, attrs, l, lock_start_time);
 
        Formatter* formatter = new JSONFormatter(false);
        auto formatter_ptr = std::unique_ptr<Formatter>(formatter);
@@ -875,6 +883,12 @@ int RGWReshard::process_single_logshard(int logshard_num)
                       << cpp_strerror(-ret) << dendl;
          return ret;
        }
+       ret = br.renew_lock_bucket();
+       if (ret < 0) {
+         ldout(cct, 0)<< __func__ << ":Error renewing bucket " << entry.bucket_name << " lock: "
+                      << cpp_strerror(-ret) << dendl;
+         return ret;
+       }
       }
       utime_t now = ceph_clock_now();
 
index 277dfc410ec34c3ebc773d3b4b7f67562f6e8843..6506f830b28d4647f90faac99eb1a3ac0110177f 100644 (file)
@@ -43,6 +43,10 @@ public:
   RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucket_info,
                    const std::map<string, bufferlist>& _bucket_attrs);
 
+  RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucket_info,
+                   const std::map<string, bufferlist>& _bucket_attrs,
+                  rados::cls::lock::Lock& reshard_lock, const utime_t& lock_start_time);
+
   int execute(int num_shards, int max_op_entries,
               bool verbose = false, ostream *out = nullptr,
               Formatter *formatter = nullptr,