]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Do not bother to check against conf values during quota handling
authorroot <root@ceph-node1.homeoffice.wal-mart.com>
Sun, 19 Jun 2016 07:18:42 +0000 (12:48 +0530)
committerOrit Wasserman <owasserm@redhat.com>
Tue, 30 Aug 2016 08:24:05 +0000 (10:24 +0200)
Fixes http://tracker.ceph.com/issues/16447
Cherry picked from 17d2c1712a5b72315a47ab0f8380331bfd478c0b

This was modified to use size in kB, rather than size in bytes, since
Jewel has not yet been converted to use size in bytes.

Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
(cherry picked from commit c85e9d4e1e3f367150314c08995c7a4d418910ff)

src/rgw/rgw_quota.cc

index 70f45cb2172de884dc5b5b548c007172991c4a73..58e449302a27a688b59a389a1f75aff70c32df9d 100644 (file)
@@ -692,73 +692,45 @@ class RGWQuotaHandlerImpl : public RGWQuotaHandler {
     return 0;
   }
 public:
-  RGWQuotaHandlerImpl(RGWRados *_store, bool quota_threads) : store(_store), bucket_stats_cache(_store), user_stats_cache(_store, quota_threads) {
-    if (store->ctx()->_conf->rgw_bucket_default_quota_max_objects >= 0) {
-      def_bucket_quota.max_objects = store->ctx()->_conf->rgw_bucket_default_quota_max_objects;
-      def_bucket_quota.enabled = true;
-    }
-    if (store->ctx()->_conf->rgw_bucket_default_quota_max_size >= 0) {
-      def_bucket_quota.max_size_kb = store->ctx()->_conf->rgw_bucket_default_quota_max_size;
-      def_bucket_quota.enabled = true;
-    }
-    if (store->ctx()->_conf->rgw_user_default_quota_max_objects >= 0) {
-      def_user_quota.max_objects = store->ctx()->_conf->rgw_user_default_quota_max_objects;
-      def_user_quota.enabled = true;
-    }
-    if (store->ctx()->_conf->rgw_user_default_quota_max_size >= 0) {
-      def_user_quota.max_size_kb = store->ctx()->_conf->rgw_user_default_quota_max_size;
-      def_user_quota.enabled = true;
-    }
-  }
+  RGWQuotaHandlerImpl(RGWRados *_store, bool quota_threads) : store(_store),
+                                    bucket_stats_cache(_store),
+                                    user_stats_cache(_store, quota_threads) {}
+
   virtual int check_quota(const string& user, rgw_bucket& bucket,
                           RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota,
                          uint64_t num_objs, uint64_t size) {
 
-    if (!bucket_quota.enabled && !user_quota.enabled && !def_bucket_quota.enabled && !def_user_quota.enabled)
+    if (!bucket_quota.enabled && !user_quota.enabled)
       return 0;
 
     uint64_t size_kb = rgw_rounded_objsize_kb(size);
 
-    RGWStorageStats bucket_stats;
-
     /*
      * we need to fetch bucket stats if the user quota is enabled, because the whole system relies
      * on us periodically updating the user's bucket stats in the user's header, this happens in
      * get_stats() if we actually fetch that info and not rely on cached data
      */
 
-    int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, bucket_quota);
-    if (ret < 0)
-      return ret;
-
     if (bucket_quota.enabled) {
-      ret = check_quota("bucket", bucket_quota, bucket_stats, num_objs, size_kb);
+      RGWStorageStats bucket_stats;
+      int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, bucket_quota);
       if (ret < 0)
         return ret;
-    }
 
-    if (def_bucket_quota.enabled) {
-      ret = check_quota("def_bucket", def_bucket_quota, bucket_stats, num_objs, size_kb);
+      ret = check_quota("bucket", bucket_quota, bucket_stats, num_objs, size_kb);
       if (ret < 0)
-        return ret;
+       return ret;
     }
 
-    if (user_quota.enabled || def_user_quota.enabled) {
+    if (user_quota.enabled) {
       RGWStorageStats user_stats;
-
-      ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota);
+      int ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota);
       if (ret < 0)
         return ret;
 
-      if (user_quota.enabled) {
-       ret = check_quota("user", user_quota, user_stats, num_objs, size_kb);
-       if (ret < 0)
-         return ret;
-      } else if (def_user_quota.enabled) {
-        ret = check_quota("def_user", def_user_quota, user_stats, num_objs, size_kb);
-        if (ret < 0)
-          return ret;
-      }
+      ret = check_quota("user", user_quota, user_stats, num_objs, size_kb);
+      if (ret < 0)
+       return ret;
     }
 
     return 0;