From 11cf9bbb298768b5307616db5977cc4985072a6e Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 27 Jan 2014 14:11:43 -0800 Subject: [PATCH] rgw: fix multipart min part size 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 --- src/common/config_opts.h | 2 ++ src/rgw/rgw_op.cc | 14 ++++++++++++-- src/rgw/rgw_op.h | 3 --- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 98aa2262c56..f9208cff8ff 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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. diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index e0bbd0f2b42..3f8dbf31c85 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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 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); } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 3724def2cf0..b85f0e2fcc7 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -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);