]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: configurable chunk size
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 4 Mar 2014 01:07:03 +0000 (17:07 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Wed, 26 Mar 2014 22:49:35 +0000 (15:49 -0700)
Fixes: #7589
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/config_opts.h
src/rgw/rgw_common.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest.cc
src/rgw/rgw_rest_s3.cc

index 32c1c22d5048ad484654a0e4254589219873a3d9..87ce3375d7092a006bc8036e843bd6dfcc8492bd 100644 (file)
@@ -730,6 +730,9 @@ OPTION(rbd_default_features, OPT_INT, 3) // 1 for layering, 3 for layering+strip
 
 OPTION(nss_db_path, OPT_STR, "") // path to nss db
 
+
+OPTION(rgw_max_chunk_size, OPT_INT, 512 * 1024)
+
 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 788aa840fb905566b04357aa63ae7563ed887caf..4d7a118f2be78478e040b1da43ce92c81ec26059 100644 (file)
@@ -71,7 +71,6 @@ using ceph::crypto::MD5;
 
 #define RGW_BUCKETS_OBJ_SUFFIX ".buckets"
 
-#define RGW_MAX_CHUNK_SIZE     (512*1024)
 #define RGW_MAX_PENDING_CHUNKS  16
 #define RGW_MAX_PUT_SIZE        (5ULL*1024*1024*1024)
 #define RGW_MIN_MULTIPART_SIZE (5ULL*1024*1024)
index 49632103917733bd3357866762d287e256fcb823..41ff4f4dd47e62883cfe7bba593308c2a7c8ed57 100644 (file)
@@ -1147,11 +1147,13 @@ int RGWPutObjProcessor_Atomic::handle_data(bufferlist& bl, off_t ofs, void **pha
     }
   }
 
+  uint64_t max_chunk_size = store->get_max_chunk_size();
+
   pending_data_bl.claim_append(bl);
-  if (pending_data_bl.length() < RGW_MAX_CHUNK_SIZE)
+  if (pending_data_bl.length() < max_chunk_size)
     return 0;
 
