]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Changed hash calculation logic.
authorAdam Kupczyk <akupczyk@mirantis.com>
Thu, 7 Apr 2016 14:01:59 +0000 (16:01 +0200)
committerAdam Kupczyk <akupczyk@mirantis.com>
Wed, 2 Nov 2016 10:34:50 +0000 (11:34 +0100)
Changed RGWPutObjProcessor interface with regard to hash calculation.

Signed-off-by: Adam Kupczyk (akupczyk@mirantis.com)
Conflicts:
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc

src/rgw/rgw_file.cc
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 13ac2625029ae85260bab73580a2bd90073783a9..5d998e111c8be3755724dff9243af7cdc2950961 100644 (file)
@@ -972,9 +972,8 @@ namespace rgw {
     if (need_to_wait) {
       orig_data = data;
     }
-
+    hash.Update((const byte *)data.c_str(), data.length());
     op_ret = put_data_and_throttle(processor, data, ofs,
-                                  (true /* md5 */ ? &hash : NULL),
                                   need_to_wait);
     if (op_ret < 0) {
       if (!need_to_wait || op_ret != -EEXIST) {
@@ -1005,7 +1004,7 @@ namespace rgw {
        goto done;
       }
 
-      op_ret = put_data_and_throttle(processor, data, ofs, NULL, false);
+      op_ret = put_data_and_throttle(processor, data, ofs, false);
       if (op_ret < 0) {
        goto done;
       }
@@ -1033,7 +1032,6 @@ namespace rgw {
       goto done;
     }
 
-    processor->complete_hash(&hash);
     hash.Final(m);
 
     buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5);
index a79c2f34c7fe81728f94923a294c745a8c95e95d..292cb531310c69ec197b3dbc14d45fc371caf00c 100644 (file)
@@ -3050,8 +3050,7 @@ void RGWPutObj::execute()
       orig_data = data;
     }
 
-    op_ret = put_data_and_throttle(processor, data, ofs,
-                                 (need_calc_md5 ? &hash : NULL), need_to_wait);
+    op_ret = put_data_and_throttle(processor, data, ofs, need_to_wait);
     if (op_ret < 0) {
       if (!need_to_wait || op_ret != -EEXIST) {
         ldout(s->cct, 20) << "processor->thottle_data() returned ret="
@@ -3081,7 +3080,7 @@ void RGWPutObj::execute()
         goto done;
       }
 
-      op_ret = put_data_and_throttle(processor, data, ofs, NULL, false);
+      op_ret = put_data_and_throttle(processor, data, ofs, false);
       if (op_ret < 0) {
         goto done;
       }
index 2431b7cf58503d6f3c12929703d9d5e138a2112c..6ecf998e8b10c516280e86a88b8c65f79f4f656f 100644 (file)
@@ -1552,9 +1552,9 @@ extern int rgw_build_bucket_policies(RGWRados* store, struct req_state* s);
 extern int rgw_build_object_policies(RGWRados *store, struct req_state *s,
                                    bool prefetch_data);
 
-static inline int put_data_and_throttle(RGWPutObjProcessor *processor,
+static inline int put_data_and_throttle(RGWPutObjDataProcessor *processor,
                                        bufferlist& data, off_t ofs,
-                                       MD5 *hash, bool need_to_wait)
+                                       bool need_to_wait)
 {
   bool again;
 
@@ -1562,7 +1562,7 @@ static inline int put_data_and_throttle(RGWPutObjProcessor *processor,
     void *handle;
     rgw_obj obj;
 
-    int ret = processor->handle_data(data, ofs, hash, &handle, &obj, &again);
+    int ret = processor->handle_data(data, ofs, &handle, &obj, &again);
     if (ret < 0)
       return ret;
 
index 64939b25aaeec5bffc17bded44b1c481dddc9d0d..ecdf104ea4fcf071117f529999df54e9d497f112 100644 (file)
@@ -2462,11 +2462,6 @@ int RGWPutObjProcessor_Atomic::handle_data(bufferlist& bl, off_t ofs, MD5 *hash,
   return ret;
 }
 
-void RGWPutObjProcessor_Atomic::complete_hash(MD5 *hash)
-{
-  hash->Update((const byte *)pending_data_bl.c_str(), pending_data_bl.length());
-}
-
 
 int RGWPutObjProcessor_Atomic::prepare_init(RGWRados *store, string *oid_rand)
 {
@@ -6729,7 +6724,7 @@ public:
     do {
       void *handle;
       rgw_obj obj;
-      int ret = processor->handle_data(bl, ofs, NULL, &handle, &obj, &again);
+      int ret = processor->handle_data(bl, ofs, &handle, &obj, &again);
       if (ret < 0)
         return ret;
 
@@ -7631,7 +7626,7 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
       void *handle;
       rgw_obj obj;
 
-      ret = processor.handle_data(bl, ofs, NULL, &handle, &obj, &again);
+      ret = processor.handle_data(bl, ofs, &handle, &obj, &again);
       if (ret < 0) {
         return ret;
       }
index 2ea19ce4addc81da05f213b426c0a174ca477110..dc3343eed150d8bdfb2f8e9825e1caa85fcc49a1 100644 (file)
@@ -3288,7 +3288,21 @@ public:
   }
 }; /* RGWChainedCacheImpl */
 
-class RGWPutObjProcessor
+/**
+ * Base of PUT operation.
+ * Allow to create chained data transformers like compresors and encryptors.
+ */
+class RGWPutObjDataProcessor
+{
+public:
+  RGWPutObjDataProcessor(){}
+  virtual ~RGWPutObjDataProcessor(){}
+  virtual int handle_data(bufferlist& bl, off_t ofs, void **phandle, rgw_obj *pobj, bool *again) = 0;
+  virtual int throttle_data(void *handle, const rgw_obj& obj, bool need_to_wait) = 0;
+}; /* RGWPutObjDataProcessor */
+
+
+class RGWPutObjProcessor : public RGWPutObjDataProcessor
 {
 protected:
   RGWRados *store;
@@ -3316,11 +3330,9 @@ public:
     store = _store;
     return 0;
   }
-  virtual int handle_data(bufferlist& bl, off_t ofs, MD5 *hash, void **phandle, rgw_obj *pobj, bool *again) = 0;
-  virtual int throttle_data(void *handle, const rgw_obj& obj, bool need_to_wait) = 0;
-  virtual void complete_hash(MD5 *hash) {
-    assert(0);
-  }
+
+  //virtual int handle_data(bufferlist& bl, off_t ofs, void **phandle, rgw_obj *pobj, bool *again);
+  //virtual int throttle_data(void *handle, const rgw_obj& obj, bool need_to_wait) = 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);
@@ -3430,8 +3442,7 @@ public:
   void set_extra_data_len(uint64_t len) {
     extra_data_len = len;
   }
-  virtual int handle_data(bufferlist& bl, off_t ofs, MD5 *hash, void **phandle, rgw_obj *pobj, bool *again);
-  virtual void complete_hash(MD5 *hash);
+  virtual int handle_data(bufferlist& bl, off_t ofs, void **phandle, rgw_obj *pobj, bool *again);
   bufferlist& get_extra_data() { return extra_data_bl; }
 
   void set_olh_epoch(uint64_t epoch) {