]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: simplify a code path 1138/head
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 24 Jan 2014 23:33:57 +0000 (15:33 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 24 Jan 2014 23:33:57 +0000 (15:33 -0800)
remove some duplicate code.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_quota.cc

index 7a967cbe88a066b29a1d3ff290c89d0957fde86d..6487b1f8badbe98b0093c07bb4514078f4fb0115 100644 (file)
@@ -694,35 +694,34 @@ public:
   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)
+      return 0;
+
     uint64_t size_kb = rgw_rounded_objsize_kb(size);
 
-    if (bucket_quota.enabled) {
-      RGWStorageStats bucket_stats;
+    RGWStorageStats bucket_stats;
 
-      int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, bucket_quota);
-      if (ret < 0)
-        return ret;
+    /*
+     * 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);
       if (ret < 0)
         return ret;
-    } else if (user_quota.enabled) {
-      /*
-       * 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
-       */
-      RGWStorageStats bucket_stats;
-
-      int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, bucket_quota);
-      if (ret < 0)
-        return ret;
     }
 
     if (user_quota.enabled) {
       RGWStorageStats user_stats;
 
-      int ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota);
+      ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota);
       if (ret < 0)
         return ret;