]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: pass accounted_size directly into RGWPutObjProcessor::complete
authorCasey Bodley <cbodley@redhat.com>
Thu, 29 Sep 2016 16:34:17 +0000 (12:34 -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 95b0c61f4a19cae3f3cffeb2341b98e20d3c9109..bd5b772150edaaf2648c2bd4a29b9f656d2f8ddb 100644 (file)
@@ -2585,9 +2585,10 @@ class RGWPutObjProcessor_Multipart : public RGWPutObjProcessor_Atomic
 
 protected:
   int prepare(RGWRados *store, string *oid_rand);
-  int do_complete(string& etag, real_time *mtime, real_time set_mtime,
-                  map<string, bufferlist>& attrs, real_time delete_at,
-                  const char *if_match = NULL, const char *if_nomatch = NULL);
+  int do_complete(size_t accounted_size, const string& etag, real_time *mtime,
+                  real_time set_mtime, map<string, bufferlist>& attrs,
+                  real_time delete_at, const char *if_match,
+                  const char *if_nomatch) override;
 
 public:
   bool immutable_head() { return true; }
@@ -2659,9 +2660,13 @@ static bool is_v2_upload_id(const string& upload_id)
          (strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX_LEGACY, sizeof(MULTIPART_UPLOAD_ID_PREFIX_LEGACY) - 1) == 0);
 }
 
-int RGWPutObjProcessor_Multipart::do_complete(string& etag, real_time *mtime, real_time set_mtime,
-                                              map<string, bufferlist>& attrs, real_time delete_at,
-                                              const char *if_match, const char *if_nomatch)
+int RGWPutObjProcessor_Multipart::do_complete(size_t accounted_size,
+                                              const string& etag,
+                                              real_time *mtime, real_time set_mtime,
+                                              map<string, bufferlist>& attrs,
+                                              real_time delete_at,
+                                              const char *if_match,
+                                              const char *if_nomatch)
 {
   complete_writing_data();
 
@@ -2673,7 +2678,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(obj_len, obj_len, attrs);
+  int r = head_obj_op.write_meta(obj_len, accounted_size, attrs);
   if (r < 0)
     return r;
 
@@ -2697,8 +2702,8 @@ int RGWPutObjProcessor_Multipart::do_complete(string& etag, real_time *mtime, re
   }
   info.num = atoi(part_num.c_str());
   info.etag = etag;
-  info.size = s->obj_size;
-  info.accounted_size = s->obj_size; // TODO
+  info.size = obj_len;
+  info.accounted_size = accounted_size;
   info.modified = real_clock::now();
   info.manifest = manifest;
 
@@ -3124,8 +3129,8 @@ void RGWPutObj::execute()
     emplace_attr(RGW_ATTR_SLO_UINDICATOR, std::move(slo_userindicator_bl));
   }
 
-  op_ret = processor->complete(etag, &mtime, real_time(), attrs, delete_at,
-                             if_match, if_nomatch);
+  op_ret = processor->complete(s->obj_size, etag, &mtime, real_time(), attrs,
+                               delete_at, if_match, if_nomatch);
 
   /* produce torrent */
   if (s->cct->_conf->rgw_torrent_flag && (ofs == torrent.get_data_len()))
@@ -3289,7 +3294,7 @@ void RGWPostObj::execute()
     emplace_attr(RGW_ATTR_COMPRESSION, std::move(tmp));
   }
 
-  op_ret = processor.complete(etag, NULL, real_time(), attrs, delete_at);
+  op_ret = processor.complete(s->obj_size, etag, NULL, real_time(), attrs, delete_at);
 }
 
 
@@ -4957,7 +4962,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, ofs, attrs);
+  op_ret = obj_op.write_meta(ofs, accounted_size, attrs);
   if (op_ret < 0)
     return;
 
index 8a6c492cdd40761e836f71cac8b27dbcc6d9466a..89b3b7f4bb93338bcf77fae6f862e315f4e6f9d2 100644 (file)
@@ -2197,11 +2197,12 @@ void RGWObjVersionTracker::generate_new_write_ver(CephContext *cct)
   append_rand_alpha(cct, write_version.tag, write_version.tag, TAG_LEN);
 }
 