-  pending_data_bl.splice(0, RGW_MAX_CHUNK_SIZE, &bl);
+  pending_data_bl.splice(0, max_chunk_size, &bl);
 
   if (!data_ofs && !immutable_head()) {
     first_chunk.claim(bl);
@@ -1174,7 +1176,9 @@ int RGWPutObjProcessor_Atomic::prepare(RGWRados *store, void *obj_ctx)
 
   head_obj.init(bucket, obj_str);
 
-  manifest.set_trivial_rule(RGW_MAX_CHUNK_SIZE, store->ctx()->_conf->rgw_obj_stripe_size);
+  uint64_t max_chunk_size = store->get_max_chunk_size();
+
+  manifest.set_trivial_rule(max_chunk_size, store->ctx()->_conf->rgw_obj_stripe_size);
 
   int r = manifest_gen.create_begin(store->ctx(), &manifest, bucket, head_obj);
   if (r < 0) {
@@ -1446,6 +1450,8 @@ int RGWRados::initialize()
 {
   int ret;
 
+  max_chunk_size = cct->_conf->rgw_max_chunk_size;
+
   ret = init_rados();
   if (ret < 0)
     return ret;
@@ -3233,8 +3239,9 @@ set_err_state:
       copy_data = true;
     } else {
       uint64_t head_size = astate->manifest.get_head_size();
+
       if (head_size > 0) {
-       if (head_size > RGW_MAX_CHUNK_SIZE)  // should never happen
+       if (head_size > max_chunk_size)  // should never happen
          copy_data = true;
        else
           copy_first = true;
@@ -3325,7 +3332,7 @@ set_err_state:
   }
 
   if (copy_first) {
-    ret = get_obj(ctx, NULL, &handle, src_obj, first_chunk, 0, RGW_MAX_CHUNK_SIZE);
+    ret = get_obj(ctx, NULL, &handle, src_obj, first_chunk, 0, max_chunk_size);
     if (ret < 0)
       goto done_ret;
 
@@ -3404,8 +3411,8 @@ int RGWRados::copy_obj_data(void *ctx,
 
     const char *data = bl.c_str();
 
-    if (ofs < RGW_MAX_CHUNK_SIZE) {
-      off_t len = min(RGW_MAX_CHUNK_SIZE - ofs, (off_t)ret);
+    if ((uint64_t)ofs < max_chunk_size) {
+      uint64_t len = min(max_chunk_size - ofs, (uint64_t)ret);
       first_chunk.append(data, len);
       ofs += len;
       ret -= len;
@@ -3429,11 +3436,11 @@ int RGWRados::copy_obj_data(void *ctx,
   first_part->loc_ofs = 0;
   first_part->size = first_chunk.length();
 
-  if (ofs > RGW_MAX_CHUNK_SIZE) {
-    RGWObjManifestPart& tail = objs[RGW_MAX_CHUNK_SIZE];
+  if ((uint64_t)ofs > max_chunk_size) {
+    RGWObjManifestPart& tail = objs[max_chunk_size];
     tail.loc = shadow_obj;
-    tail.loc_ofs = RGW_MAX_CHUNK_SIZE;
-    tail.size = ofs - RGW_MAX_CHUNK_SIZE;
+    tail.loc_ofs = max_chunk_size;
+    tail.size = ofs - max_chunk_size;
   }
 
   manifest.set_explicit(ofs, objs);
@@ -4538,8 +4545,8 @@ int RGWRados::get_obj(void *ctx, RGWObjVersionTracker *objv_tracker, void **hand
     }
   }
 
-  if (len > RGW_MAX_CHUNK_SIZE)
-    len = RGW_MAX_CHUNK_SIZE;
+  if (len > max_chunk_size)
+    len = max_chunk_size;
 
 
   state->io_ctx.locator_set_key(key);
@@ -5110,7 +5117,7 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
   op.getxattrs(&unfiltered_attrset, NULL);
   op.stat(&size, &mtime, NULL);
   if (first_chunk) {
-    op.read(0, RGW_MAX_CHUNK_SIZE, first_chunk, NULL);
+    op.read(0, cct->_conf->rgw_max_chunk_size, first_chunk, NULL);
   }
   bufferlist outbl;
   r = ref.ioctx.operate(ref.oid, &op, &outbl);
index 1a4c17fab3fd7c7caceb0fa0a98f92d26d46084e..b0c233b052d2bc0bcd69a4c99e69d5914fb6a4d8 100644 (file)
@@ -1216,6 +1216,8 @@ class RGWRados
   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;
 
+  uint64_t max_chunk_size;
+
   int get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker);
   int append_atomic_test(RGWRadosCtx *rctx, rgw_obj& obj,
                          librados::ObjectOperation& op, RGWObjState **state);
@@ -1280,6 +1282,7 @@ public:
                num_watchers(0), watchers(NULL), watch_handles(NULL),
                watch_initialized(false),
                bucket_id_lock("rados_bucket_id"), max_bucket_id(0),
+               max_chunk_size(0),
                cct(NULL), rados(NULL),
                pools_initialized(false),
                quota_handler(NULL),
@@ -1317,6 +1320,10 @@ public:
     }
   }
 
+  uint64_t get_max_chunk_size() {
+    return max_chunk_size;
+  }
+
   int list_raw_objects(rgw_bucket& pool, const string& prefix_filter, int max,
                        RGWListRawObjsCtx& ctx, list<string>& oids,
                        bool *is_truncated);
index 2201d4f92d712d121080319b7781e2404eefd8f5..6473c614627ae483b10d8593c4f7fa93974e400b 100644 (file)
@@ -708,12 +708,13 @@ int RGWPutObj_ObjStore::get_params()
 int RGWPutObj_ObjStore::get_data(bufferlist& bl)
 {
   size_t cl;
+  uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
   if (s->length) {
     cl = atoll(s->length) - ofs;
-    if (cl > RGW_MAX_CHUNK_SIZE)
-      cl = RGW_MAX_CHUNK_SIZE;
+    if (cl > chunk_size)
+      cl = chunk_size;
   } else {
-    cl = RGW_MAX_CHUNK_SIZE;
+    cl = chunk_size;
   }
 
   int len = 0;
index 9dd5c50409389315bc811c6c49e927330c0876d8..b28c2a947922525ee6ae30f667c18c6cd77c83f4 100644 (file)
@@ -711,7 +711,8 @@ int RGWPostObj_ObjStore_S3::read_form_part_header(struct post_form_part *part,
 {
   bufferlist bl;
   bool reached_boundary;
-  int r = read_line(bl, RGW_MAX_CHUNK_SIZE, &reached_boundary, done);
+  uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
+  int r = read_line(bl, chunk_size, &reached_boundary, done);
   if (r < 0)
     return r;
 
@@ -720,7 +721,7 @@ int RGWPostObj_ObjStore_S3::read_form_part_header(struct post_form_part *part,
   }
 
   if (reached_boundary) { // skip the first boundary
-    r = read_line(bl, RGW_MAX_CHUNK_SIZE, &reached_boundary, done);
+    r = read_line(bl, chunk_size, &reached_boundary, done);
     if (r < 0)
       return r;
     if (*done)
@@ -752,7 +753,7 @@ int RGWPostObj_ObjStore_S3::read_form_part_header(struct post_form_part *part,
     if (reached_boundary)
       break;
 
-    r = read_line(bl, RGW_MAX_CHUNK_SIZE, &reached_boundary, done);
+    r = read_line(bl, chunk_size, &reached_boundary, done);
   }
 
   return 0;
@@ -877,7 +878,8 @@ int RGWPostObj_ObjStore_S3::get_params()
     }
 
     bool boundary;
-    r = read_data(part.data, RGW_MAX_CHUNK_SIZE, &boundary, &done);
+    uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
+    r = read_data(part.data, chunk_size, &boundary, &done);
     if (!boundary) {
       err_msg = "Couldn't find boundary";
       return -EINVAL;
@@ -1059,7 +1061,8 @@ int RGWPostObj_ObjStore_S3::complete_get_params()
     
     bufferlist part_data;
     bool boundary;
-    r = read_data(part.data, RGW_MAX_CHUNK_SIZE, &boundary, &done);
+    uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
+    r = read_data(part.data, chunk_size, &boundary, &done);
     if (!boundary) {
       return -EINVAL;
     }
@@ -1075,7 +1078,8 @@ int RGWPostObj_ObjStore_S3::get_data(bufferlist& bl)
   bool boundary;
   bool done;
 
-  int r = read_data(bl, RGW_MAX_CHUNK_SIZE, &boundary, &done);
+  uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
+  int r = read_data(bl, chunk_size, &boundary, &done);
   if (r < 0)
     return r;