]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: user_quota and bucket_quota are defined under RGWQuota 46033/head
authorIqbal Khan <iqkhan@redhat.com>
Thu, 28 Apr 2022 18:54:29 +0000 (00:24 +0530)
committerIqbal Khan <iqkhan@redhat.com>
Wed, 4 May 2022 16:20:10 +0000 (21:50 +0530)
struct RGWQuota {
      RGWQuotaInfo user_quota;
      RGWQuotaInfo bucket_quota;
};

Signed-off-by: Iqbal Khan <iqkhan@redhat.com>
30 files changed:
src/rgw/rgw_admin.cc
src/rgw/rgw_auth.cc
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_cr_tools.cc
src/rgw/rgw_file.cc
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_config.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_user.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_dbstore.cc
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_motr.cc
src/rgw/rgw_sal_motr.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h
src/rgw/rgw_user.cc
src/rgw/rgw_user.h
src/rgw/rgw_zone.cc
src/rgw/rgw_zone.h
src/rgw/services/svc_quota.cc
src/rgw/services/svc_zone.cc
src/rgw/store/dbstore/sqlite/sqliteDB.cc

index 08054c9f77c38c3a0cd083de809d589145f9eb48..a9e668f32f6c18fc7a0a2f5415fb37ef24bb25c6 100644 (file)
@@ -1540,9 +1540,9 @@ int set_user_bucket_quota(OPT opt_cmd, RGWUser& user, RGWUserAdminOpState& op_st
 {
   RGWUserInfo& user_info = op_state.get_user_info();
 
-  set_quota_info(user_info.bucket_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
+  set_quota_info(user_info.quota.bucket_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
 
-  op_state.set_bucket_quota(user_info.bucket_quota);
+  op_state.set_bucket_quota(user_info.quota.bucket_quota);
 
   string err;
   int r = user.modify(dpp(), op_state, null_yield, &err);
@@ -1558,9 +1558,9 @@ int set_user_quota(OPT opt_cmd, RGWUser& user, RGWUserAdminOpState& op_state, in
 {
   RGWUserInfo& user_info = op_state.get_user_info();
 
-  set_quota_info(user_info.user_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
+  set_quota_info(user_info.quota.user_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
 
-  op_state.set_user_quota(user_info.user_quota);
+  op_state.set_user_quota(user_info.quota.user_quota);
 
   string err;
   int r = user.modify(dpp(), op_state, null_yield, &err);
@@ -4639,19 +4639,19 @@ int main(int argc, const char **argv)
 
         formatter->open_object_section("period_config");
         if (quota_scope == "bucket") {
-          set_quota_info(period_config.bucket_quota, opt_cmd,
+          set_quota_info(period_config.quota.bucket_quota, opt_cmd,
                          max_size, max_objects,
                          have_max_size, have_max_objects);
-          encode_json("bucket quota", period_config.bucket_quota, formatter.get());
+          encode_json("bucket quota", period_config.quota.bucket_quota, formatter.get());
         } else if (quota_scope == "user") {
-          set_quota_info(period_config.user_quota, opt_cmd,
+          set_quota_info(period_config.quota.user_quota, opt_cmd,
                          max_size, max_objects,
                          have_max_size, have_max_objects);
-          encode_json("user quota", period_config.user_quota, formatter.get());
+          encode_json("user quota", period_config.quota.user_quota, formatter.get());
         } else if (quota_scope.empty() && opt_cmd == OPT::GLOBAL_QUOTA_GET) {
           // if no scope is given for GET, print both
-          encode_json("bucket quota", period_config.bucket_quota, formatter.get());
-          encode_json("user quota", period_config.user_quota, formatter.get());
+          encode_json("bucket quota", period_config.quota.bucket_quota, formatter.get());
+          encode_json("user quota", period_config.quota.user_quota, formatter.get());
         } else {
           cerr << "ERROR: invalid quota scope specification. Please specify "
               "either --quota-scope=bucket, or --quota-scope=user" << std::endl;
index dfb338818d733b79b23b759601d0f5cd347e8734..408c4dead4a8aa1abf7691c12ca20ec698445ce7 100644 (file)
@@ -373,8 +373,8 @@ void rgw::auth::WebIdentityApplier::create_account(const DoutPrefixProvider* dpp
   user->get_info().type = TYPE_WEB;
   user->get_info().max_buckets =
     cct->_conf.get_val<int64_t>("rgw_user_max_buckets");
-  rgw_apply_default_bucket_quota(user->get_info().bucket_quota, cct->_conf);
-  rgw_apply_default_user_quota(user->get_info().user_quota, cct->_conf);
+  rgw_apply_default_bucket_quota(user->get_info().quota.bucket_quota, cct->_conf);
+  rgw_apply_default_user_quota(user->get_info().quota.user_quota, cct->_conf);
 
   int ret = user->store_user(dpp, null_yield, true);
   if (ret < 0) {
@@ -650,8 +650,8 @@ void rgw::auth::RemoteApplier::create_account(const DoutPrefixProvider* dpp,
   }
   user->get_info().max_buckets =
     cct->_conf.get_val<int64_t>("rgw_user_max_buckets");
-  rgw_apply_default_bucket_quota(user->get_info().bucket_quota, cct->_conf);
-  rgw_apply_default_user_quota(user->get_info().user_quota, cct->_conf);
+  rgw_apply_default_bucket_quota(user->get_info().quota.bucket_quota, cct->_conf);
+  rgw_apply_default_user_quota(user->get_info().quota.user_quota, cct->_conf);
   user_info = user->get_info();
 
   int ret = user->store_user(dpp, null_yield, true);
index d2f1ed918a1786e6074f2027c6928a3abe60ad0a..c6dd4a481c7ecdd501cb4636597df70b1cb0fac3 100644 (file)
@@ -2694,8 +2694,8 @@ void RGWUserInfo::dump(Formatter *f) const
   encode_json("default_placement", default_placement.name, f);
   encode_json("default_storage_class", default_placement.storage_class, f);
   encode_json("placement_tags", placement_tags, f);
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
+  encode_json("bucket_quota", quota.bucket_quota, f);
+  encode_json("user_quota", quota.user_quota, f);
   encode_json("temp_url_keys", temp_url_keys, f);
 
   string user_source_type;
@@ -2753,8 +2753,8 @@ void RGWUserInfo::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("default_placement", default_placement.name, obj);
   JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
   JSONDecoder::decode_json("placement_tags", placement_tags, obj);
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
+  JSONDecoder::decode_json("bucket_quota", quota.bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", quota.user_quota, obj);
   JSONDecoder::decode_json("temp_url_keys", temp_url_keys, obj);
 
   string user_source_type;
index 702ce96512afdd60a7458cd846e579c80af830e2..037cb909ce68f971ad9b1bf671152637e1aa3c97 100644 (file)
@@ -748,9 +748,8 @@ struct RGWUserInfo
   __u8 system;
   rgw_placement_rule default_placement;
   std::list<std::string> placement_tags;
-  RGWQuotaInfo bucket_quota;
   std::map<int, std::string> temp_url_keys;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
   uint32_t type;
   std::set<std::string> mfa_ids;
   std::string assumed_role_arn;
@@ -811,9 +810,9 @@ struct RGWUserInfo
      encode(system, bl);
      encode(default_placement, bl);
      encode(placement_tags, bl);
-     encode(bucket_quota, bl);
+     encode(quota.bucket_quota, bl);
      encode(temp_url_keys, bl);
-     encode(user_quota, bl);
+     encode(quota.user_quota, bl);
      encode(user_id.tenant, bl);
      encode(admin, bl);
      encode(type, bl);
@@ -879,13 +878,13 @@ struct RGWUserInfo
       decode(placement_tags, bl); /* tags of allowed placement rules */
     }
     if (struct_v >= 14) {
-      decode(bucket_quota, bl);
+      decode(quota.bucket_quota, bl);
     }
     if (struct_v >= 15) {
      decode(temp_url_keys, bl);
     }
     if (struct_v >= 16) {
-      decode(user_quota, bl);
+      decode(quota.user_quota, bl);
     }
     if (struct_v >= 17) {
       decode(user_id.tenant, bl);
index 27806e164934817cae7dec804c84f69c13fecace..94665a35aaa6920f45453ab37d782f921cf70cab 100644 (file)
@@ -56,35 +56,34 @@ int RGWUserCreateCR::Request::_send_request(const DoutPrefixProvider *dpp)
 
 
   if (params.apply_quota) {
-    RGWQuotaInfo bucket_quota;
-    RGWQuotaInfo user_quota;
+    RGWQuota quota;
 
     if (cct->_conf->rgw_bucket_default_quota_max_objects >= 0) {
-      bucket_quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
-      bucket_quota.enabled = true;
+      quota.bucket_quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
+      quota.bucket_quota.enabled = true;
     }
 
     if (cct->_conf->rgw_bucket_default_quota_max_size >= 0) {
-      bucket_quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
-      bucket_quota.enabled = true;
+      quota.bucket_quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
+      quota.bucket_quota.enabled = true;
     }
 
     if (cct->_conf->rgw_user_default_quota_max_objects >= 0) {
-      user_quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
-      user_quota.enabled = true;
+      quota.user_quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
+      quota.user_quota.enabled = true;
     }
 
     if (cct->_conf->rgw_user_default_quota_max_size >= 0) {
-      user_quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
-      user_quota.enabled = true;
+      quota.user_quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
+      quota.user_quota.enabled = true;
     }
 
-    if (bucket_quota.enabled) {
-      op_state.set_bucket_quota(bucket_quota);
+    if (quota.bucket_quota.enabled) {
+      op_state.set_bucket_quota(quota.bucket_quota);
     }
 
-    if (user_quota.enabled) {
-      op_state.set_user_quota(user_quota);
+    if (quota.user_quota.enabled) {
+      op_state.set_user_quota(quota.user_quota);
     }
   }
 
index 0fe9fc09e2748d0b1aa7ef18055fb42d2ba08575..079eab63b9d47e009cd7aae81aa682814b156221 100644 (file)
@@ -1904,7 +1904,7 @@ namespace rgw {
       return -EIO;
     }
 
-    op_ret = state->bucket->check_quota(this, user_quota, bucket_quota, real_ofs, null_yield, true);
+    op_ret = state->bucket->check_quota(this, quota, real_ofs, null_yield, true);
     /* max_size exceed */
     if (op_ret < 0)
       return -EIO;
@@ -1946,7 +1946,7 @@ namespace rgw {
       goto done;
     }
 
-    op_ret = state->bucket->check_quota(this, user_quota, bucket_quota, state->obj_size, null_yield, true);
+    op_ret = state->bucket->check_quota(this, quota, state->obj_size, null_yield, true);
     /* max_size exceed */
     if (op_ret < 0) {
       goto done;
index 6f45b353ce33c278e6af1395a604d1b06d692a58..414417fbb6080e56dbd20570ff1f096503e79fe1 100644 (file)
@@ -1357,18 +1357,19 @@ int RGWOp::init_quota()
     if (r < 0)
       return r;
     user = owner_user.get();
+    
   }
 
-  store->get_quota(bucket_quota, user_quota);
+  store->get_quota(quota);
 
   if (s->bucket->get_info().quota.enabled) {
-    bucket_quota = s->bucket->get_info().quota;
-  } else if (user->get_info().bucket_quota.enabled) {
-    bucket_quota = user->get_info().bucket_quota;
+    quota.bucket_quota = s->bucket->get_info().quota;
+  } else if (user->get_info().quota.bucket_quota.enabled) {
+    quota.bucket_quota = user->get_info().quota.bucket_quota;
   }
 
-  if (user->get_info().user_quota.enabled) {
-    user_quota = user->get_info().user_quota;
+  if (user->get_info().quota.user_quota.enabled) {
+    quota.user_quota = user->get_info().quota.user_quota;
   }
 
   return 0;
@@ -3896,7 +3897,7 @@ void RGWPutObj::execute(optional_yield y)
 
   if (!chunked_upload) { /* with chunked upload we don't know how big is the upload.
                             we also check sizes at the end anyway */
-    op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->content_length, y);
+    op_ret = s->bucket->check_quota(this, quota, s->content_length, y);
     if (op_ret < 0) {
       ldpp_dout(this, 20) << "check_quota() returned ret=" << op_ret << dendl;
       return;
@@ -4119,7 +4120,7 @@ void RGWPutObj::execute(optional_yield y)
     return;
   }
 
-  op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->obj_size, y);
+  op_ret = s->bucket->check_quota(this, quota, s->obj_size, y);
   if (op_ret < 0) {
     ldpp_dout(this, 20) << "second check_quota() returned op_ret=" << op_ret << dendl;
     return;
@@ -4339,7 +4340,7 @@ void RGWPostObj::execute(optional_yield y)
     ceph::buffer::list bl, aclbl;
     int len = 0;
 
-    op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->content_length, y);
+    op_ret = s->bucket->check_quota(this, quota, s->content_length, y);
     if (op_ret < 0) {
       return;
     }
@@ -4444,7 +4445,7 @@ void RGWPostObj::execute(optional_yield y)
     s->object->set_obj_size(ofs);
 
 
-    op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->obj_size, y);
+    op_ret = s->bucket->check_quota(this, quota, s->obj_size, y);
     if (op_ret < 0) {
       return;
     }
@@ -4620,7 +4621,7 @@ void RGWPutMetadataAccount::execute(optional_yield y)
 
   /* Handle the quota extracted at the verify_permission step. */
   if (new_quota_extracted) {
-    s->user->get_info().user_quota = std::move(new_quota);
+    s->user->get_info().quota.user_quota = std::move(new_quota);
   }
 
   /* We are passing here the current (old) user info to allow the function
@@ -5471,8 +5472,7 @@ void RGWCopyObj::execute(optional_yield y)
         return;
       }
       // enforce quota against the destination bucket owner
-      op_ret = dest_bucket->check_quota(this, user_quota, bucket_quota,
-                                     astate->accounted_size, y);
+      op_ret = dest_bucket->check_quota(this, quota, astate->accounted_size, y);
       if (op_ret < 0) {
         return;
       }
@@ -7412,7 +7412,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path,
     return op_ret;
   }
 
-  op_ret = bucket->check_quota(this, user_quota, bucket_quota, size, y);
+  op_ret = bucket->check_quota(this, quota, size, y);
   if (op_ret < 0) {
     return op_ret;
   }
@@ -7490,7 +7490,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path,
     return op_ret;
   }
 
-  op_ret = bucket->check_quota(this, user_quota, bucket_quota, size, y);
+  op_ret = bucket->check_quota(this, quota, size, y);
   if (op_ret < 0) {
     ldpp_dout(this, 20) << "quota exceeded for path=" << path << dendl;
     return op_ret;
index f584d78a718b00ea31e6fd9dcd12ebd36bbeeae0..aa3ea4fdb421d567887916e0d4da992e73d87393 100644 (file)
@@ -178,8 +178,7 @@ protected:
   rgw::sal::Store* store;
   RGWCORSConfiguration bucket_cors;
   bool cors_exist;
-  RGWQuotaInfo bucket_quota;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
   int op_ret;
   int do_aws4_auth_completion();
 
index f31abae145f1c2d1ce1f9025fb809acfa80ff85b..f7f910d2b494339ac43eef203881e40163a7f03b 100644 (file)
@@ -903,13 +903,12 @@ public:
 
   int check_quota(const DoutPrefixProvider *dpp,
                   const rgw_user& user,
-                 rgw_bucket& bucket,
-                 RGWQuotaInfo& user_quota,
-                 RGWQuotaInfo& bucket_quota,
-                 uint64_t num_objs,
-                 uint64_t size, optional_yield y) override {
+                  rgw_bucket& bucket,
+                  RGWQuota& quota,
+                  uint64_t num_objs,
+                  uint64_t size, optional_yield y) override {
 
-    if (!bucket_quota.enabled && !user_quota.enabled) {
+    if (!quota.bucket_quota.enabled && !quota.user_quota.enabled) {
       return 0;
     }
 
@@ -921,25 +920,25 @@ public:
      */
 
     const DoutPrefix dp(store->ctx(), dout_subsys, "rgw quota handler: ");
-    if (bucket_quota.enabled) {
+    if (quota.bucket_quota.enabled) {
       RGWStorageStats bucket_stats;
       int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, y, &dp);
       if (ret < 0) {
         return ret;
       }
-      ret = check_quota(dpp, "bucket", bucket_quota, bucket_stats, num_objs, size);
+      ret = check_quota(dpp, "bucket", quota.bucket_quota, bucket_stats, num_objs, size);
       if (ret < 0) {
         return ret;
       }
     }
 
-    if (user_quota.enabled) {
+    if (quota.user_quota.enabled) {
       RGWStorageStats user_stats;
       int ret = user_stats_cache.get_stats(user, bucket, user_stats, y, &dp);
       if (ret < 0) {
         return ret;
       }
-      ret = check_quota(dpp, "user", user_quota, user_stats, num_objs, size);
+      ret = check_quota(dpp, "user", quota.user_quota, user_stats, num_objs, size);
       if (ret < 0) {
         return ret;
       }
index 61bd25261aa92d482e10784f7ba2f25395717e62..c29bac936d07ec2ef343f20de09ccef6d1c5668f 100644 (file)
@@ -35,6 +35,7 @@ namespace rgw { namespace sal {
   class Store;
 } }
 
+
 struct RGWQuotaInfo {
   template<class T> friend class RGWQuotaCache;
 public:
@@ -89,6 +90,12 @@ public:
 };
 WRITE_CLASS_ENCODER(RGWQuotaInfo)
 
+struct RGWQuota {
+    RGWQuotaInfo user_quota;
+    RGWQuotaInfo bucket_quota;
+};
+
+
 struct rgw_bucket;
 
 class RGWQuotaHandler {
@@ -97,7 +104,7 @@ public:
   virtual ~RGWQuotaHandler() {
   }
   virtual int check_quota(const DoutPrefixProvider *dpp, const rgw_user& bucket_owner, rgw_bucket& bucket,
-                          RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota,
+                          RGWQuotaquota,
                          uint64_t num_objs, uint64_t size, optional_yield y) = 0;
 
   virtual void check_bucket_shards(const DoutPrefixProvider *dpp, uint64_t max_objs_per_shard, uint64_t num_shards,
index b9375d50ce1a5c925fbce8d8c3cdfdedd86402e4..a56775f1806019bb86b8b1295cf072212844f940 100644 (file)
@@ -9391,15 +9391,15 @@ int RGWRados::add_bucket_to_reshard(const DoutPrefixProvider *dpp, const RGWBuck
 }
 
 int RGWRados::check_quota(const DoutPrefixProvider *dpp, const rgw_user& bucket_owner, rgw_bucket& bucket,
-                          RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota,
+                          RGWQuotaquota,
                          uint64_t obj_size, optional_yield y,
                          bool check_size_only)
 {
   // if we only check size, then num_objs will set to 0
   if(check_size_only)
-    return quota_handler->check_quota(dpp, bucket_owner, bucket, user_quota, bucket_quota, 0, obj_size, y);
+    return quota_handler->check_quota(dpp, bucket_owner, bucket, quota, 0, obj_size, y);
 
-  return quota_handler->check_quota(dpp, bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size, y);
+  return quota_handler->check_quota(dpp, bucket_owner, bucket, quota, 1, obj_size, y);
 }
 
 int RGWRados::get_target_shard_id(const rgw::bucket_index_normal_layout& layout, const string& obj_key,
index f145c54da3d2ea97fe34bd5b8de30939dde8b298..41e06192b35e3a6a0ba85edd3d7e746d38844c79 100644 (file)
@@ -1495,7 +1495,7 @@ public:
   int fix_tail_obj_locator(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, rgw_obj_key& key, bool fix, bool *need_fix, optional_yield y);
 
   int check_quota(const DoutPrefixProvider *dpp, const rgw_user& bucket_owner, rgw_bucket& bucket,
-                  RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size,
+                  RGWQuotaquota, uint64_t obj_size,
                  optional_yield y, bool check_size_only = false);
 
   int check_bucket_shards(const RGWBucketInfo& bucket_info, const rgw_bucket& bucket,
index d28637cbd547ddb49fa0ef03e9eb03363fa83659..db8eab4cc72a5e6ee823f43c61b7e38c2317f669 100644 (file)
@@ -51,8 +51,8 @@ void RGWOp_ZoneGroupMap_Get::send_response() {
     RGWRegionMap region_map;
     region_map.regions = zonegroup_map.zonegroups;
     region_map.master_region = zonegroup_map.master_zonegroup;
-    region_map.bucket_quota = zonegroup_map.bucket_quota;
-    region_map.user_quota = zonegroup_map.user_quota;
+    region_map.quota.bucket_quota = zonegroup_map.quota.bucket_quota;
+    region_map.quota.user_quota = zonegroup_map.quota.user_quota;
     encode_json("region-map", region_map, s->formatter);
   } else {
     encode_json("zonegroup-map", zonegroup_map, s->formatter);
index b28c1cf5d4bef9900536a3e06b4d9d423eba1007..c226cbc0c84fdead938826b969cda0fd9951ef86 100644 (file)
@@ -1421,11 +1421,11 @@ void RGWGetUsage_ObjStore_S3::send_response()
 
      // send info about quota config
      auto user_info = s->user->get_info();
-     encode_json("QuotaMaxBytes", user_info.user_quota.max_size, formatter);
+     encode_json("QuotaMaxBytes", user_info.quota.user_quota.max_size, formatter);
      encode_json("QuotaMaxBuckets", user_info.max_buckets, formatter);
-     encode_json("QuotaMaxObjCount", user_info.user_quota.max_objects, formatter);
-     encode_json("QuotaMaxBytesPerBucket", user_info.bucket_quota.max_objects, formatter);
-     encode_json("QuotaMaxObjCountPerBucket", user_info.bucket_quota.max_size, formatter);
+     encode_json("QuotaMaxObjCount", user_info.quota.user_quota.max_objects, formatter);
+     encode_json("QuotaMaxBytesPerBucket", user_info.quota.bucket_quota.max_objects, formatter);
+     encode_json("QuotaMaxObjCountPerBucket", user_info.quota.bucket_quota.max_size, formatter);
      // send info about user's capacity utilization
      encode_json("TotalBytes", stats.size, formatter);
      encode_json("TotalBytesRounded", stats.size_rounded, formatter);
@@ -2150,11 +2150,11 @@ static void dump_bucket_metadata(struct req_state *s, rgw::sal::Bucket* bucket)
   // only bucket's owner is allowed to get the quota settings of the account
   if (bucket->is_owner(s->user.get())) {
     auto user_info = s->user->get_info();
-    dump_header(s, "X-RGW-Quota-User-Size", static_cast<long long>(user_info.user_quota.max_size));
-    dump_header(s, "X-RGW-Quota-User-Objects", static_cast<long long>(user_info.user_quota.max_objects));
+    dump_header(s, "X-RGW-Quota-User-Size", static_cast<long long>(user_info.quota.user_quota.max_size));
+    dump_header(s, "X-RGW-Quota-User-Objects", static_cast<long long>(user_info.quota.user_quota.max_objects));
     dump_header(s, "X-RGW-Quota-Max-Buckets", static_cast<long long>(user_info.max_buckets));
-    dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast<long long>(user_info.bucket_quota.max_size));
-    dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast<long long>(user_info.bucket_quota.max_objects));
+    dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast<long long>(user_info.quota.bucket_quota.max_size));
+    dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast<long long>(user_info.quota.bucket_quota.max_objects));
   }
 }
 
index 6d533931a7a138700a268a4399cdf306f56b7613..858397079b1bbec280897e05b26bb46eca731f4f 100644 (file)
@@ -178,7 +178,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets)
             global_stats,
             policies_stats,
             s->user->get_attrs(),
-            s->user->get_info().user_quota,
+            s->user->get_info().quota.user_quota,
             static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
     dump_errno(s);
     dump_header(s, "Accept-Ranges", "bytes");
@@ -284,7 +284,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_end()
             global_stats,
             policies_stats,
             s->user->get_attrs(),
-            s->user->get_info().user_quota,
+            s->user->get_info().quota.user_quota,
             static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
     dump_errno(s);
     end_header(s, nullptr, nullptr, s->formatter->get_len(), true);
@@ -352,7 +352,7 @@ void RGWListBucket_ObjStore_SWIFT::send_response()
   map<string, bool>::iterator pref_iter = common_prefixes.begin();
 
   dump_start(s);
-  dump_container_metadata(s, s->bucket.get(), bucket_quota,
+  dump_container_metadata(s, s->bucket.get(), quota.bucket_quota,
                           s->bucket->get_info().website_conf);
 
   s->formatter->open_array_section_with_attrs("container",
@@ -559,7 +559,7 @@ void RGWStatAccount_ObjStore_SWIFT::send_response()
             global_stats,
             policies_stats,
             attrs,
-            s->user->get_info().user_quota,
+            s->user->get_info().quota.user_quota,
             static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
   }
 
@@ -575,7 +575,7 @@ void RGWStatBucket_ObjStore_SWIFT::send_response()
 {
   if (op_ret >= 0) {
     op_ret = STATUS_NO_CONTENT;
-    dump_container_metadata(s, bucket.get(), bucket_quota,
+    dump_container_metadata(s, bucket.get(), quota.bucket_quota,
                             s->bucket->get_info().website_conf);
   }
 
@@ -2499,7 +2499,7 @@ RGWOp* RGWSwiftWebsiteHandler::get_ws_listing_op()
       /* Generate the header now. */
       set_req_state_err(s, op_ret);
       dump_errno(s);
-      dump_container_metadata(s, s->bucket.get(), bucket_quota,
+      dump_container_metadata(s, s->bucket.get(), quota.bucket_quota,
                               s->bucket->get_info().website_conf);
       end_header(s, this, "text/html");
       if (op_ret < 0) {
index e5fd846132caf12f7292f833c11231df342e3682..78b06d365ed6203475a9353d4cbdc19ddbddaa6c 100644 (file)
@@ -780,21 +780,22 @@ void RGWOp_Caps_Remove::execute(optional_yield y)
 }
 
 struct UserQuotas {
-  RGWQuotaInfo bucket_quota;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
 
   UserQuotas() {}
 
-  explicit UserQuotas(RGWUserInfo& info) : bucket_quota(info.bucket_quota),
-                                 user_quota(info.user_quota) {}
+  explicit UserQuotas(RGWUserInfo& info){
+    quota.bucket_quota = info.quota.bucket_quota;
+    quota.user_quota = info.quota.user_quota;
+  }
 
   void dump(Formatter *f) const {
-    encode_json("bucket_quota", bucket_quota, f);
-    encode_json("user_quota", user_quota, f);
+    encode_json("bucket_quota", quota.bucket_quota, f);
+    encode_json("user_quota", quota.user_quota, f);
   }
   void decode_json(JSONObj *obj) {
-    JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-    JSONDecoder::decode_json("user_quota", user_quota, obj);
+    JSONDecoder::decode_json("bucket_quota", quota.bucket_quota, obj);
+    JSONDecoder::decode_json("user_quota", quota.user_quota, obj);
   }
 };
 
@@ -862,9 +863,9 @@ void RGWOp_Quota_Info::execute(optional_yield y)
     UserQuotas quotas(info);
     encode_json("quota", quotas, s->formatter);
   } else if (show_user) {
-    encode_json("user_quota", info.user_quota, s->formatter);
+    encode_json("user_quota", info.quota.user_quota, s->formatter);
   } else {
-    encode_json("bucket_quota", info.bucket_quota, s->formatter);
+    encode_json("bucket_quota", info.quota.bucket_quota, s->formatter);
   }
 
   flusher.flush();
@@ -997,8 +998,8 @@ void RGWOp_Quota_Set::execute(optional_yield y)
       return;
     }
 
-    op_state.set_user_quota(quotas.user_quota);
-    op_state.set_bucket_quota(quotas.bucket_quota);
+    op_state.set_user_quota(quotas.quota.user_quota);
+    op_state.set_bucket_quota(quotas.quota.bucket_quota);
   } else {
     RGWQuotaInfo quota;
 
@@ -1025,9 +1026,9 @@ void RGWOp_Quota_Set::execute(optional_yield y)
       }
       RGWQuotaInfo *old_quota;
       if (set_user) {
-        old_quota = &info.user_quota;
+        old_quota = &info.quota.user_quota;
       } else {
-        old_quota = &info.bucket_quota;
+        old_quota = &info.quota.bucket_quota;
       }
 
       RESTArgs::get_int64(s, "max-objects", old_quota->max_objects, &quota.max_objects);
index db7b0f586e3a252fffebfbe1247ebcb28243a4f7..0a338e5ce42eaa250fbf4fad5363e386b24866c7 100644 (file)
@@ -352,7 +352,7 @@ class Store {
     virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
                                        const std::map<std::string, std::string>& meta) = 0;
     /** Get default quota info.  Used as fallback if a user or bucket has no quota set*/
-    virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) = 0;
+    virtual void get_quota(RGWQuotaquota) = 0;
     /** Get global rate limit configuration*/
     virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) = 0;
     /** Enable or disable a set of bucket.  e.g. if a User is suspended */
@@ -726,7 +726,7 @@ class Bucket {
     /** Check in the backing store if this bucket is empty */
     virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) = 0;
     /** Chec k if the given size fits within the quota */
-    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) = 0;
+    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size, optional_yield y, bool check_size_only = false) = 0;
     /** Set the attributes in attrs, leaving any other existing attrs set, and
      * write them to the backing store; a merge operation */
     virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) = 0;
index e0b0aa3224a2212339753984dfe67c0a291a8b3c..46b5f10653d894730598251dfa1151987740489c 100644 (file)
@@ -345,7 +345,7 @@ namespace rgw::sal {
     return 0;
   }
 
-  int DBBucket::check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size,
+  int DBBucket::check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size,
       optional_yield y, bool check_size_only)
   {
     /* Not Handled in the first pass as stats are also needed */
@@ -1834,7 +1834,7 @@ namespace rgw::sal {
     return;
   }
 
-  void DBStore::get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota)
+  void DBStore::get_quota(RGWQuotaquota)
   {
     // XXX: Not handled for the first pass 
     return;
index 5cd3fbc8015a6aa311728dc9384649e786548a3e..75723d11a8405afe8cd42ff578337e5d5dc622ca 100644 (file)
@@ -200,7 +200,7 @@ protected:
       virtual int put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime) override;
       virtual bool is_owner(User* user) override;
       virtual int check_empty(const DoutPrefixProvider *dpp, optional_yield y) override;
-      virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
+      virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
       virtual int merge_and_store_attrs(const DoutPrefixProvider *dpp, Attrs& attrs, optional_yield y) override;
       virtual int try_refresh_info(const DoutPrefixProvider *dpp, ceph::real_time *pmtime) override;
       virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
@@ -789,7 +789,7 @@ public:
       virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
           const std::map<std::string, std::string>& meta) override;
       virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) override;
-      virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) override;
+      virtual void get_quota(RGWQuotaquota) override;
     virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, std::vector<rgw_bucket>& buckets, bool enabled) override;
       virtual uint64_t get_new_req_id() override { return 0; }
       virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp,
index 9e0668c33aaeb1e3a9287c2a0a90367c1d249bbe..92b817fe7758e0af4d2a374eb3ad29b8124e31cf 100644 (file)
@@ -630,7 +630,7 @@ int MotrBucket::check_empty(const DoutPrefixProvider *dpp, optional_yield y)
   return 0;
 }
 
-int MotrBucket::check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size,
+int MotrBucket::check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size,
     optional_yield y, bool check_size_only)
 {
   /* Not Handled in the first pass as stats are also needed */
@@ -2988,7 +2988,7 @@ void MotrStore::get_ratelimit(RGWRateLimitInfo& bucket_ratelimit,
   return;
 }
 
-void MotrStore::get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota)
+void MotrStore::get_quota(RGWQuotaquota)
 {
   // XXX: Not handled for the first pass
   return;
index aa9b86ed5f05dcaded71f28053bb456d994f2fca..8635462687e3105355d5d588b297c43cd465c33f 100644 (file)
@@ -319,7 +319,7 @@ class MotrBucket : public Bucket {
     virtual int put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime) override;
     virtual bool is_owner(User* user) override;
     virtual int check_empty(const DoutPrefixProvider *dpp, optional_yield y) override;
-    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
+    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
     virtual int merge_and_store_attrs(const DoutPrefixProvider *dpp, Attrs& attrs, optional_yield y) override;
     virtual int try_refresh_info(const DoutPrefixProvider *dpp, ceph::real_time *pmtime) override;
     virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
@@ -930,7 +930,7 @@ class MotrStore : public Store {
     virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
         const std::map<std::string, std::string>& meta) override;
     virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) override;
-    virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) override;
+    virtual void get_quota(RGWQuotaquota) override;
     virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, std::vector<rgw_bucket>& buckets, bool enabled) override;
     virtual uint64_t get_new_req_id() override { return 0; }
     virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp,
index 0e9c3e2648ad45e250d0b72e139409880cbe6837..a0b41e800cb73112043fd95dd5f34199460e42a6 100644 (file)
@@ -732,11 +732,11 @@ int RadosBucket::check_empty(const DoutPrefixProvider* dpp, optional_yield y)
   return store->getRados()->check_bucket_empty(dpp, info, y);
 }
 
-int RadosBucket::check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size,
+int RadosBucket::check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size,
                                optional_yield y, bool check_size_only)
 {
     return store->getRados()->check_quota(dpp, owner->get_id(), get_key(),
-                                         user_quota, bucket_quota, obj_size, y, check_size_only);
+                                         quota, obj_size, y, check_size_only);
 }
 
 int RadosBucket::merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y)
