]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: modify bucket quota procedures to accomodate account quota as well.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 9 May 2016 16:37:57 +0000 (18:37 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 30 May 2016 09:42:56 +0000 (11:42 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_common.h
src/rgw/rgw_op.cc

index 677f83cc5ffc79be1d660f2143e28bef24d06d87..b3a5057df6a07313720b65ac02099cab1fe16f92 100644 (file)
@@ -88,9 +88,9 @@ using ceph::crypto::MD5;
 #define RGW_ATTR_TEMPURL_KEY1   RGW_ATTR_META_PREFIX "temp-url-key"
 #define RGW_ATTR_TEMPURL_KEY2   RGW_ATTR_META_PREFIX "temp-url-key-2"
 
-/* Container quota of the Swift API. */
-#define RGW_ATTR_CQUOTA_NOBJS   RGW_ATTR_META_PREFIX "quota-count"
-#define RGW_ATTR_CQUOTA_MSIZE   RGW_ATTR_META_PREFIX "quota-bytes"
+/* Account/container quota of the Swift API. */
+#define RGW_ATTR_QUOTA_NOBJS    RGW_ATTR_META_PREFIX "quota-count"
+#define RGW_ATTR_QUOTA_MSIZE    RGW_ATTR_META_PREFIX "quota-bytes"
 
 #define RGW_ATTR_OLH_PREFIX     RGW_ATTR_PREFIX "olh."
 
index 690d8f240b0035b3cbb20f165a6db128f06c262c..99297c9038b59abf40660f17ff49ac3a99e29f85 100644 (file)
@@ -1912,12 +1912,12 @@ static void populate_with_generic_attrs(const req_state * const s,
 }
 
 
-static int filter_out_bucket_quota(std::map<std::string, bufferlist>& add_attrs,
-                                   const std::set<std::string>& rmattr_names,
-                                   RGWQuotaInfo& quota)
+static int filter_out_quota_info(std::map<std::string, bufferlist>& add_attrs,
+                                 const std::set<std::string>& rmattr_names,
+                                 RGWQuotaInfo& quota)
 {
   /* Put new limit on max objects. */
-  auto iter = add_attrs.find(RGW_ATTR_CQUOTA_NOBJS);
+  auto iter = add_attrs.find(RGW_ATTR_QUOTA_NOBJS);
   std::string err;
   if (std::end(add_attrs) != iter) {
     quota.max_objects =
@@ -1929,7 +1929,7 @@ static int filter_out_bucket_quota(std::map<std::string, bufferlist>& add_attrs,
   }
 
   /* Put new limit on bucket (container) size. */
-  iter = add_attrs.find(RGW_ATTR_CQUOTA_MSIZE);
+  iter = add_attrs.find(RGW_ATTR_QUOTA_MSIZE);
   if (iter != add_attrs.end()) {
     quota.max_size =
       static_cast<int64_t>(strict_strtoll(iter->second.c_str(), 10, &err));
@@ -1941,12 +1941,12 @@ static int filter_out_bucket_quota(std::map<std::string, bufferlist>& add_attrs,
 
   for (const auto& name : rmattr_names) {
     /* Remove limit on max objects. */
-    if (name.compare(RGW_ATTR_CQUOTA_NOBJS) == 0) {
+    if (name.compare(RGW_ATTR_QUOTA_NOBJS) == 0) {
       quota.max_objects = -1;
     }
 
     /* Remove limit on max bucket size. */
-    if (name.compare(RGW_ATTR_CQUOTA_MSIZE) == 0) {
+    if (name.compare(RGW_ATTR_QUOTA_MSIZE) == 0) {
       quota.max_size = -1;
     }
   }
@@ -2069,7 +2069,7 @@ void RGWCreateBucket::execute()
     prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs);
     populate_with_generic_attrs(s, attrs);
 
-    op_ret = filter_out_bucket_quota(attrs, rmattr_names, quota_info);
+    op_ret = filter_out_quota_info(attrs, rmattr_names, quota_info);
     if (op_ret < 0) {
       return;
     }
@@ -2150,7 +2150,7 @@ void RGWCreateBucket::execute()
       rgw_get_request_metadata(s->cct, s->info, attrs, false);
       prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs);
       populate_with_generic_attrs(s, attrs);
-      op_ret = filter_out_bucket_quota(attrs, rmattr_names, s->bucket_info.quota);
+      op_ret = filter_out_quota_info(attrs, rmattr_names, s->bucket_info.quota);
       if (op_ret < 0) {
         return;
       }
@@ -2972,7 +2972,7 @@ void RGWPutMetadataBucket::execute()
    * implementation: anyone with write permissions is able to set the bucket
    * quota. This stays in contrast to account quotas that can be set only by
    * clients holding reseller admin privileges. */
-  op_ret = filter_out_bucket_quota(attrs, rmattr_names, s->bucket_info.quota);
+  op_ret = filter_out_quota_info(attrs, rmattr_names, s->bucket_info.quota);
   if (op_ret < 0) {
     return;
   }