Skip to content

Commit

Permalink
rgw: add a check_bucket_shards to the quota
Browse files Browse the repository at this point in the history
Signed-off-by: Orit Wasserman <[email protected]>
  • Loading branch information
oritwas authored and yehudasa committed Jun 5, 2017
1 parent 1ed76a6 commit 553bf4b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -1735,3 +1735,5 @@ OPTION(rgw_swift_custom_header, OPT_STR, "") // option to enable swift custom he
/* resharding tunables */
OPTION(rgw_reshard_max_jobs, OPT_INT, 1024)
OPTION(rgw_reshard_bucket_lock_duration, OPT_INT, 120) // duration of lock on bucket obj during resharding
OPTION(rgw_dynamic_resharding, OPT_BOOL, true)
OPTION(rgw_max_objs_per_shard, OPT_INT, 100000)
25 changes: 25 additions & 0 deletions src/rgw/rgw_quota.cc
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,29 @@ class RGWQuotaHandlerImpl : public RGWQuotaHandler {
bucket_stats_cache.adjust_stats(user, bucket, obj_delta, added_bytes, removed_bytes);
user_stats_cache.adjust_stats(user, bucket, obj_delta, added_bytes, removed_bytes);
}

int check_bucket_shards(uint64_t max_objs_per_shard, uint64_t num_shards,
const rgw_user& user, rgw_bucket& bucket, RGWQuotaInfo& bucket_quota,
uint64_t num_objs, bool& need_resharding)
{
RGWStorageStats bucket_stats;
int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats,
bucket_quota);
if (ret < 0) {
return ret;
}

if (bucket_stats.num_objects + num_objs > num_shards * max_objs_per_shard) {
dout(10) << "resharding needed: stats.num_objects=" << bucket_stats.num_objects
<< " shard max_objects=" << max_objs_per_shard * num_shards << dendl;
need_resharding = true;
} else {
need_resharding = false;
}

return 0;
}

};


Expand All @@ -951,3 +974,5 @@ void RGWQuotaHandler::free_handler(RGWQuotaHandler *handler)
{
delete handler;
}


4 changes: 4 additions & 0 deletions src/rgw/rgw_quota.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class RGWQuotaHandler {
RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota,
uint64_t num_objs, uint64_t size) = 0;

virtual int check_bucket_shards(uint64_t max_objs_per_shard, uint64_t num_shards,
const rgw_user& bucket_owner, rgw_bucket& bucket,
RGWQuotaInfo& bucket_quota, uint64_t num_objs, bool& need_resharding) = 0;

virtual void update_stats(const rgw_user& bucket_owner, rgw_bucket& bucket, int obj_delta, uint64_t added_bytes, uint64_t removed_bytes) = 0;

static RGWQuotaHandler *generate_handler(RGWRados *store, bool quota_threads);
Expand Down
12 changes: 12 additions & 0 deletions src/rgw/rgw_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13080,6 +13080,18 @@ int RGWRados::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bu
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)
{
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);
}


int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket,
RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size)
{
Expand Down
4 changes: 4 additions & 0 deletions src/rgw/rgw_rados.h
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,10 @@ class RGWRados
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);

uint64_t instance_id();
const string& zone_id() {
return get_zone_params().get_id();
Expand Down

0 comments on commit 553bf4b

Please sign in to comment.