From: Yehuda Sadeh Date: Wed, 7 Jan 2015 23:30:27 +0000 (-0800) Subject: rgw: max shards configuration is part of the zone config X-Git-Tag: v0.92~12^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=37a11862d27014f6aa052d86fdd6397353e0b5de;p=ceph.git rgw: max shards configuration is part of the zone config The zone config params are set in the region configuration. Also, there's a ceph.conf configurable (rgw_override_bucket_index_max_shards) for overriding this per rgw. Signed-off-by: Yehuda Sadeh --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index ea2ac25e61c5..d7c152d53882 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -843,13 +843,15 @@ OPTION(nss_db_path, OPT_STR, "") // path to nss db OPTION(rgw_max_chunk_size, OPT_INT, 512 * 1024) /** + * override max bucket index shards in zone configuration (if not zero) + * * Represents the number of shards for the bucket index object, a value of zero * indicates there is no sharding. By default (no sharding, the name of the object * is '.dir.{marker}', with sharding, the name is '.dir.{markder}.{sharding_id}', * sharding_id is zero-based value. It is not recommended to set a too large value * (e.g. thousand) as it increases the cost for bucket listing. */ -OPTION(rgw_bucket_index_max_shards, OPT_U32, 0) +OPTION(rgw_override_bucket_index_max_shards, OPT_U32, 0) /** * Represents the maximum AIO pending requests for the bucket index object shards. diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 4a2922780da9..f4ce380d20cd 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -664,6 +664,7 @@ void RGWZone::dump(Formatter *f) const encode_json("endpoints", endpoints, f); encode_json("log_meta", log_meta, f); encode_json("log_data", log_data, f); + encode_json("bucket_index_max_shards", bucket_index_max_shards, f); } void RGWZone::decode_json(JSONObj *obj) @@ -672,6 +673,7 @@ void RGWZone::decode_json(JSONObj *obj) JSONDecoder::decode_json("endpoints", endpoints, obj); JSONDecoder::decode_json("log_meta", log_meta, obj); JSONDecoder::decode_json("log_data", log_data, obj); + JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards, obj); } void RGWRegionPlacementTarget::dump(Formatter *f) const diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 6ab472a2fb4c..66d4d1c20833 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1327,14 +1327,6 @@ int RGWRados::init_rados() { int ret; - bucket_index_max_shards = cct->_conf->rgw_bucket_index_max_shards; - if (bucket_index_max_shards > MAX_BUCKET_INDEX_SHARDS_PRIME) { - bucket_index_max_shards = MAX_BUCKET_INDEX_SHARDS_PRIME; - ldout(cct, 1) << __func__ << " bucket index max shards is too large, reset to value: " - << MAX_BUCKET_INDEX_SHARDS_PRIME << dendl; - } - ldout(cct, 20) << __func__ << " bucket index max shards: " << bucket_index_max_shards << dendl; - rados = new Rados(); if (!rados) return -ENOMEM; @@ -1455,6 +1447,15 @@ int RGWRados::init_complete() quota_handler = RGWQuotaHandler::generate_handler(this, quota_threads); + bucket_index_max_shards = (cct->_conf->rgw_override_bucket_index_max_shards ? cct->_conf->rgw_override_bucket_index_max_shards : + zone_public_config.bucket_index_max_shards); + if (bucket_index_max_shards > MAX_BUCKET_INDEX_SHARDS_PRIME) { + bucket_index_max_shards = MAX_BUCKET_INDEX_SHARDS_PRIME; + ldout(cct, 1) << __func__ << " bucket index max shards is too large, reset to value: " + << MAX_BUCKET_INDEX_SHARDS_PRIME << dendl; + } + ldout(cct, 20) << __func__ << " bucket index max shards: " << bucket_index_max_shards << dendl; + return ret; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index ef387dabc8cf..929b025e6d13 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -912,14 +912,24 @@ struct RGWZone { bool log_meta; bool log_data; - RGWZone() : log_meta(false), log_data(false) {} +/** + * Represents the number of shards for the bucket index object, a value of zero + * indicates there is no sharding. By default (no sharding, the name of the object + * is '.dir.{marker}', with sharding, the name is '.dir.{markder}.{sharding_id}', + * sharding_id is zero-based value. It is not recommended to set a too large value + * (e.g. thousand) as it increases the cost for bucket listing. + */ + uint32_t bucket_index_max_shards; + + RGWZone() : log_meta(false), log_data(false), bucket_index_max_shards(0) {} void encode(bufferlist& bl) const { - ENCODE_START(2, 1, bl); + ENCODE_START(3, 1, bl); ::encode(name, bl); ::encode(endpoints, bl); ::encode(log_meta, bl); ::encode(log_data, bl); + ::encode(bucket_index_max_shards, bl); ENCODE_FINISH(bl); } @@ -931,6 +941,9 @@ struct RGWZone { ::decode(log_meta, bl); ::decode(log_data, bl); } + if (struct_v >= 3) { + ::decode(bucket_index_max_shards, bl); + } DECODE_FINISH(bl); } void dump(Formatter *f) const;