]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add accounted_size to RGWObjState
authorCasey Bodley <cbodley@redhat.com>
Thu, 29 Sep 2016 15:44:00 +0000 (11:44 -0400)
committerAdam Kupczyk <akupczyk@mirantis.com>
Wed, 2 Nov 2016 11:13:06 +0000 (12:13 +0100)
RGWRados::get_obj_state() now initializes accounted_size based on
the compression attribute, if present

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index cb39809ad6e7cf6f21e1da0fa66a298fab62faa2..cbd1ca3d53472ff33e026b9123a21a638ae5019d 100644 (file)
@@ -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<string, bufferlist>::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();
index e37f758cd0b709f9ee1357900d867b9bff7d0f2c..cd9121dc14a78121300ff11634ccefb4eafafb07 100644 (file)
@@ -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()) {