]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add accounted_size argument to Write::write_meta
authorCasey Bodley <cbodley@redhat.com>
Thu, 29 Sep 2016 16:32:21 +0000 (12:32 -0400)
committerAdam Kupczyk <akupczyk@mirantis.com>
Wed, 2 Nov 2016 11:13:06 +0000 (12:13 +0100)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index fa2f56af4bae9ad847fd697b00d0463d158c9a0e..e72548ab785bf04793b1238a8fd01a918766d85a 100644 (file)
@@ -2673,7 +2673,7 @@ int RGWPutObjProcessor_Multipart::do_complete(string& etag, real_time *mtime, re
   head_obj_op.meta.owner = s->owner.get_id();
   head_obj_op.meta.delete_at = delete_at;
 
-  int r = head_obj_op.write_meta(s->obj_size, attrs);
+  int r = head_obj_op.write_meta(obj_len, obj_len, attrs);
   if (r < 0)
     return r;
 
@@ -4582,7 +4582,7 @@ void RGWInitMultipart::execute()
     obj_op.meta.category = RGW_OBJ_CATEGORY_MULTIMETA;
     obj_op.meta.flags = PUT_OBJ_CREATE_EXCL;
 
-    op_ret = obj_op.write_meta(0, attrs);
+    op_ret = obj_op.write_meta(0, 0, attrs);
   } while (op_ret == -EEXIST);
 }
 
@@ -4954,7 +4954,7 @@ void RGWCompleteMultipart::execute()
   obj_op.meta.ptag = &s->req_id; /* use req_id as operation tag */
   obj_op.meta.owner = s->owner.get_id();
   obj_op.meta.flags = PUT_OBJ_CREATE;
-  op_ret = obj_op.write_meta(ofs, attrs);
+  op_ret = obj_op.write_meta(ofs, ofs, attrs);
   if (op_ret < 0)
     return;
 
index be518907a621844a465fe0c47538a1d052f0845d..8a6c492cdd40761e836f71cac8b27dbcc6d9466a 100644 (file)
@@ -2540,7 +2540,7 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, real_time *mtime, real_
   obj_op.meta.olh_epoch = olh_epoch;
   obj_op.meta.delete_at = delete_at;
 
-  r = obj_op.write_meta(obj_len, attrs);
+  r = obj_op.write_meta(obj_len, obj_len, attrs);
   if (r < 0) {
     return r;
   }
@@ -6245,13 +6245,14 @@ int RGWRados::swift_versioning_restore(RGWObjectCtx& obj_ctx,
  * obj: the object name/key
  * data: the object contents/value
  * size: the amount of data to write (data must be this long)
+ * accounted_size: original size of data before compression, encryption
  * mtime: if non-NULL, writes the given mtime to the bucket storage
  * attrs: all the given attrs are written to bucket storage for the given object
  * exclusive: create object exclusively
  * Returns: 0 on success, -ERR# otherwise.
  */
-int RGWRados::Object::Write::write_meta(uint64_t size,
-                  map<string, bufferlist>& attrs)
+int RGWRados::Object::Write::write_meta(uint64_t size, uint64_t accounted_size,
+                                        map<string, bufferlist>& attrs)
 {
   rgw_bucket bucket;
   rgw_rados_ref ref;
@@ -6357,7 +6358,7 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
   int64_t poolid;
 
   bool orig_exists = state->exists;
-  uint64_t orig_size = state->size;
+  uint64_t orig_size = state->accounted_size;
 
   bool versioned_target = (meta.olh_epoch > 0 || !obj.get_instance().empty());
 
@@ -6394,7 +6395,7 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
     ldout(store->ctx(), 0) << "ERROR: complete_atomic_modification returned r=" << r << dendl;
   }
 
-  r = index_op.complete(poolid, epoch, size, size,
+  r = index_op.complete(poolid, epoch, size, accounted_size,
                         meta.set_mtime, etag, content_type, &acl_bl,
                         meta.category, meta.remove_objs);
   if (r < 0)
@@ -6429,7 +6430,8 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
   meta.canceled = false;
 
   /* update quota cache */
-  store->quota_handler->update_stats(meta.owner, bucket, (orig_exists ? 0 : 1), size, orig_size);
+  store->quota_handler->update_stats(meta.owner, bucket, (orig_exists ? 0 : 1),
+                                     accounted_size, orig_size);
   return 0;
 
 done_cancel:
@@ -7536,7 +7538,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
   write_op.meta.olh_epoch = olh_epoch;
   write_op.meta.delete_at = delete_at;
 
-  ret = write_op.write_meta(obj_size, attrs);
+  ret = write_op.write_meta(obj_size, astate->accounted_size, attrs);
   if (ret < 0) {
     goto done_ret;
   }
index 79340b8ed523efee5f852cbcda0e3fb3e0bc4d37..ba62caee50c4aeb00deb146bf5771506cc383065 100644 (file)
@@ -2465,7 +2465,8 @@ public:
 
       explicit Write(RGWRados::Object *_target) : target(_target) {}
 
-      int write_meta(uint64_t size,  map<std::string, bufferlist>& attrs);
+      int write_meta(uint64_t size, uint64_t accounted_size,
+                     map<std::string, bufferlist>& attrs);
       int write_data(const char *data, uint64_t ofs, uint64_t len, bool exclusive);
     };