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>
setgroup: ceph
rgw crypt require ssl: false
debug rgw: 20
+ rgw:
+ compression type: random
tasks:
- rgw:
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
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---------------------
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?
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)
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()) {
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;
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)
}
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 "