Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed problem with PUT with x-amz-copy-source when source object is compressed. #12253

Merged
merged 1 commit into from Dec 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 28 additions & 4 deletions src/rgw/rgw_op.cc
Expand Up @@ -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<RGWGetObj_Decompress> decompress;
RGWCompressionInfo cs_info;
map<string, bufferlist> attrs;

int ret = 0;

uint64_t obj_size;
Expand All @@ -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<RGWObjectCtx *>(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);

Expand Down