]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix multipart min part size 1154/head
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 27 Jan 2014 22:11:43 +0000 (14:11 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Tue, 28 Jan 2014 20:16:59 +0000 (12:16 -0800)
As part of the fix for wip-7169 it turned out that we removed
min_part_size. Looking back, the original implementation was broken
anyway and didn't do anything. This fixes it and makes it configurable.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/config_opts.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h

index 98aa2262c56ee462b6dd54f03af87051cbb984cd..f9208cff8ff712c98e0a2c06a0b8ce3da9e02cab 100644 (file)
@@ -766,6 +766,8 @@ OPTION(rgw_user_quota_sync_interval, OPT_INT, 3600 * 24) // time period for accu
 OPTION(rgw_user_quota_sync_idle_users, OPT_BOOL, false) // whether stats for idle users be fully synced
 OPTION(rgw_user_quota_sync_wait_time, OPT_INT, 3600 * 24) // min time between two full stats syc for non-idle users
 
+OPTION(rgw_multipart_min_part_size, OPT_INT, 5 * 1024 * 1024) // min size for each part (except for last one) in multipart upload
+
 OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter
 
 // This will be set to true when it is safe to start threads.
index e0bbd0f2b42190e935ed49e9854059950f31481f..3f8dbf31c851f2580bb8f694decee0f14518fbed 100644 (file)
@@ -2549,10 +2549,13 @@ void RGWCompleteMultipart::execute()
   meta_oid = mp.get_meta();
 
   int total_parts = 0;
+  int handled_parts = 0;
   int max_parts = 1000;
   int marker = 0;
   bool truncated;
 
+  uint64_t min_part_size = s->cct->_conf->rgw_multipart_min_part_size;
+
   list<string> remove_objs; /* objects to be removed from index listing */
 
   iter = parts->parts.begin();
@@ -2571,7 +2574,14 @@ void RGWCompleteMultipart::execute()
       return;
     }
 
-    for (obj_iter = obj_parts.begin(); iter != parts->parts.end() && obj_iter != obj_parts.end(); ++iter, ++obj_iter) {
+    for (obj_iter = obj_parts.begin(); iter != parts->parts.end() && obj_iter != obj_parts.end(); ++iter, ++obj_iter, ++handled_parts) {
+      uint64_t part_size = obj_iter->second.size;
+      if (handled_parts < (int)parts->parts.size() - 1 &&
+          part_size < min_part_size) {
+        ret = -ERR_TOO_SMALL;
+        return;
+      }
+
       char etag[CEPH_CRYPTO_MD5_DIGESTSIZE];
       if (iter->first != (int)obj_iter->first) {
         ldout(s->cct, 0) << "NOTICE: parts num mismatch: next requested: " << iter->first << " next uploaded: " << obj_iter->first << dendl;
@@ -2600,7 +2610,7 @@ void RGWCompleteMultipart::execute()
 
         part.loc = src_obj;
         part.loc_ofs = 0;
-        part.size = obj_iter->second.size;
+        part.size = part_size;
       } else {
         manifest.append(obj_part.manifest);
       }
index 3724def2cf033295ae6c033031cf25c40abb9869..b85f0e2fcc70bea5ee4eb8a5851c852bec884f0b 100644 (file)
@@ -672,15 +672,12 @@ protected:
   string etag;
   char *data;
   int len;
-  uint64_t min_part_size;
 
 public:
   RGWCompleteMultipart() {
     ret = 0;
     data = NULL;
     len = 0;
-    // min_part_size = RGW_MIN_MULTIPART_SIZE;
-    min_part_size = 0;
   }
   virtual ~RGWCompleteMultipart() {
     free(data);