From: Adam Kupczyk Date: Thu, 7 Apr 2016 14:01:59 +0000 (+0200) Subject: Changed hash calculation logic. X-Git-Tag: v11.1.0~429^2~33 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9f4233d8435126d111dc4d25426d042cefc25618;p=ceph.git Changed hash calculation logic. 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 --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 13ac2625029a..5d998e111c8b 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a79c2f34c7fe..292cb531310c 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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; } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 2431b7cf5850..6ecf998e8b10 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 64939b25aaee..ecdf104ea4fc 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 2ea19ce4addc..dc3343eed150 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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& 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) {