Skip to content

Commit 5e98b8b

Browse files
committed
rgw: user_quota and bucket_quota are defined under RGWQuota
struct RGWQuota { RGWQuotaInfo user_quota; RGWQuotaInfo bucket_quota; }; Signed-off-by: Iqbal Khan <[email protected]>
1 parent cc5354e commit 5e98b8b

30 files changed

+177
-177
lines changed

src/rgw/rgw_admin.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,9 @@ int set_user_bucket_quota(OPT opt_cmd, RGWUser& user, RGWUserAdminOpState& op_st
15401540
{
15411541
RGWUserInfo& user_info = op_state.get_user_info();
15421542

1543-
set_quota_info(user_info.bucket_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
1543+
set_quota_info(user_info.quota.bucket_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
15441544

1545-
op_state.set_bucket_quota(user_info.bucket_quota);
1545+
op_state.set_bucket_quota(user_info.quota.bucket_quota);
15461546

15471547
string err;
15481548
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
15581558
{
15591559
RGWUserInfo& user_info = op_state.get_user_info();
15601560

1561-
set_quota_info(user_info.user_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
1561+
set_quota_info(user_info.quota.user_quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
15621562

1563-
op_state.set_user_quota(user_info.user_quota);
1563+
op_state.set_user_quota(user_info.quota.user_quota);
15641564

15651565
string err;
15661566
int r = user.modify(dpp(), op_state, null_yield, &err);
@@ -4639,19 +4639,19 @@ int main(int argc, const char **argv)
46394639

46404640
formatter->open_object_section("period_config");
46414641
if (quota_scope == "bucket") {
4642-
set_quota_info(period_config.bucket_quota, opt_cmd,
4642+
set_quota_info(period_config.quota.bucket_quota, opt_cmd,
46434643
max_size, max_objects,
46444644
have_max_size, have_max_objects);
4645-
encode_json("bucket quota", period_config.bucket_quota, formatter.get());
4645+
encode_json("bucket quota", period_config.quota.bucket_quota, formatter.get());
46464646
} else if (quota_scope == "user") {
4647-
set_quota_info(period_config.user_quota, opt_cmd,
4647+
set_quota_info(period_config.quota.user_quota, opt_cmd,
46484648
max_size, max_objects,
46494649
have_max_size, have_max_objects);
4650-
encode_json("user quota", period_config.user_quota, formatter.get());
4650+
encode_json("user quota", period_config.quota.user_quota, formatter.get());
46514651
} else if (quota_scope.empty() && opt_cmd == OPT::GLOBAL_QUOTA_GET) {
46524652
// if no scope is given for GET, print both
4653-
encode_json("bucket quota", period_config.bucket_quota, formatter.get());
4654-
encode_json("user quota", period_config.user_quota, formatter.get());
4653+
encode_json("bucket quota", period_config.quota.bucket_quota, formatter.get());
4654+
encode_json("user quota", period_config.quota.user_quota, formatter.get());
46554655
} else {
46564656
cerr << "ERROR: invalid quota scope specification. Please specify "
46574657
"either --quota-scope=bucket, or --quota-scope=user" << std::endl;

src/rgw/rgw_auth.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ void rgw::auth::WebIdentityApplier::create_account(const DoutPrefixProvider* dpp
373373
user->get_info().type = TYPE_WEB;
374374
user->get_info().max_buckets =
375375
cct->_conf.get_val<int64_t>("rgw_user_max_buckets");
376-
rgw_apply_default_bucket_quota(user->get_info().bucket_quota, cct->_conf);
377-
rgw_apply_default_user_quota(user->get_info().user_quota, cct->_conf);
376+
rgw_apply_default_bucket_quota(user->get_info().quota.bucket_quota, cct->_conf);
377+
rgw_apply_default_user_quota(user->get_info().quota.user_quota, cct->_conf);
378378

379379
int ret = user->store_user(dpp, null_yield, true);
380380
if (ret < 0) {
@@ -650,8 +650,8 @@ void rgw::auth::RemoteApplier::create_account(const DoutPrefixProvider* dpp,
650650
}
651651
user->get_info().max_buckets =
652652
cct->_conf.get_val<int64_t>("rgw_user_max_buckets");
653-
rgw_apply_default_bucket_quota(user->get_info().bucket_quota, cct->_conf);
654-
rgw_apply_default_user_quota(user->get_info().user_quota, cct->_conf);
653+
rgw_apply_default_bucket_quota(user->get_info().quota.bucket_quota, cct->_conf);
654+
rgw_apply_default_user_quota(user->get_info().quota.user_quota, cct->_conf);
655655
user_info = user->get_info();
656656

657657
int ret = user->store_user(dpp, null_yield, true);

src/rgw/rgw_common.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,8 +2694,8 @@ void RGWUserInfo::dump(Formatter *f) const
26942694
encode_json("default_placement", default_placement.name, f);
26952695
encode_json("default_storage_class", default_placement.storage_class, f);
26962696
encode_json("placement_tags", placement_tags, f);
2697-
encode_json("bucket_quota", bucket_quota, f);
2698-
encode_json("user_quota", user_quota, f);
2697+
encode_json("bucket_quota", quota.bucket_quota, f);
2698+
encode_json("user_quota", quota.user_quota, f);
26992699
encode_json("temp_url_keys", temp_url_keys, f);
27002700

27012701
string user_source_type;
@@ -2753,8 +2753,8 @@ void RGWUserInfo::decode_json(JSONObj *obj)
27532753
JSONDecoder::decode_json("default_placement", default_placement.name, obj);
27542754
JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
27552755
JSONDecoder::decode_json("placement_tags", placement_tags, obj);
2756-
JSONDecoder::decode_json("bucket_quota", bucket_quota, obj);
2757-
JSONDecoder::decode_json("user_quota", user_quota, obj);
2756+
JSONDecoder::decode_json("bucket_quota", quota.bucket_quota, obj);
2757+
JSONDecoder::decode_json("user_quota", quota.user_quota, obj);
27582758
JSONDecoder::decode_json("temp_url_keys", temp_url_keys, obj);
27592759

27602760
string user_source_type;

src/rgw/rgw_common.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,8 @@ struct RGWUserInfo
748748
__u8 system;
749749
rgw_placement_rule default_placement;
750750
std::list<std::string> placement_tags;
751-
RGWQuotaInfo bucket_quota;
752751
std::map<int, std::string> temp_url_keys;
753-
RGWQuotaInfo user_quota;
752+
RGWQuota quota;
754753
uint32_t type;
755754
std::set<std::string> mfa_ids;
756755
std::string assumed_role_arn;
@@ -811,9 +810,9 @@ struct RGWUserInfo
811810
encode(system, bl);
812811
encode(default_placement, bl);
813812
encode(placement_tags, bl);
814-
encode(bucket_quota, bl);
813+
encode(quota.bucket_quota, bl);
815814
encode(temp_url_keys, bl);
816-
encode(user_quota, bl);
815+
encode(quota.user_quota, bl);
817816
encode(user_id.tenant, bl);
818817
encode(admin, bl);
819818
encode(type, bl);
@@ -879,13 +878,13 @@ struct RGWUserInfo
879878
decode(placement_tags, bl); /* tags of allowed placement rules */
880879
}
881880
if (struct_v >= 14) {
882-
decode(bucket_quota, bl);
881+
decode(quota.bucket_quota, bl);
883882
}
884883
if (struct_v >= 15) {
885884
decode(temp_url_keys, bl);
886885
}
887886
if (struct_v >= 16) {
888-
decode(user_quota, bl);
887+
decode(quota.user_quota, bl);
889888
}
890889
if (struct_v >= 17) {
891890
decode(user_id.tenant, bl);

src/rgw/rgw_cr_tools.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,34 @@ int RGWUserCreateCR::Request::_send_request(const DoutPrefixProvider *dpp)
5656

5757

5858
if (params.apply_quota) {
59-
RGWQuotaInfo bucket_quota;
60-
RGWQuotaInfo user_quota;
59+
RGWQuota quota;
6160

6261
if (cct->_conf->rgw_bucket_default_quota_max_objects >= 0) {
63-
bucket_quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
64-
bucket_quota.enabled = true;
62+
quota.bucket_quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
63+
quota.bucket_quota.enabled = true;
6564
}
6665

6766
if (cct->_conf->rgw_bucket_default_quota_max_size >= 0) {
68-
bucket_quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
69-
bucket_quota.enabled = true;
67+
quota.bucket_quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
68+
quota.bucket_quota.enabled = true;
7069
}
7170

7271
if (cct->_conf->rgw_user_default_quota_max_objects >= 0) {
73-
user_quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
74-
user_quota.enabled = true;
72+
quota.user_quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
73+
quota.user_quota.enabled = true;
7574
}
7675

7776
if (cct->_conf->rgw_user_default_quota_max_size >= 0) {
78-
user_quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
79-
user_quota.enabled = true;
77+
quota.user_quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
78+
quota.user_quota.enabled = true;
8079
}
8180

82-
if (bucket_quota.enabled) {
83-
op_state.set_bucket_quota(bucket_quota);
81+
if (quota.bucket_quota.enabled) {
82+
op_state.set_bucket_quota(quota.bucket_quota);
8483
}
8584

86-
if (user_quota.enabled) {
87-
op_state.set_user_quota(user_quota);
85+
if (quota.user_quota.enabled) {
86+
op_state.set_user_quota(quota.user_quota);
8887
}
8988
}
9089

src/rgw/rgw_file.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ namespace rgw {
19041904
return -EIO;
19051905
}
19061906

1907-
op_ret = state->bucket->check_quota(this, user_quota, bucket_quota, real_ofs, null_yield, true);
1907+
op_ret = state->bucket->check_quota(this, quota, real_ofs, null_yield, true);
19081908
/* max_size exceed */
19091909
if (op_ret < 0)
19101910
return -EIO;
@@ -1946,7 +1946,7 @@ namespace rgw {
19461946
goto done;
19471947
}
19481948

1949-
op_ret = state->bucket->check_quota(this, user_quota, bucket_quota, state->obj_size, null_yield, true);
1949+
op_ret = state->bucket->check_quota(this, quota, state->obj_size, null_yield, true);
19501950
/* max_size exceed */
19511951
if (op_ret < 0) {
19521952
goto done;

src/rgw/rgw_op.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,18 +1357,19 @@ int RGWOp::init_quota()
13571357
if (r < 0)
13581358
return r;
13591359
user = owner_user.get();
1360+
13601361
}
13611362

1362-
store->get_quota(bucket_quota, user_quota);
1363+
store->get_quota(quota);
13631364

13641365
if (s->bucket->get_info().quota.enabled) {
1365-
bucket_quota = s->bucket->get_info().quota;
1366-
} else if (user->get_info().bucket_quota.enabled) {
1367-
bucket_quota = user->get_info().bucket_quota;
1366+
quota.bucket_quota = s->bucket->get_info().quota;
1367+
} else if (user->get_info().quota.bucket_quota.enabled) {
1368+
quota.bucket_quota = user->get_info().quota.bucket_quota;
13681369
}
13691370

1370-
if (user->get_info().user_quota.enabled) {
1371-
user_quota = user->get_info().user_quota;
1371+
if (user->get_info().quota.user_quota.enabled) {
1372+
quota.user_quota = user->get_info().quota.user_quota;
13721373
}
13731374

13741375
return 0;
@@ -3896,7 +3897,7 @@ void RGWPutObj::execute(optional_yield y)
38963897

38973898
if (!chunked_upload) { /* with chunked upload we don't know how big is the upload.
38983899
we also check sizes at the end anyway */
3899-
op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->content_length, y);
3900+
op_ret = s->bucket->check_quota(this, quota, s->content_length, y);
39003901
if (op_ret < 0) {
39013902
ldpp_dout(this, 20) << "check_quota() returned ret=" << op_ret << dendl;
39023903
return;
@@ -4119,7 +4120,7 @@ void RGWPutObj::execute(optional_yield y)
41194120
return;
41204121
}
41214122

4122-
op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->obj_size, y);
4123+
op_ret = s->bucket->check_quota(this, quota, s->obj_size, y);
41234124
if (op_ret < 0) {
41244125
ldpp_dout(this, 20) << "second check_quota() returned op_ret=" << op_ret << dendl;
41254126
return;
@@ -4339,7 +4340,7 @@ void RGWPostObj::execute(optional_yield y)
43394340
ceph::buffer::list bl, aclbl;
43404341
int len = 0;
43414342

4342-
op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->content_length, y);
4343+
op_ret = s->bucket->check_quota(this, quota, s->content_length, y);
43434344
if (op_ret < 0) {
43444345
return;
43454346
}
@@ -4444,7 +4445,7 @@ void RGWPostObj::execute(optional_yield y)
44444445
s->object->set_obj_size(ofs);
44454446

44464447

4447-
op_ret = s->bucket->check_quota(this, user_quota, bucket_quota, s->obj_size, y);
4448+
op_ret = s->bucket->check_quota(this, quota, s->obj_size, y);
44484449
if (op_ret < 0) {
44494450
return;
44504451
}
@@ -4620,7 +4621,7 @@ void RGWPutMetadataAccount::execute(optional_yield y)
46204621

46214622
/* Handle the quota extracted at the verify_permission step. */
46224623
if (new_quota_extracted) {
4623-
s->user->get_info().user_quota = std::move(new_quota);
4624+
s->user->get_info().quota.user_quota = std::move(new_quota);
46244625
}
46254626

46264627
/* We are passing here the current (old) user info to allow the function
@@ -5471,8 +5472,7 @@ void RGWCopyObj::execute(optional_yield y)
54715472
return;
54725473
}
54735474
// enforce quota against the destination bucket owner
5474-
op_ret = dest_bucket->check_quota(this, user_quota, bucket_quota,
5475-
astate->accounted_size, y);
5475+
op_ret = dest_bucket->check_quota(this, quota, astate->accounted_size, y);
54765476
if (op_ret < 0) {
54775477
return;
54785478
}
@@ -7412,7 +7412,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path,
74127412
return op_ret;
74137413
}
74147414

7415-
op_ret = bucket->check_quota(this, user_quota, bucket_quota, size, y);
7415+
op_ret = bucket->check_quota(this, quota, size, y);
74167416
if (op_ret < 0) {
74177417
return op_ret;
74187418
}
@@ -7490,7 +7490,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path,
74907490
return op_ret;
74917491
}
74927492

7493-
op_ret = bucket->check_quota(this, user_quota, bucket_quota, size, y);
7493+
op_ret = bucket->check_quota(this, quota, size, y);
74947494
if (op_ret < 0) {
74957495
ldpp_dout(this, 20) << "quota exceeded for path=" << path << dendl;
74967496
return op_ret;

src/rgw/rgw_op.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ class RGWOp : public DoutPrefixProvider {
178178
rgw::sal::Store* store;
179179
RGWCORSConfiguration bucket_cors;
180180
bool cors_exist;
181-
RGWQuotaInfo bucket_quota;
182-
RGWQuotaInfo user_quota;
181+
RGWQuota quota;
183182
int op_ret;
184183
int do_aws4_auth_completion();
185184

src/rgw/rgw_quota.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,12 @@ class RGWQuotaHandlerImpl : public RGWQuotaHandler {
903903

904904
int check_quota(const DoutPrefixProvider *dpp,
905905
const rgw_user& user,
906-
rgw_bucket& bucket,
907-
RGWQuotaInfo& user_quota,
908-
RGWQuotaInfo& bucket_quota,
909-
uint64_t num_objs,
910-
uint64_t size, optional_yield y) override {
906+
rgw_bucket& bucket,
907+
RGWQuota& quota,
908+
uint64_t num_objs,
909+
uint64_t size, optional_yield y) override {
911910

912-
if (!bucket_quota.enabled && !user_quota.enabled) {
911+
if (!quota.bucket_quota.enabled && !quota.user_quota.enabled) {
913912
return 0;
914913
}
915914

@@ -921,25 +920,25 @@ class RGWQuotaHandlerImpl : public RGWQuotaHandler {
921920
*/
922921

923922
const DoutPrefix dp(store->ctx(), dout_subsys, "rgw quota handler: ");
924-
if (bucket_quota.enabled) {
923+
if (quota.bucket_quota.enabled) {
925924
RGWStorageStats bucket_stats;
926925
int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, y, &dp);
927926
if (ret < 0) {
928927
return ret;
929928
}
930-
ret = check_quota(dpp, "bucket", bucket_quota, bucket_stats, num_objs, size);
929+
ret = check_quota(dpp, "bucket", quota.bucket_quota, bucket_stats, num_objs, size);
931930
if (ret < 0) {
932931
return ret;
933932
}
934933
}
935934

936-
if (user_quota.enabled) {
935+
if (quota.user_quota.enabled) {
937936
RGWStorageStats user_stats;
938937
int ret = user_stats_cache.get_stats(user, bucket, user_stats, y, &dp);
939938
if (ret < 0) {
940939
return ret;
941940
}
942-
ret = check_quota(dpp, "user", user_quota, user_stats, num_objs, size);
941+
ret = check_quota(dpp, "user", quota.user_quota, user_stats, num_objs, size);
943942
if (ret < 0) {
944943
return ret;
945944
}

src/rgw/rgw_quota.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace rgw { namespace sal {
3535
class Store;
3636
} }
3737

38+
3839
struct RGWQuotaInfo {
3940
template<class T> friend class RGWQuotaCache;
4041
public:
@@ -89,6 +90,12 @@ struct RGWQuotaInfo {
8990
};
9091
WRITE_CLASS_ENCODER(RGWQuotaInfo)
9192

93+
struct RGWQuota {
94+
RGWQuotaInfo user_quota;
95+
RGWQuotaInfo bucket_quota;
96+
};
97+
98+
9299
struct rgw_bucket;
93100

94101
class RGWQuotaHandler {
@@ -97,7 +104,7 @@ class RGWQuotaHandler {
97104
virtual ~RGWQuotaHandler() {
98105
}
99106
virtual int check_quota(const DoutPrefixProvider *dpp, const rgw_user& bucket_owner, rgw_bucket& bucket,
100-
RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota,
107+
RGWQuota& quota,
101108
uint64_t num_objs, uint64_t size, optional_yield y) = 0;
102109

103110
virtual void check_bucket_shards(const DoutPrefixProvider *dpp, uint64_t max_objs_per_shard, uint64_t num_shards,

0 commit comments

Comments
 (0)