From: Seena Fallah Date: Sat, 7 Jun 2025 20:12:04 +0000 (+0200) Subject: rgw: introduce DataProcessorFilter X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=81145b1a12966a333aec5c0a6e7531c20faeb41d;p=ceph.git rgw: introduce DataProcessorFilter DataProcessor to RGWGetObj_Filter pipe where allows a RGWGetObj_Filter instance to process DataProcessor. Co-authored-by: Marcus Watts Signed-off-by: Seena Fallah --- diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index a832218ee5f..71c158f489d 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -375,6 +375,38 @@ public: } }; +class DataProcessorFilter : public RGWGetObj_Filter +{ + rgw::sal::DataProcessor* processor; + off_t ofs = 0; + +public: + DataProcessorFilter() {} + explicit DataProcessorFilter(rgw::sal::DataProcessor* proc) : processor(proc) {} + ~DataProcessorFilter() override {} + + void set_processor(rgw::sal::DataProcessor* proc) { + processor = proc; + } + + int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) override { + // DataProcessor requires ownership of the entire bufferlist. + // RGWGetObj_Filter, however, may reuse the original bufferlist after this call. + // To avoid unintended side effects, we create a copy of the relevant portion. + bufferlist copy_bl; + bl.begin().copy(bl_len, copy_bl); + + int ret = processor->process(std::move(copy_bl), ofs); + if (ret < 0) return ret; + ofs += bl_len; + return bl_len; + } + + int flush() override { + return processor->process({}, ofs); + } +}; + class RGWGetObj : public RGWOp { protected: const char *range_str;