]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: support full object encryption stack on compression 46188/head
authorDai Zhiwei <daizhiwei3@huawei.com>
Fri, 6 May 2022 12:04:15 +0000 (20:04 +0800)
committerDai Zhiwei <daizhiwei3@huawei.com>
Fri, 23 Sep 2022 03:16:12 +0000 (11:16 +0800)
add implementation for full object encryption stack on compression. Compressing first and then encrypting.

Fixed: https://tracker.ceph.com/issues/19988
Signed-off-by: Dai Zhiwei <daizhiwei3@huawei.com>
Signed-off-by: luo rixin <luorixin@huawei.com>
qa/suites/rgw/crypt/3-rgw/rgw.yaml
src/rgw/rgw_compression.cc
src/rgw/rgw_compression.h
src/rgw/rgw_op.cc

index ee8d62af05c83e1b1f4094455878167bf2959ca3..764d216aadecd27f777f301a0ed5cd0eb63b070b 100644 (file)
@@ -6,6 +6,8 @@ overrides:
         setgroup: ceph
         rgw crypt require ssl: false
         debug rgw: 20
+  rgw:
+    compression type: random
 
 tasks:
 - rgw:
index 8835a8fc55411e5a4749ee548d730619e8e704fa..8306e766a7618d459e16d165f633a99107d0e8a8 100644 (file)
@@ -44,6 +44,8 @@ int rgw_compression_info_from_attrset(const map<string, bufferlist>& attrs,
 int RGWPutObj_Compress::process(bufferlist&& in, uint64_t logical_offset)
 {
   bufferlist out;
+  compressed_ofs = logical_offset;
+
   if (in.length() > 0) {
     // compression stuff
     if ((logical_offset > 0 && compressed) || // if previous part was compressed
@@ -69,14 +71,20 @@ int RGWPutObj_Compress::process(bufferlist&& in, uint64_t logical_offset)
         newbl.new_ofs = bs > 0 ? blocks[bs-1].len + blocks[bs-1].new_ofs : 0;
         newbl.len = out.length();
         blocks.push_back(newbl);
+
+       compressed_ofs = newbl.new_ofs;
       }
     } else {
       compressed = false;
       out = std::move(in);
     }
     // end of compression stuff
+  } else {
+    size_t bs = blocks.size();
+    compressed_ofs = bs > 0 ? blocks[bs-1].len + blocks[bs-1].new_ofs : logical_offset;
   }
-  return Pipe::process(std::move(out), logical_offset);
+
+  return Pipe::process(std::move(out), compressed_ofs);
 }
 
 //----------------RGWGetObj_Decompress---------------------
@@ -99,7 +107,7 @@ RGWGetObj_Decompress::RGWGetObj_Decompress(CephContext* cct_,
 int RGWGetObj_Decompress::handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len)
 {
   ldout(cct, 10) << "Compression for rgw is enabled, decompress part "
-      << "bl_ofs="<< bl_ofs << ", bl_len=" << bl_len << dendl;
+      << "bl_ofs=" << bl_ofs << ", bl_len=" << bl_len << dendl;
 
   if (!compressor.get()) {
     // if compressor isn't available - error, because cannot return decompressed data?
index bc6511c867381f8714a88127483bd65a80a93877..e558f3bbd8ef625872a5c3699aeeeaa79674805e 100644 (file)
@@ -47,6 +47,7 @@ class RGWPutObj_Compress : public rgw::putobj::Pipe
   CompressorRef compressor;
   std::optional<int32_t> compressor_message;
   std::vector<compression_block> blocks;
+  uint64_t compressed_ofs{0};
 public:
   RGWPutObj_Compress(CephContext* cct_, CompressorRef compressor,
                      rgw::sal::DataProcessor *next)
index e983be0e5ba3c1f3989abfdfb8cf748c94ff5a23..734ea9bfe3fa3d78c270c742c277c624cebb0eef 100644 (file)
@@ -2265,6 +2265,10 @@ void RGWGetObj::execute(optional_yield y)
     goto done_err;
   total_len = (ofs <= end ? end + 1 - ofs : 0);
 
+  ofs_x = ofs;
+  end_x = end;
+  filter->fixup_range(ofs_x, end_x);
+
   /* Check whether the object has expired. Swift API documentation
    * stands that we should return 404 Not Found in such case. */
   if (need_object_expiration() && s->object->is_expired()) {
@@ -2282,6 +2286,7 @@ void RGWGetObj::execute(optional_yield y)
                                     attr_iter != attrs.end() ? &(attr_iter->second) : nullptr);
   if (decrypt != nullptr) {
     filter = decrypt.get();
+    filter->fixup_range(ofs_x, end_x);
   }
   if (op_ret < 0) {
     goto done_err;
@@ -2294,9 +2299,6 @@ void RGWGetObj::execute(optional_yield y)
 
   perfcounter->inc(l_rgw_get_b, end - ofs);
 
-  ofs_x = ofs;
-  end_x = end;
-  filter->fixup_range(ofs_x, end_x);
   op_ret = read_op->iterate(this, ofs_x, end_x, filter, s->yield);
 
   if (op_ret >= 0)
@@ -4050,7 +4052,8 @@ void RGWPutObj::execute(optional_yield y)
     }
     if (encrypt != nullptr) {
       filter = &*encrypt;
-    } else if (compression_type != "none") {
+    }
+    if (compression_type != "none") {
       plugin = get_compressor_plugin(s, compression_type);
       if (!plugin) {
         ldpp_dout(this, 1) << "Cannot load plugin for compression type "