From: Adam Kupczyk Date: Thu, 1 Dec 2016 13:32:43 +0000 (+0100) Subject: Fixed problem with PUT with x-amz-copy-source when source object is compressed. X-Git-Tag: v11.1.0~14^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cce94b9fa27df8279877d3fcd2983a3f8d32c15f;p=ceph-ci.git Fixed problem with PUT with x-amz-copy-source when source object is compressed. Signed-off-by: Adam Kupczyk --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 39d361ab43a..f67f4f9b8f3 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2775,6 +2775,11 @@ int RGWPutObj::get_data_cb(bufferlist& bl, off_t bl_ofs, off_t bl_len) int RGWPutObj::get_data(const off_t fst, const off_t lst, bufferlist& bl) { RGWPutObj_CB cb(this); + RGWGetDataCB* filter = &cb; + boost::optional decompress; + RGWCompressionInfo cs_info; + map attrs; + int ret = 0; uint64_t obj_size; @@ -2790,17 +2795,36 @@ int RGWPutObj::get_data(const off_t fst, const off_t lst, bufferlist& bl) RGWRados::Object op_target(store, copy_source_bucket_info, *static_cast(s->obj_ctx), obj); RGWRados::Object::Read read_op(&op_target); read_op.params.obj_size = &obj_size; + read_op.params.attrs = &attrs; + ret = read_op.prepare(); if (ret < 0) return ret; + + bool need_decompress; + op_ret = rgw_compression_info_from_attrset(attrs, need_decompress, cs_info); + if (op_ret < 0) { + lderr(s->cct) << "ERROR: failed to decode compression info, cannot decompress" << dendl; + return -EIO; + } + + bool partial_content = true; + if (need_decompress) + { + obj_size = cs_info.orig_size; + decompress.emplace(s->cct, &cs_info, partial_content, filter); + filter = &*decompress; + } + ret = read_op.range_to_ofs(obj_size, new_ofs, new_end); if (ret < 0) return ret; - ret = read_op.iterate(new_ofs, new_end, &cb); - if (ret < 0) { - return ret; - } + filter->fixup_range(new_ofs, new_end); + ret = read_op.iterate(new_ofs, new_end, filter); + + if (ret >= 0) + ret = filter->flush(); bl.claim_append(bl_aux);