Skip to content

Commit

Permalink
Merge pull request #10655 from dachary/wip-16163-jewel
Browse files Browse the repository at this point in the history
jewel: rgw: can set negative max_buckets on RGWUserInfo
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
  • Loading branch information
oritwas committed Aug 22, 2016
2 parents 1bf76cd + 96ad2d1 commit 46106f0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/common/config_opts.h
Expand Up @@ -1405,7 +1405,7 @@ OPTION(rgw_multipart_part_upload_limit, OPT_INT, 10000) // parts limit in multip
OPTION(rgw_max_slo_entries, OPT_INT, 1000) // default number of max entries in slo

OPTION(rgw_olh_pending_timeout_sec, OPT_INT, 3600) // time until we retire a pending olh change
OPTION(rgw_user_max_buckets, OPT_U32, 1000) // global option to set max buckets count for all user
OPTION(rgw_user_max_buckets, OPT_INT, 1000) // global option to set max buckets count for all user

OPTION(rgw_objexp_gc_interval, OPT_U32, 60 * 10) // maximum time between round of expired objects garbage collecting
OPTION(rgw_objexp_time_step, OPT_U32, 4096) // number of seconds for rounding the timestamps
Expand Down
4 changes: 3 additions & 1 deletion src/rgw/rgw_admin.cc
Expand Up @@ -2001,6 +2001,7 @@ int main(int argc, char **argv)
int remove_bad = false;
int check_head_obj_locator = false;
int max_buckets = -1;
bool max_buckets_specified = false;
map<string, bool> categories;
string caps;
int check_objects = false;
Expand Down Expand Up @@ -2139,6 +2140,7 @@ int main(int argc, char **argv)
cerr << "ERROR: failed to parse max buckets: " << err << std::endl;
return EINVAL;
}
max_buckets_specified = true;
} else if (ceph_argparse_witharg(args, i, &val, "--max-entries", (char*)NULL)) {
max_entries = (int)strict_strtol(val.c_str(), 10, &err);
if (!err.empty()) {
Expand Down Expand Up @@ -3634,7 +3636,7 @@ int main(int argc, char **argv)
if (gen_secret_key)
user_op.set_gen_secret(); // assume that a key pair should be created

if (max_buckets >= 0)
if (max_buckets_specified)
user_op.set_max_buckets(max_buckets);

if (system_specified)
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_common.h
Expand Up @@ -535,7 +535,7 @@ struct RGWUserInfo
map<string, RGWAccessKey> swift_keys;
map<string, RGWSubUser> subusers;
__u8 suspended;
uint32_t max_buckets;
int32_t max_buckets;
uint32_t op_mask;
RGWUserCaps caps;
__u8 system;
Expand Down
3 changes: 3 additions & 0 deletions src/rgw/rgw_op.cc
Expand Up @@ -1795,6 +1795,9 @@ int RGWCreateBucket::verify_permission()
<< dendl;
return -EACCES;
}
if (s->user->max_buckets < 0) {
return -EPERM;
}

if (s->user->max_buckets) {
RGWUserBuckets buckets;
Expand Down
10 changes: 5 additions & 5 deletions src/rgw/rgw_rest_user.cc
Expand Up @@ -73,8 +73,8 @@ void RGWOp_User_Create::execute()
bool system;
bool exclusive;

uint32_t max_buckets;
uint32_t default_max_buckets = s->cct->_conf->rgw_user_max_buckets;
int32_t max_buckets;
int32_t default_max_buckets = s->cct->_conf->rgw_user_max_buckets;

RGWUserAdminOpState op_state;

Expand All @@ -89,7 +89,7 @@ void RGWOp_User_Create::execute()
RESTArgs::get_string(s, "user-caps", caps, &caps);
RESTArgs::get_bool(s, "generate-key", true, &gen_key);
RESTArgs::get_bool(s, "suspended", false, &suspended);
RESTArgs::get_uint32(s, "max-buckets", default_max_buckets, &max_buckets);
RESTArgs::get_int32(s, "max-buckets", default_max_buckets, &max_buckets);
RESTArgs::get_bool(s, "system", false, &system);
RESTArgs::get_bool(s, "exclusive", false, &exclusive);

Expand Down Expand Up @@ -174,7 +174,7 @@ void RGWOp_User_Modify::execute()
bool suspended;
bool system;

uint32_t max_buckets;
int32_t max_buckets;

RGWUserAdminOpState op_state;

Expand All @@ -188,7 +188,7 @@ void RGWOp_User_Modify::execute()
RESTArgs::get_string(s, "user-caps", caps, &caps);
RESTArgs::get_bool(s, "generate-key", false, &gen_key);
RESTArgs::get_bool(s, "suspended", false, &suspended);
RESTArgs::get_uint32(s, "max-buckets", RGW_DEFAULT_MAX_BUCKETS, &max_buckets);
RESTArgs::get_int32(s, "max-buckets", RGW_DEFAULT_MAX_BUCKETS, &max_buckets);
RESTArgs::get_string(s, "key-type", key_type_str, &key_type_str);

RESTArgs::get_bool(s, "system", false, &system);
Expand Down
6 changes: 3 additions & 3 deletions src/rgw/rgw_user.h
Expand Up @@ -157,7 +157,7 @@ struct RGWUserAdminOpState {
rgw_user user_id;
std::string user_email;
std::string display_name;
uint32_t max_buckets;
int32_t max_buckets;
__u8 suspended;
__u8 system;
__u8 exclusive;
Expand Down Expand Up @@ -335,7 +335,7 @@ struct RGWUserAdminOpState {
info = user_info;
}

void set_max_buckets(uint32_t mb) {
void set_max_buckets(int32_t mb) {
max_buckets = mb;
max_buckets_specified = true;
}
Expand Down Expand Up @@ -410,7 +410,7 @@ struct RGWUserAdminOpState {
__u8 get_suspension_status() { return suspended; }
int32_t get_key_type() {return key_type; }
uint32_t get_subuser_perm() { return perm_mask; }
uint32_t get_max_buckets() { return max_buckets; }
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; }
Expand Down

0 comments on commit 46106f0

Please sign in to comment.