]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add a new field to bucket info indicating the number of shards of this bucket and...
authorGuang Yang <yguang@yahoo-inc.com>
Mon, 28 Jul 2014 07:40:26 +0000 (07:40 +0000)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 03:21:22 +0000 (19:21 -0800)
Signed-off-by: Guang Yang (yguang@yahoo-inc.com)
src/common/config_opts.h
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index e4e6de21e2bd795c911e4afd1fb33d3a537cef2e..e0727e4de8e4fcd90dd61b068cbe86f8d2ae25a0 100644 (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
index 0a68a3b2f54fc9883561ca0f6e37297fb1548da8..cc816e862fb914fb44be056ed1015028bfff688f 100644 (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);
index 589b7dd995329c91d182e7885633bdd25113c511..5b3cfbde1edb3b2850b20be3981fc31ea0b4f120 100644 (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;
index cd731b78a5920a36a14055e8baf0a563ff2e1c41..4ba73f75db634dcc9fd994a552116e757867aff9 100644 (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
index df9191ea15d1c0f7dfdaa74ebdf978da6813b2dd..7a283e0fa9aa678c86b48d44b37d89e1ecba7dbb 100644 (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;
index d397a1f15e66223a9c886701e54584ae4508f519..62ac3fa92cda15d97ba3e0b334501b229814354d 100644 (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),