gc_invalidate_time = ceph_clock_now();
gc_invalidate_time += (s->cct->_conf->rgw_gc_obj_min_wait / 2);
- bool need_decompress;
- int64_t ofs_x, end_x;
+ bool need_decompress = false;
+ int64_t ofs_x = 0, end_x = 0;
+ bool encrypted = false;
RGWGetObj_CB cb(this);
RGWGetObj_Filter* filter = (RGWGetObj_Filter *)&cb;
ldpp_dout(this, 0) << "ERROR: failed to decode compression info, cannot decompress" << dendl;
goto done_err;
}
- if (need_decompress) {
- s->obj_size = cs_info.orig_size;
- s->object->set_obj_size(cs_info.orig_size);
- decompress.emplace(s->cct, &cs_info, partial_content, filter);
- filter = &*decompress;
+
+ // where encryption and compression are combined, compression was applied to
+ // the data before encryption. if the system header rgwx-skip-decrypt is
+ // present, we have to skip the decompression filter too
+ encrypted = attrs.count(RGW_ATTR_CRYPT_MODE);
+
+ if (need_decompress && (!encrypted || !skip_decrypt)) {
+ s->obj_size = cs_info.orig_size;
+ s->object->set_obj_size(cs_info.orig_size);
+ decompress.emplace(s->cct, &cs_info, partial_content, filter);
+ filter = &*decompress;
}
attr_iter = attrs.find(RGW_ATTR_OBJ_REPLICATION_TRACE);
if (encrypt != nullptr) {
filter = &*encrypt;
}
- if (compression_type != "none") {
+ // a zonegroup feature is required to combine compression and encryption
+ const rgw::sal::ZoneGroup& zonegroup = driver->get_zone()->get_zonegroup();
+ const bool compress_encrypted = zonegroup.supports(rgw::zone_features::compress_encrypted);
+ if (compression_type != "none" &&
+ (encrypt == nullptr || compress_encrypted)) {
plugin = get_compressor_plugin(s, compression_type);
if (!plugin) {
ldpp_dout(this, 1) << "Cannot load plugin for compression type "