From bbf5fddbfc0c912e4165c16306e542fd013bc25b Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 29 Sep 2016 12:42:57 -0400 Subject: [PATCH] rgw: remove compression attribute from bucket instance Signed-off-by: Casey Bodley --- src/rgw/rgw_op.cc | 58 -------------------------------------------- src/rgw/rgw_op.h | 2 -- src/rgw/rgw_rados.cc | 15 ------------ src/rgw/rgw_rados.h | 21 ---------------- 4 files changed, 96 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index bd5b772150eda..6796f6eb1fa35 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -775,16 +775,6 @@ bool RGWOp::generate_cors_headers(string& origin, string& method, string& header return true; } -int RGWOp::update_compressed_bucket_size(uint64_t obj_size, RGWBucketCompressionInfo& bucket_size) -{ - bucket_size.orig_size += obj_size; - bufferlist bs; - ::encode(bucket_size, bs); - s->bucket_attrs[RGW_ATTR_COMPRESSION] = bs; - return store->put_bucket_instance_info(s->bucket_info, false, real_time(), - &s->bucket_attrs); -} - int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, const RGWObjEnt& ent, RGWAccessControlPolicy * const bucket_policy, @@ -1891,12 +1881,6 @@ void RGWStatBucket::execute() op_ret = -EINVAL; } } - RGWBucketCompressionInfo bcs; - int res = rgw_bucket_compression_info_from_attrset(s->bucket_attrs, bcs); - if (!res) - bucket.size = bcs.orig_size; - if (res < 0) - lderr(s->cct) << "Failed to read decompressed bucket size" << dendl; } int RGWListBucket::verify_permission() @@ -3068,15 +3052,6 @@ void RGWPutObj::execute() attrs[RGW_ATTR_COMPRESSION] = tmp; } - // add attr to bucket to know original size of data - res = rgw_bucket_compression_info_from_attrset(s->bucket_attrs, bucket_size); - if (res < 0) - lderr(s->cct) << "ERROR: failed to read decompressed bucket size, cannot update stat" << dendl; - op_ret = update_compressed_bucket_size(s->obj_size, bucket_size); - if (op_ret < 0) - ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name - << " returned err=" << op_ret << dendl; - buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5); etag = calc_md5; @@ -3697,27 +3672,6 @@ void RGWDeleteObj::execute() if (op_ret >= 0) { delete_marker = del_op.result.delete_marker; version_id = del_op.result.version_id; - RGWBucketCompressionInfo bucket_size; - int res = rgw_bucket_compression_info_from_attrset(s->bucket_attrs, bucket_size); - if (res < 0) - lderr(s->cct) << "ERROR: failed to read decompressed bucket size, cannot update stat" << dendl; - if (!res) { - uint64_t deleted_size; - bool tmp; - RGWCompressionInfo cs_info; - res = rgw_compression_info_from_attrset(attrs, tmp, cs_info); - if (res < 0) { - lderr(s->cct) << "ERROR: failed to decode compression info, cannot update stat" << dendl; - deleted_size = s->obj_size; - } else { - if (tmp) - deleted_size = cs_info.orig_size; - else - deleted_size = s->obj_size; - } - if (update_compressed_bucket_size(-deleted_size, bucket_size) < 0) - lderr(s->cct) << "ERROR: failed to update bucket stat" << dendl; - } } /* Check whether the object has expired. Swift API documentation @@ -5075,18 +5029,6 @@ void RGWAbortMultipart::execute() if (op_ret == -ENOENT) { op_ret = -ERR_NO_SUCH_BUCKET; } - - if (!op_ret) { - RGWBucketCompressionInfo bucket_size; - int res = rgw_bucket_compression_info_from_attrset(s->bucket_attrs, bucket_size); - if (res < 0) - lderr(s->cct) << "ERROR: failed to read decompressed bucket size, cannot update stat" << dendl; - if (!res) { - if (update_compressed_bucket_size(-deleted_size, bucket_size) < 0) - lderr(s->cct) << "ERROR: failed to update bucket stat" << dendl; - } - } - } int RGWListMultipart::verify_permission() diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 60295e7739eda..31f6b77465806 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -87,8 +87,6 @@ RGWOp() : s(nullptr), dialect_handler(nullptr), store(nullptr), } int read_bucket_cors(); bool generate_cors_headers(string& origin, string& method, string& headers, string& exp_headers, unsigned *max_age); - // obj_size can be positive or negative - int update_compressed_bucket_size(uint64_t obj_size, RGWBucketCompressionInfo& bucket_size); virtual int verify_params() { return 0; } virtual bool prefetch_data() { return false; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d74d5d19e8c3a..59186d3e6057f 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -12941,18 +12941,3 @@ int rgw_compression_info_from_attrset(map& attrs, bool& need return 0; } } - -int rgw_bucket_compression_info_from_attrset(map& attrs, RGWBucketCompressionInfo& cs_info) -{ - map::iterator cmp = attrs.find(RGW_ATTR_COMPRESSION); - if (cmp != attrs.end()) { - try { - ::decode(cs_info, cmp->second); - } catch (buffer::error& err) { - return -EIO; - } - } else { - return 1; - } - return 0; -} diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 12ac56917697b..9f5f7bb953422 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -127,28 +127,7 @@ struct RGWCompressionInfo { }; WRITE_CLASS_ENCODER(RGWCompressionInfo) -struct RGWBucketCompressionInfo { - uint64_t orig_size; - - RGWBucketCompressionInfo() : orig_size(0) {} - - void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - ::encode(orig_size, bl); - ENCODE_FINISH(bl); - } - - void decode(bufferlist::iterator& bl) { - DECODE_START(1, bl); - ::decode(orig_size, bl); - DECODE_FINISH(bl); - } -}; -WRITE_CLASS_ENCODER(RGWBucketCompressionInfo) - int rgw_compression_info_from_attrset(map& attrs, bool& need_decompress, RGWCompressionInfo& cs_info); -// return 0, if find and read; -EIO, if find and not read; 1 if not find -int rgw_bucket_compression_info_from_attrset(map& attrs, RGWBucketCompressionInfo& cs_info); struct RGWOLHInfo { rgw_obj target; -- 2.39.5