]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add helper functions to apply configured default quotas
authorCasey Bodley <cbodley@redhat.com>
Wed, 19 Sep 2018 13:38:20 +0000 (09:38 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 11 Oct 2018 17:06:06 +0000 (13:06 -0400)
Resolves (with following): rhbz#1630870

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit ba83d0c0be3960e8f352c3058cb9a40020de02ae)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h
src/rgw/rgw_user.cc

index ce3d1265facd45b8ab2e210511553486e3a7feca..4212e9c8b9852f480193fc6e5c3acb1d14d06b7e 100644 (file)
@@ -1006,3 +1006,26 @@ void RGWQuotaHandler::free_handler(RGWQuotaHandler *handler)
 }
 
 
+void rgw_apply_default_bucket_quota(RGWQuotaInfo& quota, const CephContext* cct)
+{
+  if (cct->_conf->rgw_bucket_default_quota_max_objects >= 0) {
+    quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
+    quota.enabled = true;
+  }
+  if (cct->_conf->rgw_bucket_default_quota_max_size >= 0) {
+    quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
+    quota.enabled = true;
+  }
+}
+
+void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const CephContext* cct)
+{
+  if (cct->_conf->rgw_user_default_quota_max_objects >= 0) {
+    quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
+    quota.enabled = true;
+  }
+  if (cct->_conf->rgw_user_default_quota_max_size >= 0) {
+    quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
+    quota.enabled = true;
+  }
+}
index 49ec14871815c1ba43373e87379a349bcd7ac6dd..2f08d4a5d98c74996164c59b130787e1cbdeab7c 100644 (file)
@@ -114,4 +114,8 @@ public:
   static void free_handler(RGWQuotaHandler *handler);
 };
 
+// apply default quotas from configuration
+void rgw_apply_default_bucket_quota(RGWQuotaInfo& quota, const CephContext* cct);
+void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const CephContext* cct);
+
 #endif
index ae8fe1fff22bc8f6ce22973583a33cedf29d2a80..a27534807f7c74591139c980a10d172911c6335f 100644 (file)
@@ -23,6 +23,7 @@
 #include "rgw_common.h"
 
 #include "rgw_bucket.h"
+#include "rgw_quota.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -1991,14 +1992,7 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
   if (op_state.has_bucket_quota()) {
     user_info.bucket_quota = op_state.get_bucket_quota();
   } else {
-    if (cct->_conf->rgw_bucket_default_quota_max_objects >= 0) {
-      user_info.bucket_quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
-      user_info.bucket_quota.enabled = true;
-    }
-    if (cct->_conf->rgw_bucket_default_quota_max_size >= 0) {
-      user_info.bucket_quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
-      user_info.bucket_quota.enabled = true;
-    }
+    rgw_apply_default_bucket_quota(user_info.bucket_quota, cct);
   }
 
   if (op_state.temp_url_key_specified) {
@@ -2012,14 +2006,7 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
   if (op_state.has_user_quota()) {
     user_info.user_quota = op_state.get_user_quota();
   } else {
-    if (cct->_conf->rgw_user_default_quota_max_objects >= 0) {
-      user_info.user_quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
-      user_info.user_quota.enabled = true;
-    }
-    if (cct->_conf->rgw_user_default_quota_max_size >= 0) {
-      user_info.user_quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
-      user_info.user_quota.enabled = true;
-    }
+    rgw_apply_default_user_quota(user_info.user_quota, cct);
   }
 
   // update the request