From f65267c96cbd4cd25036b6bf399692e77bbb9436 Mon Sep 17 00:00:00 2001 From: Vikhyat Umrao Date: Thu, 3 Sep 2015 12:02:05 +0530 Subject: [PATCH] rgw : setting max number of buckets for users via ceph.conf option This patch adds a new option "rgw_user_max_buckets" for setting max number of buckets for users via ceph.conf. Fixes #12714 Signed-off-by: Vikhyat Umrao --- src/common/config_opts.h | 1 + src/rgw/rgw_admin.cc | 1 + src/rgw/rgw_rest_user.cc | 5 +++-- src/rgw/rgw_user.cc | 15 ++++++++------- src/test/cli/radosgw-admin/help.t | 1 + 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index f8bbdfbc0a565..a1c88b196289d 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1123,6 +1123,7 @@ OPTION(rgw_multipart_min_part_size, OPT_INT, 5 * 1024 * 1024) // min size for ea OPTION(rgw_multipart_part_upload_limit, OPT_INT, 10000) // parts limit in multipart upload 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(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter OPTION(throttler_perf_counter, OPT_BOOL, true) // enable/disable throttler perf counter diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 1140cbdbbc5f8..610275700cb83 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -125,6 +125,7 @@ void _usage() cout << " --access= Set access permissions for sub-user, should be one\n"; cout << " of read, write, readwrite, full\n"; cout << " --display-name=\n"; + cout << " --max_buckets max number of buckets for a user\n"; cout << " --system set the system flag on the user\n"; cout << " --bucket=\n"; cout << " --pool=\n"; diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index 6b5d1eb286965..6cd2591bfb5de 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -71,6 +71,7 @@ void RGWOp_User_Create::execute() bool exclusive; uint32_t max_buckets; + uint32_t default_max_buckets = s->cct->_conf->rgw_user_max_buckets; RGWUserAdminOpState op_state; @@ -83,7 +84,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", RGW_DEFAULT_MAX_BUCKETS, &max_buckets); + RESTArgs::get_uint32(s, "max-buckets", default_max_buckets, &max_buckets); RESTArgs::get_bool(s, "system", false, &system); RESTArgs::get_bool(s, "exclusive", false, &exclusive); @@ -122,7 +123,7 @@ void RGWOp_User_Create::execute() op_state.set_key_type(key_type); } - if (max_buckets != RGW_DEFAULT_MAX_BUCKETS) + if (max_buckets != default_max_buckets) op_state.set_max_buckets(max_buckets); if (s->info.args.exists("suspended")) diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 5a5328d8c1b4d..47475c3d8b5ea 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -1810,7 +1810,13 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) if (!user_email.empty()) user_info.user_email = user_email; - user_info.max_buckets = op_state.get_max_buckets(); + CephContext *cct = store->ctx(); + if (op_state.max_buckets_specified) { + user_info.max_buckets = op_state.get_max_buckets(); + } else { + user_info.max_buckets = cct->_conf->rgw_user_max_buckets; + } + user_info.suspended = op_state.get_suspension_status(); user_info.system = op_state.system; @@ -2016,13 +2022,8 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) if (!display_name.empty()) user_info.display_name = display_name; - // will be set to RGW_DEFAULT_MAX_BUCKETS by default - uint32_t max_buckets = op_state.get_max_buckets(); - - ldout(store->ctx(), 0) << "max_buckets=" << max_buckets << " specified=" << op_state.max_buckets_specified << dendl; - if (op_state.max_buckets_specified) - user_info.max_buckets = max_buckets; + user_info.max_buckets = op_state.get_max_buckets(); if (op_state.system_specified) user_info.system = op_state.system; diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index fec8737541e4b..c9eab32c2db11 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -82,6 +82,7 @@ --access= Set access permissions for sub-user, should be one of read, write, readwrite, full --display-name= + --max_buckets max number of buckets for a user --system set the system flag on the user --bucket= --pool= -- 2.39.5