@@ -1228,10 +1228,10 @@ int RadosStore::register_to_service_map(const DoutPrefixProvider *dpp, const std
   return rados->register_to_service_map(dpp, daemon_type, meta);
 }
 
-void RadosStore::get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota)
+void RadosStore::get_quota(RGWQuotaquota)
 {
-    bucket_quota = svc()->quota->get_bucket_quota();
-    user_quota = svc()->quota->get_user_quota();
+    quota.bucket_quota = svc()->quota->get_bucket_quota();
+    quota.user_quota = svc()->quota->get_user_quota();
 }
 
 void RadosStore::get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit)
index a0aea9ce03ebac153af90479873d4f44053b5043..156fc6e6c03f1c9acb02263bb628ccdda7210d01 100644 (file)
@@ -159,7 +159,7 @@ class RadosStore : public Store {
     virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) override;
     virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
                                const std::map<std::string, std::string>& meta) override;
-    virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) override;
+    virtual void get_quota(RGWQuotaquota) override;
     virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) override;
     virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled) override;
     virtual uint64_t get_new_req_id() override { return rados->get_new_req_id(); }
@@ -552,7 +552,7 @@ class RadosBucket : public Bucket {
     virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime) override;
     virtual bool is_owner(User* user) override;
     virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) override;
