Skip to content

Commit

Permalink
Merge pull request ceph#46188 from Zhiwei-Dai/wip-rgw-crypto-stack-on…
Browse files Browse the repository at this point in the history
…-compress

rgw: support full object encryption stack on compression

Reviewed-by: Casey Bodley <[email protected]>
  • Loading branch information
cbodley authored Oct 24, 2022
2 parents c58715d + fd6082e commit 5dc16be
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions qa/suites/rgw/crypt/3-rgw/rgw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ overrides:
setgroup: ceph
rgw crypt require ssl: false
debug rgw: 20
rgw:
compression type: random

tasks:
- rgw:
Expand Down
12 changes: 10 additions & 2 deletions src/rgw/rgw_compression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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---------------------
Expand All @@ -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?
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,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()) {
Expand All @@ -2304,6 +2308,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;
Expand All @@ -2317,9 +2322,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)
Expand Down Expand Up @@ -4086,7 +4088,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 "
Expand Down

0 comments on commit 5dc16be

Please sign in to comment.