From: Guang Yang Date: Mon, 28 Jul 2014 07:40:26 +0000 (+0000) Subject: Add a new field to bucket info indicating the number of shards of this bucket and... X-Git-Tag: v0.92~12^2~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=90a3920c4480596c4bbc6ae4946437007ae7f99d;p=ceph.git Add a new field to bucket info indicating the number of shards of this bucket and make it configurable. Signed-off-by: Guang Yang (yguang@yahoo-inc.com) --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index e4e6de21e2bd..e0727e4de8e4 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -842,6 +842,15 @@ OPTION(nss_db_path, OPT_STR, "") // path to nss db OPTION(rgw_max_chunk_size, OPT_INT, 512 * 1024) +/** + * 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_data, OPT_STR, "/var/lib/ceph/radosgw/$cluster-$id") OPTION(rgw_enable_apis, OPT_STR, "s3, swift, swift_auth, admin") OPTION(rgw_cache_enabled, OPT_BOOL, true) // rgw cache enabled diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 0a68a3b2f54f..cc816e862fb9 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -26,6 +26,8 @@ PerfCounters *perfcounter = NULL; +const uint32_t RGWBucketInfo::NUM_SHARDS_BLIND_BUCKET(UINT32_MAX); + int rgw_perf_start(CephContext *cct) { PerfCountersBuilder plb(cct, cct->_conf->name.to_str(), l_rgw_first, l_rgw_last); diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 589b7dd99532..5b3cfbde1edb 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -140,6 +140,10 @@ using ceph::crypto::MD5; #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295) +#endif + typedef void *RGWAccessHandle; @@ -732,8 +736,17 @@ struct RGWBucketInfo obj_version ep_objv; /* entry point object version, for runtime tracking only */ RGWQuotaInfo quota; + // Represents the number of bucket index object shards: + // - value of 0 indicates there is no sharding (this is by default before this + // feature is implemented). + // - value of UINT32_T::MAX indicates this is a blind bucket. + uint32_t num_shards; + + // Represents the shard number for blind bucket. + const static uint32_t NUM_SHARDS_BLIND_BUCKET; + void encode(bufferlist& bl) const { - ENCODE_START(9, 4, bl); + ENCODE_START(10, 4, bl); ::encode(bucket, bl); ::encode(owner, bl); ::encode(flags, bl); @@ -743,6 +756,7 @@ struct RGWBucketInfo ::encode(placement_rule, bl); ::encode(has_instance_obj, bl); ::encode(quota, bl); + ::encode(num_shards, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { @@ -765,6 +779,8 @@ struct RGWBucketInfo ::decode(has_instance_obj, bl); if (struct_v >= 9) ::decode(quota, bl); + if (struct_v >= 10) + ::decode(num_shards, bl); DECODE_FINISH(bl); } void dump(Formatter *f) const; diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index cd731b78a592..4ba73f75db63 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -545,6 +545,7 @@ void RGWBucketInfo::dump(Formatter *f) const encode_json("placement_rule", placement_rule, f); encode_json("has_instance_obj", has_instance_obj, f); encode_json("quota", quota, f); + encode_json("num_shards", num_shards, f); } void RGWBucketInfo::decode_json(JSONObj *obj) { @@ -556,6 +557,7 @@ void RGWBucketInfo::decode_json(JSONObj *obj) { JSONDecoder::decode_json("placement_rule", placement_rule, obj); JSONDecoder::decode_json("has_instance_obj", has_instance_obj, obj); JSONDecoder::decode_json("quota", quota, obj); + JSONDecoder::decode_json("num_shards", num_shards, obj); } void RGWObjEnt::dump(Formatter *f) const diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index df9191ea15d1..7a283e0fa9aa 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1325,6 +1325,9 @@ int RGWRados::init_rados() { int ret; + bucket_index_max_shards = cct->_conf->rgw_bucket_index_max_shards; + ldout(cct, 20) << __func__ << " bucket index max shards: " << bucket_index_max_shards << dendl; + rados = new Rados(); if (!rados) return -ENOMEM; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index d397a1f15e66..62ac3fa92cda 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1293,6 +1293,9 @@ class RGWRados Mutex bucket_id_lock; + // This field represents the number of bucket index object shards + uint32_t bucket_index_max_shards; + int get_obj_ioctx(const rgw_obj& obj, librados::IoCtx *ioctx); int get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref, rgw_bucket *bucket, bool ref_system_obj = false); uint64_t max_bucket_id; @@ -1365,6 +1368,7 @@ public: num_watchers(0), watchers(NULL), watch_handles(NULL), watch_initialized(false), bucket_id_lock("rados_bucket_id"), max_bucket_id(0), + bucket_index_max_shards(0), cct(NULL), rados(NULL), pools_initialized(false), quota_handler(NULL),