-    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
+    virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuotaquota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override;
     virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& attrs, optional_yield y) override;
     virtual int try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime) override;
     virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
index 24efdc7cb17f6426bc65ac2a1729c664120ae0a1..580c429b5c1209af95585f0be39828ce802cde73 100644 (file)
@@ -281,8 +281,8 @@ static void dump_user_info(Formatter *f, RGWUserInfo &info,
   encode_json("default_placement", info.default_placement.name, f);
   encode_json("default_storage_class", info.default_placement.storage_class, f);
   encode_json("placement_tags", info.placement_tags, f);
-  encode_json("bucket_quota", info.bucket_quota, f);
-  encode_json("user_quota", info.user_quota, f);
+  encode_json("bucket_quota", info.quota.bucket_quota, f);
+  encode_json("user_quota", info.quota.user_quota, f);
   encode_json("temp_url_keys", info.temp_url_keys, f);
 
   string user_source_type;
@@ -1756,9 +1756,9 @@ int RGWUser::execute_add(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_
     user_info.op_mask = op_state.get_op_mask();
 
   if (op_state.has_bucket_quota()) {
-    user_info.bucket_quota = op_state.get_bucket_quota();
+    user_info.quota.bucket_quota = op_state.get_bucket_quota();
   } else {
-    rgw_apply_default_bucket_quota(user_info.bucket_quota, cct->_conf);
+    rgw_apply_default_bucket_quota(user_info.quota.bucket_quota, cct->_conf);
   }
 
   if (op_state.temp_url_key_specified) {
@@ -1770,9 +1770,9 @@ int RGWUser::execute_add(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_
   }
 
   if (op_state.has_user_quota()) {
-    user_info.user_quota = op_state.get_user_quota();
+    user_info.quota.user_quota = op_state.get_user_quota();
   } else {
-    rgw_apply_default_user_quota(user_info.user_quota, cct->_conf);
+    rgw_apply_default_user_quota(user_info.quota.user_quota, cct->_conf);
   }
 
   if (op_state.default_placement_specified) {
@@ -2014,10 +2014,10 @@ int RGWUser::execute_modify(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
     user_info.op_mask = op_state.get_op_mask();
 
   if (op_state.has_bucket_quota())
-    user_info.bucket_quota = op_state.get_bucket_quota();
+    user_info.quota.bucket_quota = op_state.get_bucket_quota();
 
   if (op_state.has_user_quota())
-    user_info.user_quota = op_state.get_user_quota();
+    user_info.quota.user_quota = op_state.get_user_quota();
 
   if (op_state.has_suspension_op()) {
     __u8 suspended = op_state.get_suspension_status();
index 68bbcb552042b90cf630b7146be021154e56ee4a..b9f25d323aec990735a9367b1cd1fb86406e6ded 100644 (file)
@@ -176,8 +176,7 @@ struct RGWUserAdminOpState {
   bool bucket_ratelimit_specified{false};
   bool user_ratelimit_specified{false};
 
-  RGWQuotaInfo bucket_quota;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
   RGWRateLimitInfo user_ratelimit;
   RGWRateLimitInfo bucket_ratelimit;
 
@@ -333,13 +332,13 @@ struct RGWUserAdminOpState {
     key_op = true;
   }
 
-  void set_bucket_quota(RGWQuotaInfo& quota) {
-    bucket_quota = quota;
+  void set_bucket_quota(RGWQuotaInfo& quotas) {
+    quota.bucket_quota = quotas;
     bucket_quota_specified = true;
   }
 
-  void set_user_quota(RGWQuotaInfo& quota) {
-    user_quota = quota;
+  void set_user_quota(RGWQuotaInfo& quotas) {
+    quota.user_quota = quotas;
     user_quota_specified = true;
   }
 
@@ -403,8 +402,8 @@ struct RGWUserAdminOpState {
   uint32_t get_subuser_perm() { return perm_mask; }
   int32_t get_max_buckets() { return max_buckets; }
   uint32_t get_op_mask() { return op_mask; }
-  RGWQuotaInfo& get_bucket_quota() { return bucket_quota; }
-  RGWQuotaInfo& get_user_quota() { return user_quota; }
+  RGWQuotaInfo& get_bucket_quota() { return quota.bucket_quota; }
+  RGWQuotaInfo& get_user_quota() { return quota.user_quota; }
   std::set<std::string>& get_mfa_ids() { return mfa_ids; }
 
   rgw::sal::User* get_user() { return user.get(); }
index c8e8d09b8879a66adb8548e56b5138fa8627db8c..8265371c014054347001ac68f6829eacf59cbeb7 100644 (file)
@@ -2066,8 +2066,8 @@ int RGWZoneGroupMap::read(const DoutPrefixProvider *dpp, CephContext *cct, RGWSI
     return ret;
   }
 
-  bucket_quota = period.get_config().bucket_quota;
-  user_quota = period.get_config().user_quota;
+  quota.bucket_quota = period.get_config().quota.bucket_quota;
+  quota.user_quota = period.get_config().quota.user_quota;
   zonegroups = period.get_map().zonegroups;
   zonegroups_by_api = period.get_map().zonegroups_by_api;
   master_zonegroup = period.get_map().master_zonegroup;
@@ -2079,8 +2079,8 @@ void RGWRegionMap::encode(bufferlist& bl) const {
   ENCODE_START( 3, 1, bl);
   encode(regions, bl);
   encode(master_region, bl);
-  encode(bucket_quota, bl);
-  encode(user_quota, bl);
+  encode(quota.bucket_quota, bl);
+  encode(quota.user_quota, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -2089,9 +2089,9 @@ void RGWRegionMap::decode(bufferlist::const_iterator& bl) {
   decode(regions, bl);
   decode(master_region, bl);
   if (struct_v >= 2)
-    decode(bucket_quota, bl);
+    decode(quota.bucket_quota, bl);
   if (struct_v >= 3)
-    decode(user_quota, bl);
+    decode(quota.user_quota, bl);
   DECODE_FINISH(bl);
 }
 
@@ -2099,8 +2099,8 @@ void RGWZoneGroupMap::encode(bufferlist& bl) const {
   ENCODE_START( 3, 1, bl);
   encode(zonegroups, bl);
   encode(master_zonegroup, bl);
-  encode(bucket_quota, bl);
-  encode(user_quota, bl);
+  encode(quota.bucket_quota, bl);
+  encode(quota.user_quota, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -2109,9 +2109,9 @@ void RGWZoneGroupMap::decode(bufferlist::const_iterator& bl) {
   decode(zonegroups, bl);
   decode(master_zonegroup, bl);
   if (struct_v >= 2)
-    decode(bucket_quota, bl);
+    decode(quota.bucket_quota, bl);
   if (struct_v >= 3)
-    decode(user_quota, bl);
+    decode(quota.user_quota, bl);
   DECODE_FINISH(bl);
 
   zonegroups_by_api.clear();
@@ -2754,8 +2754,8 @@ void RGWPeriodMap::decode_json(JSONObj *obj)
 
 void RGWPeriodConfig::dump(Formatter *f) const
 {
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
+  encode_json("bucket_quota", quota.bucket_quota, f);
+  encode_json("user_quota", quota.user_quota, f);
   encode_json("user_ratelimit", user_ratelimit, f);
   encode_json("bucket_ratelimit", bucket_ratelimit, f);
   encode_json("anonymous_ratelimit", anon_ratelimit, f);
@@ -2763,8 +2763,8 @@ void RGWPeriodConfig::dump(Formatter *f) const
 
 void RGWPeriodConfig::decode_json(JSONObj *obj)
 {
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
+  JSONDecoder::decode_json("bucket_quota", quota.bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", quota.user_quota, obj);
   JSONDecoder::decode_json("user_ratelimit", user_ratelimit, obj);
   JSONDecoder::decode_json("bucket_ratelimit", bucket_ratelimit, obj);
   JSONDecoder::decode_json("anonymous_ratelimit", anon_ratelimit, obj);
@@ -2774,24 +2774,24 @@ void RGWRegionMap::dump(Formatter *f) const
 {
   encode_json("regions", regions, f);
   encode_json("master_region", master_region, f);
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
+  encode_json("bucket_quota", quota.bucket_quota, f);
+  encode_json("user_quota", quota.user_quota, f);
 }
 
 void RGWRegionMap::decode_json(JSONObj *obj)
 {
   JSONDecoder::decode_json("regions", regions, obj);
   JSONDecoder::decode_json("master_region", master_region, obj);
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
+  JSONDecoder::decode_json("bucket_quota", quota.bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", quota.user_quota, obj);
 }
 
 void RGWZoneGroupMap::dump(Formatter *f) const
 {
   encode_json("zonegroups", zonegroups, f);
   encode_json("master_zonegroup", master_zonegroup, f);
-  encode_json("bucket_quota", bucket_quota, f);
-  encode_json("user_quota", user_quota, f);
+  encode_json("bucket_quota", quota.bucket_quota, f);
+  encode_json("user_quota", quota.user_quota, f);
 }
 
 void RGWZoneGroupMap::decode_json(JSONObj *obj)
@@ -2807,7 +2807,7 @@ void RGWZoneGroupMap::decode_json(JSONObj *obj)
     JSONDecoder::decode_json("master_region", master_zonegroup, obj);
   }
 
-  JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
-  JSONDecoder::decode_json("user_quota", user_quota, obj);
+  JSONDecoder::decode_json("bucket_quota", quota.bucket_quota, obj);
+  JSONDecoder::decode_json("user_quota", quota.user_quota, obj);
 }
 
index 9e89cbf150a72183210415177d332757ba158b4e..6e1176ac511e561a8baa3c637a41896c78a749d5 100644 (file)
@@ -1026,8 +1026,7 @@ WRITE_CLASS_ENCODER(RGWPeriodMap)
 
 struct RGWPeriodConfig
 {
-  RGWQuotaInfo bucket_quota;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
   RGWRateLimitInfo user_ratelimit;
   RGWRateLimitInfo bucket_ratelimit;
   // rate limit unauthenticated user
@@ -1035,8 +1034,8 @@ struct RGWPeriodConfig
 
   void encode(bufferlist& bl) const {
     ENCODE_START(2, 1, bl);
-    encode(bucket_quota, bl);
-    encode(user_quota, bl);
+    encode(quota.bucket_quota, bl);
+    encode(quota.user_quota, bl);
     encode(bucket_ratelimit, bl);
     encode(user_ratelimit, bl);
     encode(anon_ratelimit, bl);
@@ -1045,8 +1044,8 @@ struct RGWPeriodConfig
 
   void decode(bufferlist::const_iterator& bl) {
     DECODE_START(2, bl);
-    decode(bucket_quota, bl);
-    decode(user_quota, bl);
+    decode(quota.bucket_quota, bl);
+    decode(quota.user_quota, bl);
     if (struct_v >= 2) {
       decode(bucket_ratelimit, bl);
       decode(user_ratelimit, bl);
@@ -1076,8 +1075,7 @@ struct RGWRegionMap {
 
   std::string master_region;
 
-  RGWQuotaInfo bucket_quota;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::const_iterator& bl);
@@ -1094,8 +1092,7 @@ struct RGWZoneGroupMap {
 
   std::string master_zonegroup;
 
-  RGWQuotaInfo bucket_quota;
-  RGWQuotaInfo user_quota;
+  RGWQuota quota;
 
   /* construct the map */
   int read(const DoutPrefixProvider *dpp, CephContext *cct, RGWSI_SysObj *sysobj_svc, optional_yield y);
@@ -1281,11 +1278,11 @@ public:
   const std::string& get_info_oid_prefix() const;
 
   void set_user_quota(RGWQuotaInfo& user_quota) {
-    period_config.user_quota = user_quota;
+    period_config.quota.user_quota = user_quota;
   }
 
   void set_bucket_quota(RGWQuotaInfo& bucket_quota) {
-    period_config.bucket_quota = bucket_quota;
+    period_config.quota.bucket_quota = bucket_quota;
   }
 
   void set_id(const std::string& _id) {
index c7164964cdf24fc3471e8fda5eb2f244b1c9214e..0487a6ec95c26f5e75a3fa302b18803dbc46aae2 100644 (file)
@@ -8,11 +8,11 @@
 
 const RGWQuotaInfo& RGWSI_Quota::get_bucket_quota() const
 {
-  return zone_svc->get_current_period().get_config().bucket_quota;
+  return zone_svc->get_current_period().get_config().quota.bucket_quota;
 }
 
 const RGWQuotaInfo& RGWSI_Quota::get_user_quota() const
 {
-  return zone_svc->get_current_period().get_config().user_quota;
+  return zone_svc->get_current_period().get_config().quota.user_quota;
 }
 
index 5280371ad237ca5b480299cf377d77f522481049..ab77f6aef6eeb8ea553c7a0db5588dce9691b652 100644 (file)
@@ -928,8 +928,8 @@ int RGWSI_Zone::convert_regionmap(const DoutPrefixProvider *dpp, optional_yield
     }
   }
 
-  current_period->set_user_quota(zonegroupmap.user_quota);
-  current_period->set_bucket_quota(zonegroupmap.bucket_quota);
+  current_period->set_user_quota(zonegroupmap.quota.user_quota);
+  current_period->set_bucket_quota(zonegroupmap.quota.bucket_quota);
 
   // remove the region_map so we don't try to convert again
   ret = sysobj.wop().remove(dpp, y);
index 347958abf16cd1996122f18ca19bed0ec1f6a244..6668173414a9f433aa9e09954a777a948ca7bf3e 100644 (file)
@@ -388,9 +388,9 @@ static int list_user(const DoutPrefixProvider *dpp, DBOpInfo &op, sqlite3_stmt *
 
   SQL_DECODE_BLOB_PARAM(dpp, stmt, PlacementTags, op.user.uinfo.placement_tags, sdb);
 
-  SQL_DECODE_BLOB_PARAM(dpp, stmt, BucketQuota, op.user.uinfo.bucket_quota, sdb);
+  SQL_DECODE_BLOB_PARAM(dpp, stmt, BucketQuota, op.user.uinfo.quota.bucket_quota, sdb);
   SQL_DECODE_BLOB_PARAM(dpp, stmt, TempURLKeys, op.user.uinfo.temp_url_keys, sdb);
-  SQL_DECODE_BLOB_PARAM(dpp, stmt, UserQuota, op.user.uinfo.user_quota, sdb);
+  SQL_DECODE_BLOB_PARAM(dpp, stmt, UserQuota, op.user.uinfo.quota.user_quota, sdb);
 
   op.user.uinfo.type = sqlite3_column_int(stmt, TYPE);
 
@@ -1182,13 +1182,13 @@ int SQLInsertUser::Bind(const DoutPrefixProvider *dpp, struct DBOpParams *params
   SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.user.uinfo.placement_tags, sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.user.bucket_quota, sdb);
-  SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.user.uinfo.bucket_quota, sdb);
+  SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.user.uinfo.quota.bucket_quota, sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.user.temp_url_keys, sdb);
   SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.user.uinfo.temp_url_keys, sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.user.user_quota, sdb);
-  SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.user.uinfo.user_quota, sdb);
+  SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.user.uinfo.quota.user_quota, sdb);
 
   SQL_BIND_INDEX(dpp, stmt, index, p_params.op.user.type, sdb);
   SQL_BIND_INT(dpp, stmt, index, params->op.user.uinfo.type, sdb);