]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: align head object size with pool alignment 25774/head
authorYehuda Sadeh <yehuda@redhat.com>
Sat, 19 Jan 2019 05:04:50 +0000 (21:04 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Sat, 19 Jan 2019 05:04:50 +0000 (21:04 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_putobj_processor.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index d4de1414d58936f2209c1447f801e942ac4ee2f8..cc6404e7b9d42a48073058f1e6f8322e56793004 100644 (file)
@@ -200,16 +200,17 @@ int AtomicObjectProcessor::process_first_chunk(bufferlist&& data,
 
 int AtomicObjectProcessor::prepare()
 {
-  uint64_t max_head_chunk_size = 0;
+  uint64_t max_head_chunk_size;
   uint64_t head_max_size;
   uint64_t chunk_size = 0;
+  uint64_t alignment;
   rgw_pool head_pool;
 
   if (!store->get_obj_data_pool(bucket_info.placement_rule, head_obj, &head_pool)) {
     return -EIO;
   }
 
-  int r = store->get_max_chunk_size(head_pool, &max_head_chunk_size);
+  int r = store->get_max_chunk_size(head_pool, &max_head_chunk_size, &alignment);
   if (r < 0) {
     return r;
   }
@@ -239,8 +240,12 @@ int AtomicObjectProcessor::prepare()
     chunk_size = max_head_chunk_size;
   }
 
+  uint64_t stripe_size;
   const uint64_t default_stripe_size = store->ctx()->_conf->rgw_obj_stripe_size;
-  manifest.set_trivial_rule(head_max_size, default_stripe_size);
+
+  store->get_max_aligned_size(default_stripe_size, alignment, &stripe_size);
+
+  manifest.set_trivial_rule(head_max_size, stripe_size);
 
   r = manifest_gen.create_begin(store->ctx(), &manifest,
                                 bucket_info.placement_rule,
@@ -355,28 +360,37 @@ int MultipartObjectProcessor::process_first_chunk(bufferlist&& data,
 
 int MultipartObjectProcessor::prepare_head()
 {
-  int r = manifest_gen.create_begin(store->ctx(), &manifest,
-                                    bucket_info.placement_rule,
-                                    &tail_placement_rule,
-                                    target_obj.bucket, target_obj);
+  const uint64_t default_stripe_size = store->ctx()->_conf->rgw_obj_stripe_size;
+  uint64_t chunk_size;
+  uint64_t stripe_size;
+  uint64_t alignment;
+
+  int r = store->get_max_chunk_size(tail_placement_rule, target_obj, &chunk_size, &alignment);
   if (r < 0) {
+    ldout(store->ctx(), 0) << "ERROR: unexpected: get_max_chunk_size(): placement_rule=" << tail_placement_rule.to_str() << " obj=" << target_obj << " returned r=" << r << dendl;
     return r;
   }
+  store->get_max_aligned_size(default_stripe_size, alignment, &stripe_size);
 
-  rgw_raw_obj stripe_obj = manifest_gen.get_cur_obj(store);
-  rgw_raw_obj_to_obj(head_obj.bucket, stripe_obj, &head_obj);
-  head_obj.index_hash_source = target_obj.key.name;
+  manifest.set_multipart_part_rule(stripe_size, part_num);
 
-  uint64_t chunk_size = 0;
-  r = store->get_max_chunk_size(stripe_obj.pool, &chunk_size);
+  r = manifest_gen.create_begin(store->ctx(), &manifest,
+                                bucket_info.placement_rule,
+                                &tail_placement_rule,
+                                target_obj.bucket, target_obj);
   if (r < 0) {
     return r;
   }
+
+  rgw_raw_obj stripe_obj = manifest_gen.get_cur_obj(store);
+  rgw_raw_obj_to_obj(head_obj.bucket, stripe_obj, &head_obj);
+  head_obj.index_hash_source = target_obj.key.name;
+
   r = writer.set_stripe_obj(stripe_obj);
   if (r < 0) {
     return r;
   }
-  uint64_t stripe_size = manifest_gen.cur_stripe_max_size();
+  stripe_size = manifest_gen.cur_stripe_max_size();
 
   uint64_t max_head_size = std::min(chunk_size, stripe_size);
   set_head_chunk_size(max_head_size);
@@ -388,8 +402,6 @@ int MultipartObjectProcessor::prepare_head()
 
 int MultipartObjectProcessor::prepare()
 {
-  const uint64_t default_stripe_size = store->ctx()->_conf->rgw_obj_stripe_size;
-  manifest.set_multipart_part_rule(default_stripe_size, part_num);
   manifest.set_prefix(target_obj.key.name + "." + upload_id);
 
   return prepare_head();
index 5bbc9f5fd33f98af7c0c2b812ca5577f3730245c..b2627f41286f9f6702c0eca97d88d6b2952dfed8 100644 (file)
@@ -1002,41 +1002,51 @@ int RGWRados::get_required_alignment(const rgw_pool& pool, uint64_t *alignment)
   return 0;
 }
 
-int RGWRados::get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size)
+void RGWRados::get_max_aligned_size(uint64_t size, uint64_t alignment, uint64_t *max_size)
 {
-  uint64_t alignment = 0;
+  if (alignment == 0) {
+    *max_size = size;
+    return;
+  }
+
+  if (size <= alignment) {
+    *max_size = alignment;
+    return;
+  }
+
+  *max_size = size - (size % alignment);
+}
+
+int RGWRados::get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size, uint64_t *palignment)
+{
+  uint64_t alignment;
   int r = get_required_alignment(pool, &alignment);
   if (r < 0) {
     return r;
   }
 
-  uint64_t config_chunk_size = cct->_conf->rgw_max_chunk_size;
-
-  if (alignment == 0) {
-    *max_chunk_size = config_chunk_size;
-    return 0;
+  if (palignment) {
+    *palignment = alignment;
   }
 
-  if (config_chunk_size <= alignment) {
-    *max_chunk_size = alignment;
-    return 0;
-  }
+  uint64_t config_chunk_size = cct->_conf->rgw_max_chunk_size;
 
-  *max_chunk_size = config_chunk_size - (config_chunk_size % alignment);
+  get_max_aligned_size(config_chunk_size, alignment, max_chunk_size);
 
   ldout(cct, 20) << "max_chunk_size=" << *max_chunk_size << dendl;
 
   return 0;
 }
 
-int RGWRados::get_max_chunk_size(const rgw_placement_rule& placement_rule, const rgw_obj& obj, uint64_t *max_chunk_size)
+int RGWRados::get_max_chunk_size(const rgw_placement_rule& placement_rule, const rgw_obj& obj,
+                                 uint64_t *max_chunk_size, uint64_t *palignment)
 {
   rgw_pool pool;
   if (!get_obj_data_pool(placement_rule, obj, &pool)) {
     ldout(cct, 0) << "ERROR: failed to get data pool for object " << obj << dendl;
     return -EIO;
   }
-  return get_max_chunk_size(pool, max_chunk_size);
+  return get_max_chunk_size(pool, max_chunk_size, palignment);
 }
 
 class RGWIndexCompletionManager;
index c11976343b13d731ef4764ed4b10352bb8296333..552e4f938d6c7f65c0991cfd6222a085fd7ca436 100644 (file)
@@ -1393,8 +1393,9 @@ public:
   }
 
   int get_required_alignment(const rgw_pool& pool, uint64_t *alignment);
-  int get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size);
-  int get_max_chunk_size(const rgw_placement_rule& placement_rule, const rgw_obj& obj, uint64_t *max_chunk_size);
+  void get_max_aligned_size(uint64_t size, uint64_t alignment, uint64_t *max_size);
+  int get_max_chunk_size(const rgw_pool& pool, uint64_t *max_chunk_size, uint64_t *palignment = nullptr);
+  int get_max_chunk_size(const rgw_placement_rule& placement_rule, const rgw_obj& obj, uint64_t *max_chunk_size, uint64_t *palignment = nullptr);
 
   uint32_t get_max_bucket_shards() {
     return rgw_shards_max();