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)
This commit is contained in:
Guang Yang 2014-07-28 07:40:26 +00:00 committed by Yehuda Sadeh
parent d784bc47c4
commit 90a3920c44
6 changed files with 37 additions and 1 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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),