]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Introduced filter concepts to RGWGetObj. Plugged in decryption.
authorAdam Kupczyk <akupczyk@mirantis.com>
Wed, 13 Apr 2016 09:00:43 +0000 (11:00 +0200)
committerAdam Kupczyk <akupczyk@mirantis.com>
Wed, 2 Nov 2016 10:34:50 +0000 (11:34 +0100)
Allows to plug in decompression in future.

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

src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rados.h
src/spdk
src/xxHash

index 2c905c5fcd7f161e19327a9d63599a621d57aba8..90e67d74a898513ab8cb8a1ffc626de90cf9eda3 100644 (file)
@@ -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<string, bufferlist>::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));
index 6ecf998e8b10c516280e86a88b8c65f79f4f656f..17832ed44f40dae82b78152a5c2ea2254cfe3089 100644 (file)
@@ -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 {
index dc3343eed150d8bdfb2f8e9825e1caa85fcc49a1..7406ded0d3eacad6a04233c4a25b192d8e51e9cb 100644 (file)
@@ -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 {
index 9322c258084c6abdeefe00067f8b310a6e0d9a5a..c02b179490123a3212b0c0d23b69da13965d1552 160000 (submodule)
--- a/src/spdk
+++ b/src/spdk
@@ -1 +1 @@
-Subproject commit 9322c258084c6abdeefe00067f8b310a6e0d9a5a
+Subproject commit c02b179490123a3212b0c0d23b69da13965d1552
index 1f40c6511fa8dd9d2e337ca8c9bc18b3e87663c9..44a6297b298e59ab7452defe859f21ed8371aa1c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1f40c6511fa8dd9d2e337ca8c9bc18b3e87663c9
+Subproject commit 44a6297b298e59ab7452defe859f21ed8371aa1c