return ret;
}
- Formatter* formatter = new JSONFormatter(false);
- auto formatter_ptr = std::unique_ptr<Formatter>(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;
}
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();
-}
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<string, bufferlist> bucket_attrs;
int list(int logshard_num, string& marker, uint32_t max, std::list<cls_rgw_reshard_entry>& 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();