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
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) {
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;
}
goto done;
}
- processor->complete_hash(&hash);
hash.Final(m);
buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5);
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="
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;
}
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;
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;
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)
{
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;
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;
}
}
}; /* 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;
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);
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) {