ldout(s->cct, 20) << "check_quota() returned ret=" << op_ret << dendl;
goto done;
}
- bool need_resharding = false;
- op_ret = store->check_bucket_shards(s->bucket_owner.get_id(), s->bucket,
- bucket_quota, s->bucket_info.num_shards, need_resharding);
+ op_ret = store->check_bucket_shards(s->bucket_info, s->bucket, bucket_quota);
if (op_ret < 0) {
ldout(s->cct, 20) << "check_bucket_shards() returned ret=" << op_ret << dendl;
goto done;
- } else if (need_resharding) {
- /* Add to resharding queue */
- ldout(s->cct, 20) << s->bucket << " needs resharding " << dendl;
}
}
return 0;
}
-int RGWRados::check_bucket_shards(const rgw_user& bucket_owner, rgw_bucket& bucket,
- RGWQuotaInfo& bucket_quota, uint64_t num_shards, bool& need_resharding)
+int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, rgw_bucket& bucket,
+ RGWQuotaInfo& bucket_quota)
{
if (!cct->_conf->rgw_dynamic_resharding) {
return 0;
}
- return quota_handler->check_bucket_shards((uint64_t)cct->_conf->rgw_max_objs_per_shard, num_shards,
- bucket_owner, bucket, bucket_quota, 1, need_resharding);
+ bool need_resharding = false;
+ int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+
+ int ret = quota_handler->check_bucket_shards((uint64_t)cct->_conf->rgw_max_objs_per_shard,
+ num_source_shards, bucket_info.owner, bucket, bucket_quota,
+ 1, need_resharding);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (need_resharding) {
+ return add_bucket_to_reshard(bucket_info);
+ }
+
+ return ret;
}
int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info)
int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket,
RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size);
- int check_bucket_shards(const rgw_user& bucket_owner, rgw_bucket& bucket,
- RGWQuotaInfo& bucket_quota, uint64_t num_shards,
- bool& need_resharding);
+ int check_bucket_shards(const RGWBucketInfo& bucket_info, rgw_bucket& bucket,
+ RGWQuotaInfo& bucket_quota);
int add_bucket_to_reshard(const RGWBucketInfo& bucket_info);