From: Iqbal Khan Date: Thu, 28 Apr 2022 18:54:29 +0000 (+0530) Subject: rgw: user_quota and bucket_quota are defined under RGWQuota X-Git-Tag: v18.0.0~950^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F46033%2Fhead;p=ceph.git rgw: user_quota and bucket_quota are defined under RGWQuota struct RGWQuota { RGWQuotaInfo user_quota; RGWQuotaInfo bucket_quota; }; Signed-off-by: Iqbal Khan --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 08054c9f77c3..a9e668f32f6c 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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; diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index dfb338818d73..408c4dead4a8 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -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("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("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); diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index d2f1ed918a17..c6dd4a481c7e 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -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; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 702ce96512af..037cb909ce68 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -748,9 +748,8 @@ struct RGWUserInfo __u8 system; rgw_placement_rule default_placement; std::list placement_tags; - RGWQuotaInfo bucket_quota; std::map temp_url_keys; - RGWQuotaInfo user_quota; + RGWQuota quota; uint32_t type; std::set 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); diff --git a/src/rgw/rgw_cr_tools.cc b/src/rgw/rgw_cr_tools.cc index 27806e164934..94665a35aaa6 100644 --- a/src/rgw/rgw_cr_tools.cc +++ b/src/rgw/rgw_cr_tools.cc @@ -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); } } diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 0fe9fc09e274..079eab63b9d4 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 6f45b353ce33..414417fbb608 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index f584d78a718b..aa3ea4fdb421 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -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(); diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index f31abae145f1..f7f910d2b494 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -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; } diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h index 61bd25261aa9..c29bac936d07 100644 --- a/src/rgw/rgw_quota.h +++ b/src/rgw/rgw_quota.h @@ -35,6 +35,7 @@ namespace rgw { namespace sal { class Store; } } + struct RGWQuotaInfo { template 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, + RGWQuota& quota, 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, diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b9375d50ce1a..a56775f18060 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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, + RGWQuota& quota, 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, diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index f145c54da3d2..41e06192b35e 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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, + RGWQuota& quota, uint64_t obj_size, optional_yield y, bool check_size_only = false); int check_bucket_shards(const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, diff --git a/src/rgw/rgw_rest_config.cc b/src/rgw/rgw_rest_config.cc index d28637cbd547..db8eab4cc72a 100644 --- a/src/rgw/rgw_rest_config.cc +++ b/src/rgw/rgw_rest_config.cc @@ -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); diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index b28c1cf5d4be..c226cbc0c84f 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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(user_info.user_quota.max_size)); - dump_header(s, "X-RGW-Quota-User-Objects", static_cast(user_info.user_quota.max_objects)); + dump_header(s, "X-RGW-Quota-User-Size", static_cast(user_info.quota.user_quota.max_size)); + dump_header(s, "X-RGW-Quota-User-Objects", static_cast(user_info.quota.user_quota.max_objects)); dump_header(s, "X-RGW-Quota-Max-Buckets", static_cast(user_info.max_buckets)); - dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast(user_info.bucket_quota.max_size)); - dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast(user_info.bucket_quota.max_objects)); + dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast(user_info.quota.bucket_quota.max_size)); + dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast(user_info.quota.bucket_quota.max_objects)); } } diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 6d533931a7a1..858397079b1b 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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(*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(*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::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(*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) { diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index e5fd846132ca..78b06d365ed6 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -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, "a.max_objects); diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index db7b0f586e3a..0a338e5ce42e 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -352,7 +352,7 @@ class Store { virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type, const std::map& 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(RGWQuota& quota) = 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, RGWQuota& quota, 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; diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index e0b0aa3224a2..46b5f10653d8 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -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, RGWQuota& quota, 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(RGWQuota& quota) { // XXX: Not handled for the first pass return; diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index 5cd3fbc8015a..75723d11a840 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -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, RGWQuota& quota, 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& 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(RGWQuota& quota) override; virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, std::vector& buckets, bool enabled) override; virtual uint64_t get_new_req_id() override { return 0; } virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp, diff --git a/src/rgw/rgw_sal_motr.cc b/src/rgw/rgw_sal_motr.cc index 9e0668c33aae..92b817fe7758 100644 --- a/src/rgw/rgw_sal_motr.cc +++ b/src/rgw/rgw_sal_motr.cc @@ -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, RGWQuota& quota, 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(RGWQuota& quota) { // XXX: Not handled for the first pass return; diff --git a/src/rgw/rgw_sal_motr.h b/src/rgw/rgw_sal_motr.h index aa9b86ed5f05..8635462687e3 100644 --- a/src/rgw/rgw_sal_motr.h +++ b/src/rgw/rgw_sal_motr.h @@ -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, RGWQuota& quota, 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& 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(RGWQuota& quota) override; virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, std::vector& buckets, bool enabled) override; virtual uint64_t get_new_req_id() override { return 0; } virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp, diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 0e9c3e2648ad..a0b41e800cb7 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -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, RGWQuota& quota, 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(RGWQuota& quota) { - 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) diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index a0aea9ce03eb..156fc6e6c03f 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -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& meta) override; - virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) override; + virtual void get_quota(RGWQuota& quota) 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& 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, RGWQuota& quota, 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, diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 24efdc7cb17f..580c429b5c12 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -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(); diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index 68bbcb552042..b9f25d323aec 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -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& get_mfa_ids() { return mfa_ids; } rgw::sal::User* get_user() { return user.get(); } diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index c8e8d09b8879..8265371c0140 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -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); } diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index 9e89cbf150a7..6e1176ac511e 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -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) { diff --git a/src/rgw/services/svc_quota.cc b/src/rgw/services/svc_quota.cc index c7164964cdf2..0487a6ec95c2 100644 --- a/src/rgw/services/svc_quota.cc +++ b/src/rgw/services/svc_quota.cc @@ -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; } diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index 5280371ad237..ab77f6aef6ee 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -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); diff --git a/src/rgw/store/dbstore/sqlite/sqliteDB.cc b/src/rgw/store/dbstore/sqlite/sqliteDB.cc index 347958abf16c..6668173414a9 100644 --- a/src/rgw/store/dbstore/sqlite/sqliteDB.cc +++ b/src/rgw/store/dbstore/sqlite/sqliteDB.cc @@ -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);