From: Yehuda Sadeh Date: Tue, 23 May 2017 00:10:14 +0000 (-0700) Subject: rgw: remove unneeded and duplicate code X-Git-Tag: ses5-milestone6~8^2~7^2~22 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=81693efd7810163c5f65ae4fbbfa698e2cc90715;p=ceph.git rgw: remove unneeded and duplicate code Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 8a8791e273801..5bdf32d0afbe7 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -721,12 +721,10 @@ int RGWReshard::process_single_logshard(int logshard_num) return ret; } - Formatter* formatter = new JSONFormatter(false); - auto formatter_ptr = std::unique_ptr(formatter); - RGWBucketAdminOpState bucket_op; - ret = reshard_bucket(formatter, entry.new_num_shards, bucket, bucket_info, new_bucket_info, - max_entries, bucket_op, true); - formatter->flush(cout); + RGWBucketAdminOpState bucket_op; + RGWBucketReshard reshard_op(store, bucket_info, attrs); + ret = reshard_op.do_reshard(entry.new_num_shards, new_bucket_info, + max_entries, false, nullptr, nullptr); if (ret < 0) { return ret; } @@ -836,50 +834,3 @@ void RGWReshard::ReshardWorker::stop() Mutex::Locker l(lock); cond.Signal(); } - -#if 0 -BucketIndexLockGuard::BucketIndexLockGuard(RGWRados* _store, - const string& bucket_instance_id, const string& _oid, const librados::IoCtx& _io_ctx) : - store(_store), - l(create_bucket_index_lock_name(bucket_instance_id)), - oid(_oid), io_ctx(_io_ctx),locked(false) -{ -} - -int BucketIndexLockGuard::lock() -{ - if (!locked) { - int ret = l.lock_shared(&store->reshard_pool_ctx, oid); - if (ret == -EBUSY) { - ldout(store->ctx(), 0) << "RGWReshardLog::add failed to acquire lock on " << oid << dendl; - return 0; - } - if (ret < 0) { - return ret; - } - locked = true; - return ret; - } else { - ldout(store->ctx(), 0) << " % alread lock" << oid << dendl; - return -EBUSY; - } -} - -int BucketIndexLockGuard::unlock() -{ - if (locked) { - int ret = l.unlock(&io_ctx, oid); - if (ret <0) { - ldout(store->ctx(), 0) << "failed to unlock " << oid << dendl; - } else { - locked = false; - } - return ret; - } - return 0; -} - -BucketIndexLockGuard::~BucketIndexLockGuard() -{ - unlock(); -} diff --git a/src/rgw/rgw_reshard.h b/src/rgw/rgw_reshard.h index 8c1b393050c3c..2010ac4a478ce 100644 --- a/src/rgw/rgw_reshard.h +++ b/src/rgw/rgw_reshard.h @@ -14,30 +14,9 @@ class CephContext; class RGWRados; -#if 0 -/* gets a locked lock , release it when exiting context */ -class BucketIndexLockGuard -{ - RGWRados *store; - rados::cls::lock::Lock l; - string oid; - librados::IoCtx io_ctx; - bool locked; - -public: - BucketIndexLockGuard(RGWRados* store, const string& bucket_instance_id, - const string& oid, const librados::IoCtx& io_ctx); - /* unlocks the lock */ - ~BucketIndexLockGuard(); -protected: +class RGWBucketReshard { friend class RGWReshard; - int lock(); - int unlock(); -}; -#endif - -class RGWBucketReshard { RGWRados *store; RGWBucketInfo bucket_info; std::map bucket_attrs; @@ -109,15 +88,6 @@ public: int list(int logshard_num, string& marker, uint32_t max, std::list& entries, bool *is_truncated); int clear_bucket_resharding(const string& bucket_instance_oid, cls_rgw_reshard_entry& entry); - int reshard_bucket(Formatter *formatter, - int num_shards, - rgw_bucket& bucket, - RGWBucketInfo& bucket_info, - RGWBucketInfo& new_bucket_info, - int max_entries, - RGWBucketAdminOpState& bucket_op, - bool verbose = false); - /* reshard thread */ int process_single_logshard(int logshard_num); int process_all_logshards();