]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add a check_bucket_shards to the quota
authorOrit Wasserman <owasserm@redhat.com>
Thu, 18 May 2017 04:01:35 +0000 (07:01 +0300)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:50 +0000 (13:17 -0700)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/common/config_opts.h
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index ac95b1540d4d42d94e818c96c7c283aed35afb29..0502a8b1f56969d111fdaf1441569e975347ec58 100644 (file)
@@ -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)
index 6a61400a1101a8798b42845b20c5e56a70346ba8..55dc64a0a72c04ac962194acbf3f575741e198bc 100644 (file)
@@ -939,6 +939,29 @@ public:
     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;
+  }
+
 };
 
 
@@ -951,3 +974,5 @@ void RGWQuotaHandler::free_handler(RGWQuotaHandler *handler)
 {
   delete handler;
 }
+
+
index 9291434634cc8480f9bb86b864101225101d2ce1..b542c603eea2cfcf82d28368da73d6312b07e1f8 100644 (file)
@@ -103,6 +103,10 @@ public:
                           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);
index f6d11f239e902bc51d06372c5400bd7cad60ddbd..bb3e34a26eaf0103f8c4c267a79c7ceee5f09f90 100644 (file)
@@ -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)
 {
index 3b7f5a362e84c0638c12c37f9afecde960a0f27f..d9d670657551f02020472851f4cfe017290dd76d 100644 (file)
@@ -3479,6 +3479,10 @@ public:
   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();