Skip to content

Commit 813fb28

Browse files
authored
Merge pull request ceph#52247 from cbodley/wip-57905
rgw: rgwx-skip-decrypt also skips decompression of encrypted objects Reviewed-by: Shilpa Jagannath <[email protected]>
2 parents 19f97fc + b91ff3f commit 813fb28

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,6 +3386,7 @@ class RGWRadosPutObj : public RGWHTTPStreamRWRequest::ReceiveCB
33863386

33873387

33883388
int process_attrs(void) {
3389+
bool encrypted = false;
33893390
if (extra_data_bl.length()) {
33903391
JSONParser jp;
33913392
if (!jp.parse(extra_data_bl.c_str(), extra_data_bl.length())) {
@@ -3395,8 +3396,18 @@ class RGWRadosPutObj : public RGWHTTPStreamRWRequest::ReceiveCB
33953396

33963397
JSONDecoder::decode_json("attrs", src_attrs, &jp);
33973398

3399+
encrypted = src_attrs.count(RGW_ATTR_CRYPT_MODE);
3400+
if (encrypted) {
3401+
// we won't have access to the decrypted data for checksumming
3402+
try_etag_verify = false;
3403+
}
3404+
3405+
// if the object is both compressed and encrypted, it was transferred
3406+
// in its encrypted+compressed form. we need to preserve the original
3407+
// RGW_ATTR_COMPRESSION instead of falling back to default compression
3408+
// settings
33983409
auto iter = src_attrs.find(RGW_ATTR_COMPRESSION);
3399-
if (iter != src_attrs.end()) {
3410+
if (iter != src_attrs.end() && !encrypted) {
34003411
const bufferlist bl = std::move(iter->second);
34013412
src_attrs.erase(iter); // don't preserve source compression info
34023413

@@ -3437,8 +3448,8 @@ class RGWRadosPutObj : public RGWHTTPStreamRWRequest::ReceiveCB
34373448
return ret;
34383449
}
34393450

3440-
if (plugin && src_attrs.find(RGW_ATTR_CRYPT_MODE) == src_attrs.end()) {
3441-
//do not compress if object is encrypted
3451+
// do not compress if object is encrypted
3452+
if (plugin && !encrypted) {
34423453
compressor = boost::in_place(cct, plugin, filter);
34433454
// add a filter that buffers data so we don't try to compress tiny blocks.
34443455
// libcurl reads in 16k at a time, and we need at least 64k to get a good
@@ -3448,12 +3459,7 @@ class RGWRadosPutObj : public RGWHTTPStreamRWRequest::ReceiveCB
34483459
filter = &*buffering;
34493460
}
34503461

3451-
/*
3452-
* Presently we don't support ETag based verification if encryption is
3453-
* requested. We can enable simultaneous support once we have a mechanism
3454-
* to know the sequence in which the filters must be applied.
3455-
*/
3456-
if (try_etag_verify && src_attrs.find(RGW_ATTR_CRYPT_MODE) == src_attrs.end()) {
3462+
if (try_etag_verify) {
34573463
ret = rgw::putobj::create_etag_verifier(dpp, cct, filter, manifest_bl,
34583464
compression_info,
34593465
etag_verifier);

src/rgw/rgw_op.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,8 +2200,9 @@ void RGWGetObj::execute(optional_yield y)
22002200
gc_invalidate_time = ceph_clock_now();
22012201
gc_invalidate_time += (s->cct->_conf->rgw_gc_obj_min_wait / 2);
22022202

2203-
bool need_decompress;
2204-
int64_t ofs_x, end_x;
2203+
bool need_decompress = false;
2204+
int64_t ofs_x = 0, end_x = 0;
2205+
bool encrypted = false;
22052206

22062207
RGWGetObj_CB cb(this);
22072208
RGWGetObj_Filter* filter = (RGWGetObj_Filter *)&cb;
@@ -2301,11 +2302,17 @@ void RGWGetObj::execute(optional_yield y)
23012302
ldpp_dout(this, 0) << "ERROR: failed to decode compression info, cannot decompress" << dendl;
23022303
goto done_err;
23032304
}
2304-
if (need_decompress) {
2305-
s->obj_size = cs_info.orig_size;
2306-
s->object->set_obj_size(cs_info.orig_size);
2307-
decompress.emplace(s->cct, &cs_info, partial_content, filter);
2308-
filter = &*decompress;
2305+
2306+
// where encryption and compression are combined, compression was applied to
2307+
// the data before encryption. if the system header rgwx-skip-decrypt is
2308+
// present, we have to skip the decompression filter too
2309+
encrypted = attrs.count(RGW_ATTR_CRYPT_MODE);
2310+
2311+
if (need_decompress && (!encrypted || !skip_decrypt)) {
2312+
s->obj_size = cs_info.orig_size;
2313+
s->object->set_obj_size(cs_info.orig_size);
2314+
decompress.emplace(s->cct, &cs_info, partial_content, filter);
2315+
filter = &*decompress;
23092316
}
23102317

23112318
attr_iter = attrs.find(RGW_ATTR_OBJ_REPLICATION_TRACE);

0 commit comments

Comments
 (0)