From: Adam Kupczyk Date: Wed, 13 Apr 2016 09:00:43 +0000 (+0200) Subject: Introduced filter concepts to RGWGetObj. Plugged in decryption. X-Git-Tag: v11.1.0~429^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=69740441feaa56d1ef3b4e3032a0058f01f55557;p=ceph.git Introduced filter concepts to RGWGetObj. Plugged in decryption. Allows to plug in decompression in future. Signed-off-by: Adam Kupczyk (a.kupczyk@mirantis.com) Conflicts: src/rgw/rgw_op.cc --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 2c905c5fcd7f..90e67d74a898 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1383,7 +1383,7 @@ void RGWGetObj::execute() gc_invalidate_time += (s->cct->_conf->rgw_gc_obj_min_wait / 2); RGWGetObj_CB cb(this); - + RGWGetDataCB* decrypt = nullptr; map::iterator attr_iter; perfcounter->inc(l_rgw_get); @@ -1577,7 +1577,21 @@ void RGWGetObj::execute() perfcounter->inc(l_rgw_get_b, new_end - new_ofs); - op_ret = read_op.iterate(new_ofs, new_end, &cb); + op_ret = this->get_decrypt_filter(&decrypt, cb); + if (op_ret < 0) { + goto done_err; + } + if (decrypt != nullptr) { + off_t tmp_ofs = ofs; + off_t tmp_end = end; + decrypt->fixup_range(tmp_ofs, tmp_end); + op_ret = read_op.iterate(tmp_ofs, tmp_end, decrypt); + if (op_ret >= 0) + op_ret = decrypt->flush(); + delete decrypt; + } + else + op_ret = read_op.iterate(ofs, end, &cb); perfcounter->tinc(l_rgw_get_lat, (ceph_clock_now(s->cct) - start_time)); diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 6ecf998e8b10..17832ed44f40 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -201,6 +201,13 @@ public: virtual RGWOpType get_type() { return RGW_OP_GET_OBJ; } virtual uint32_t op_mask() { return RGW_OP_TYPE_READ; } virtual bool need_object_expiration() { return false; } + /** + * calculates filter used to decrypt RGW objects data + */ + virtual int get_decrypt_filter(RGWGetDataCB** filter, RGWGetDataCB& cb) { + *filter = NULL; + return 0; + } }; class RGWGetObj_CB : public RGWGetDataCB @@ -215,6 +222,36 @@ public: } }; +class RGWGetObj_Filter : public RGWGetDataCB +{ +protected: + RGWGetDataCB& next; +public: + RGWGetObj_Filter(RGWGetDataCB& next): next(next) {} + virtual ~RGWGetObj_Filter() {} + /** + * Passes data through filter. + * Filter can modify content of bl. + * When bl_len == 0 , it means 'flush + */ + virtual int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) { + return next.handle_data(bl, bl_ofs, bl_len); + } + /** + * Flushes any cached data. Used by RGWGetObjFilter. + * Return logic same as handle_data. + */ + virtual int flush() { + return next.flush(); + } + /** + * Allows filter to extend range required for successful filtering + */ + virtual void fixup_range(off_t& bl_ofs, off_t& bl_len) { + next.fixup_range(bl_ofs, bl_len); + } +}; + class RGWBulkDelete : public RGWOp { public: struct acct_path_t { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index dc3343eed150..7406ded0d3ea 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -198,6 +198,17 @@ public: virtual void set_extra_data_len(uint64_t len) { extra_data_len = len; } + /** + * Flushes any cached data. Used by RGWGetObjFilter. + * Return logic same as handle_data. + */ + virtual int flush() { + return 0; + } + /** + * Allows to extend fetch range of RGW object. Used by RGWGetObjFilter. + */ + virtual void fixup_range(off_t& bl_ofs, off_t& bl_end) {} }; class RGWAccessListFilter { diff --git a/src/spdk b/src/spdk index 9322c258084c..c02b17949012 160000 --- a/src/spdk +++ b/src/spdk @@ -1 +1 @@ -Subproject commit 9322c258084c6abdeefe00067f8b310a6e0d9a5a +Subproject commit c02b179490123a3212b0c0d23b69da13965d1552 diff --git a/src/xxHash b/src/xxHash index 1f40c6511fa8..44a6297b298e 160000 --- a/src/xxHash +++ b/src/xxHash @@ -1 +1 @@ -Subproject commit 1f40c6511fa8dd9d2e337ca8c9bc18b3e87663c9 +Subproject commit 44a6297b298e59ab7452defe859f21ed8371aa1c