@@ -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);
0 commit comments