]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Fixed problem with PUT with x-amz-copy-source when source object is compressed.
authorAdam Kupczyk <akupczyk@mirantis.com>
Thu, 1 Dec 2016 13:32:43 +0000 (14:32 +0100)
committerAdam Kupczyk <akupczyk@mirantis.com>
Thu, 1 Dec 2016 13:32:43 +0000 (14:32 +0100)
Signed-off-by: Adam Kupczyk <akupczyk@mirantis.com>
src/rgw/rgw_op.cc

index 39d361ab43a0c9aee237d341d6f483124c833601..f67f4f9b8f37030bb1a979f675a9762c932072cf 100644 (file)
@@ -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;
@@ -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);