]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: set object accounted size correctly 16179/head
authorfang.yuxiang <fang.yuxiang@eisoo.com>
Thu, 4 May 2017 07:58:37 +0000 (15:58 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 6 Jul 2017 17:18:07 +0000 (19:18 +0200)
sometimes, object accounted size is set wrong,
because we don't konw the object size if don't resort to the compression info or manifest.
e.g, when i use s3cmd do copy object(bucket_A/obj_A -> bucket_B/obj_B, assume the size of obj_A is 4M).
then i use s3cmd do list bucket, I got obj_B size is 512K, it is the head size apparently.

Fixes: http://tracker.ceph.com/issues/20071
Signed-off-by: fang yuxiang <fang.yuxiang@eisoo.com>
(cherry picked from commit 539985a99eebdc72c8d2446acc1108664a162f68)

src/rgw/rgw_rados.cc

index 3335689472b81d4467b7c8f181127caba5bdae6a..c32ab40684bb73691527d63a451230ed4b9802aa 100644 (file)
@@ -8536,13 +8536,14 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState *
   s->accounted_size = s->size;
 
   auto iter = s->attrset.find(RGW_ATTR_COMPRESSION);
-  if (iter != s->attrset.end()) {
+  const bool compressed = (iter != s->attrset.end());
+  if (compressed) {
     // use uncompressed size for accounted_size
     try {
       RGWCompressionInfo info;
       auto p = iter->second.begin();
       ::decode(info, p);
-      s->accounted_size = info.orig_size;
+      s->accounted_size = info.orig_size; 
     } catch (buffer::error&) {
       dout(0) << "ERROR: could not decode compression info for object: " << obj << dendl;
       return -EIO;
@@ -8567,6 +8568,8 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState *
       s->manifest.set_head(obj, s->size); /* patch manifest to reflect the head we just read, some manifests might be
                                              broken due to old bugs */
       s->size = s->manifest.get_obj_size();
+      if (!compressed)
+        s->accounted_size = s->size;
     } catch (buffer::error& err) {
       ldout(cct, 0) << "ERROR: couldn't decode manifest" << dendl;
       return -EIO;