From b663c097d1e6f41aed9abeadaae80f66fc71f5ec Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 5 Feb 2013 14:59:51 -0800 Subject: rgw: unlink multipart upload parts when completing upload Fixes: #4011 When completing the multipart upload, we also need to unlink the parts from the bucket index. Originally we used to remove the parts however, nowadays the parts live on as we just point the object manifest at them. So we don't remove the objects, however, we need to remove them from the bucket index. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_op.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 40e496acc72..652d0fd9ccb 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1515,6 +1515,8 @@ void RGWCompleteMultipart::execute() rgw_obj target_obj; RGWMPObj mp; RGWObjManifest manifest; + list unlink_parts; + int r; ret = get_params(); if (ret < 0) @@ -1583,12 +1585,14 @@ void RGWCompleteMultipart::execute() attrs[RGW_ATTR_ETAG] = etag_bl; target_obj.init(s->bucket, s->object_str); - + for (obj_iter = obj_parts.begin(); obj_iter != obj_parts.end(); ++obj_iter) { string oid = mp.get_part(obj_iter->second.num); rgw_obj src_obj; src_obj.init_ns(s->bucket, oid, mp_ns); + unlink_parts.push_back(src_obj.object); + RGWObjManifestPart& part = manifest.objs[ofs]; part.loc = src_obj; @@ -1609,7 +1613,14 @@ void RGWCompleteMultipart::execute() // remove the upload obj meta_obj.init_ns(s->bucket, meta_oid, mp_ns); - rgwstore->delete_obj(s->obj_ctx, meta_obj); + r = rgwstore->remove_objs_from_index(s->bucket, unlink_parts); + if (r < 0) { + ldout(s->cct, 0) << "WARNING: remove_objs_from_index() failed r=" << r << dendl; + } + r = rgwstore->delete_obj(s->obj_ctx, meta_obj); + if (r < 0) { + ldout(s->cct, 0) << "WARNING: failed to remove object r=" << r << dendl; + } done: send_response(); -- cgit v1.2.1