From: Yehuda Sadeh Date: Tue, 4 Mar 2014 01:07:03 +0000 (-0800) Subject: rgw: configurable chunk size X-Git-Tag: v0.79~83^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=98654092fc5a18ef542d294d5696cac86d96229f;p=ceph.git rgw: configurable chunk size Fixes: #7589 Reviewed-by: Josh Durgin Signed-off-by: Yehuda Sadeh --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 32c1c22d5048..87ce3375d709 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 788aa840fb90..4d7a118f2be7 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 496321039177..41ff4f4dd47e 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 1a4c17fab3fd..b0c233b052d2 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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& oids, bool *is_truncated); diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 2201d4f92d71..6473c614627a 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -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; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 9dd5c5040938..b28c2a947922 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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;