]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: max shards configuration is part of the zone config
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 7 Jan 2015 23:30:27 +0000 (15:30 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 03:21:27 +0000 (19:21 -0800)
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 <yehuda@redhat.com>
src/common/config_opts.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index ea2ac25e61c53c14827c907fcfb5bf81fa5978d0..d7c152d5388204186a83897d2ea70827928fa35e 100644 (file)
@@ -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.
index 4a2922780da9ad85a81cb6f99952a8a8674e9e80..f4ce380d20cdc9616663f3a02a977037185c8e72 100644 (file)
@@ -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
index 6ab472a2fb4c1f3a72b56fd270a0f64830872787..66d4d1c2083307050fa48097bb75e6c9267f4204 100644 (file)
@@ -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;
 }
 
index ef387dabc8cf020fda5c5ae1947c897592e628c7..929b025e6d13dbeaeb3c08478c8572c22874b817 100644 (file)
@@ -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;