From dfd6240789ff3e182138b88c6f7bc6dea532d6f7 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Fri, 21 Sep 2018 16:26:41 +0300 Subject: [PATCH] rgw: use the same lock when resharding Signed-off-by: Orit Wasserman (cherry picked from commit 173bfc87544e4f349e2d51e8e34acb83c6067897) --- src/rgw/rgw_reshard.cc | 18 ++++++++++++++++-- src/rgw/rgw_reshard.h | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 76f5b76e659ad..b2f53bf1e4a0b 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -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& _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); @@ -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(); diff --git a/src/rgw/rgw_reshard.h b/src/rgw/rgw_reshard.h index 277dfc410ec34..6506f830b28d4 100644 --- a/src/rgw/rgw_reshard.h +++ b/src/rgw/rgw_reshard.h @@ -43,6 +43,10 @@ public: RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucket_info, const std::map& _bucket_attrs); + RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucket_info, + const std::map& _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, -- 2.39.5