From: Casey Bodley Date: Thu, 29 Sep 2016 15:44:00 +0000 (-0400) Subject: rgw: add accounted_size to RGWObjState X-Git-Tag: v11.1.0~429^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9a105a6966aa0a40c13cf970a478a8f45c970bbc;p=ceph.git rgw: add accounted_size to RGWObjState RGWRados::get_obj_state() now initializes accounted_size based on the compression attribute, if present Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index cb39809ad6e7..cbd1ca3d5347 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8476,8 +8476,23 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState * s->exists = true; s->has_attrs = true; + s->accounted_size = s->size; - map::iterator iter = s->attrset.find(RGW_ATTR_SHADOW_OBJ); + auto iter = s->attrset.find(RGW_ATTR_COMPRESSION); + if (iter != s->attrset.end()) { + // use uncompressed size for accounted_size + try { + RGWCompressionInfo info; + auto p = iter->second.begin(); + ::decode(info, p); + s->accounted_size = info.orig_size; + } catch (buffer::error&) { + dout(0) << "ERROR: could not decode compression info for object: " << obj << dendl; + return -EIO; + } + } + + iter = s->attrset.find(RGW_ATTR_SHADOW_OBJ); if (iter != s->attrset.end()) { bufferlist bl = iter->second; bufferlist::iterator it = bl.begin(); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index e37f758cd0b7..cd9121dc14a7 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -749,7 +749,8 @@ struct RGWObjState { bool is_atomic; bool has_attrs; bool exists; - uint64_t size; + uint64_t size; //< size of raw object + uint64_t accounted_size{0}; //< size before compression, encryption ceph::real_time mtime; uint64_t epoch; bufferlist obj_tag; @@ -781,6 +782,7 @@ struct RGWObjState { has_attrs = rhs.has_attrs; exists = rhs.exists; size = rhs.size; + accounted_size = rhs.accounted_size; mtime = rhs.mtime; epoch = rhs.epoch; if (rhs.obj_tag.length()) {