-int RGWPutObjProcessor::complete(string& etag, real_time *mtime, real_time set_mtime,
+int RGWPutObjProcessor::complete(size_t accounted_size, const string& etag,
+                                 real_time *mtime, real_time set_mtime,
                                  map<string, bufferlist>& attrs, real_time delete_at,
-                                 const char *if_match, const char * if_nomatch)
+                                 const char *if_match, const char *if_nomatch)
 {
-  int r = do_complete(etag, mtime, set_mtime, attrs, delete_at, if_match, if_nomatch);
+  int r = do_complete(accounted_size, etag, mtime, set_mtime, attrs, delete_at, if_match, if_nomatch);
   if (r < 0)
     return r;
 
@@ -2511,8 +2512,10 @@ int RGWPutObjProcessor_Atomic::complete_writing_data()
   return 0;
 }
 
-int RGWPutObjProcessor_Atomic::do_complete(string& etag, real_time *mtime, real_time set_mtime,
-                                           map<string, bufferlist>& attrs, real_time delete_at,
+int RGWPutObjProcessor_Atomic::do_complete(size_t accounted_size, const string& etag,
+                                           real_time *mtime, real_time set_mtime,
+                                           map<string, bufferlist>& attrs,
+                                           real_time delete_at,
                                            const char *if_match,
                                            const char *if_nomatch) {
   int r = complete_writing_data();
@@ -2540,7 +2543,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, obj_len, attrs);
+  r = obj_op.write_meta(obj_len, accounted_size, attrs);
   if (r < 0) {
     return r;
   }
@@ -6733,8 +6736,9 @@ public:
     return data_len;
   }
 
-  int complete(string& etag, real_time *mtime, real_time set_mtime, map<string, bufferlist>& attrs, real_time delete_at) {
-    return processor->complete(etag, mtime, set_mtime, attrs, delete_at);
+  int complete(const string& etag, real_time *mtime, real_time set_mtime,
+               map<string, bufferlist>& attrs, real_time delete_at) {
+    return processor->complete(data_len, etag, mtime, set_mtime, attrs, delete_at);
   }
 
   bool is_canceled() {
@@ -7638,7 +7642,8 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
     }
   }
 
-  ret = processor.complete(etag, mtime, set_mtime, attrs, delete_at);
+  // XXX: need to copy over compression attr and its orig_size here?
+  ret = processor.complete(ofs, etag, mtime, set_mtime, attrs, delete_at);
 
   return ret;
 }
index 788923e972667275080fa57fcbdf40d1aae8a0c1..12ac56917697b0913f32e024cf4789a10cc866d9 100644 (file)
@@ -3356,9 +3356,10 @@ protected:
   RGWBucketInfo bucket_info;
   bool canceled;
 
-  virtual int do_complete(string& etag, ceph::real_time *mtime, ceph::real_time set_mtime,
+  virtual int do_complete(size_t accounted_size, const string& etag,
+                          ceph::real_time *mtime, ceph::real_time set_mtime,
                           map<string, bufferlist>& attrs, ceph::real_time delete_at,
-                          const char *if_match = NULL, const char *if_nomatch = NULL) = 0;
+                          const char *if_match, const char *if_nomatch) = 0;
 
 public:
   RGWPutObjProcessor(RGWObjectCtx& _obj_ctx, RGWBucketInfo& _bi) : store(NULL), 
@@ -3372,9 +3373,10 @@ public:
     return 0;
   }
 
-  virtual int complete(string& etag, ceph::real_time *mtime, ceph::real_time set_mtime,
-                       map<string, bufferlist>& attrs, ceph::real_time delete_at,
-                       const char *if_match = NULL, const char *if_nomatch = NULL);
+  int complete(size_t accounted_size, const string& etag,
+               ceph::real_time *mtime, ceph::real_time set_mtime,
+               map<string, bufferlist>& attrs, ceph::real_time delete_at,
+               const char *if_match = NULL, const char *if_nomatch = NULL);
 
   CephContext *ctx();
 
@@ -3444,9 +3446,10 @@ protected:
   RGWObjManifest::generator manifest_gen;
 
   int write_data(bufferlist& bl, off_t ofs, void **phandle, rgw_obj *pobj, bool exclusive);
-  virtual int do_complete(string& etag, ceph::real_time *mtime, ceph::real_time set_mtime,
-                          map<string, bufferlist>& attrs, ceph::real_time delete_at,
-                          const char *if_match = NULL, const char *if_nomatch = NULL);
+  int do_complete(size_t accounted_size, const string& etag,
+                  ceph::real_time *mtime, ceph::real_time set_mtime,
+                  map<string, bufferlist>& attrs, ceph::real_time delete_at,
+                  const char *if_match, const char *if_nomatch) override;
 
   int prepare_next_part(off_t ofs);
   int complete_parts();