diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/tools/immutable_object_cache/Types.h | |
parent | Initial commit. (diff) | |
download | ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/tools/immutable_object_cache/Types.h | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/src/tools/immutable_object_cache/Types.h b/src/tools/immutable_object_cache/Types.h new file mode 100644 index 000000000..05394d843 --- /dev/null +++ b/src/tools/immutable_object_cache/Types.h @@ -0,0 +1,136 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_CACHE_TYPES_H +#define CEPH_CACHE_TYPES_H + +#include "include/encoding.h" +#include "include/Context.h" +#include "SocketCommon.h" + +namespace ceph { +namespace immutable_obj_cache { + +namespace { +struct HeaderHelper { + uint8_t v; + uint8_t c_v; + ceph_le32 len; +}__attribute__((packed)); + +inline uint8_t get_header_size() { + return sizeof(HeaderHelper); +} + +inline uint32_t get_data_len(char* buf) { + HeaderHelper* header = reinterpret_cast<HeaderHelper*>(buf); + return header->len; +} +} // namespace + +class ObjectCacheRequest { + public: + uint16_t type; + uint64_t seq; + + bufferlist payload; + + CacheGenContextURef process_msg; + + ObjectCacheRequest(); + ObjectCacheRequest(uint16_t type, uint64_t seq); + virtual ~ObjectCacheRequest(); + + // encode consists of two steps + // step 1 : directly encode common bits using encode method of base classs. + // step 2 : according to payload_empty, determine whether addtional bits + // need to be encoded which be implements by child class. + void encode(); + void decode(bufferlist& bl); + bufferlist get_payload_bufferlist() { return payload; } + + virtual void encode_payload() = 0; + virtual void decode_payload(bufferlist::const_iterator bl_it, + __u8 encode_version) = 0; + virtual uint16_t get_request_type() = 0; + virtual bool payload_empty() = 0; +}; + +class ObjectCacheRegData : public ObjectCacheRequest { + public: + std::string version; + ObjectCacheRegData(); + ObjectCacheRegData(uint16_t t, uint64_t s, const std::string &version); + ObjectCacheRegData(uint16_t t, uint64_t s); + ~ObjectCacheRegData() override; + void encode_payload() override; + void decode_payload(bufferlist::const_iterator bl, + __u8 encode_version) override; + uint16_t get_request_type() override { return RBDSC_REGISTER; } + bool payload_empty() override { return false; } +}; + +class ObjectCacheRegReplyData : public ObjectCacheRequest { + public: + ObjectCacheRegReplyData(); + ObjectCacheRegReplyData(uint16_t t, uint64_t s); + ~ObjectCacheRegReplyData() override; + void encode_payload() override; + void decode_payload(bufferlist::const_iterator iter, + __u8 encode_version) override; + uint16_t get_request_type() override { return RBDSC_REGISTER_REPLY; } + bool payload_empty() override { return true; } +}; + +class ObjectCacheReadData : public ObjectCacheRequest { + public: + uint64_t read_offset; + uint64_t read_len; + uint64_t pool_id; + uint64_t snap_id; + uint64_t object_size = 0; + std::string oid; + std::string pool_namespace; + ObjectCacheReadData(uint16_t t, uint64_t s, uint64_t read_offset, + uint64_t read_len, uint64_t pool_id, + uint64_t snap_id, uint64_t object_size, + std::string oid, std::string pool_namespace); + ObjectCacheReadData(uint16_t t, uint64_t s); + ~ObjectCacheReadData() override; + void encode_payload() override; + void decode_payload(bufferlist::const_iterator bl, + __u8 encode_version) override; + uint16_t get_request_type() override { return RBDSC_READ; } + bool payload_empty() override { return false; } +}; + +class ObjectCacheReadReplyData : public ObjectCacheRequest { + public: + std::string cache_path; + ObjectCacheReadReplyData(uint16_t t, uint64_t s, std::string cache_path); + ObjectCacheReadReplyData(uint16_t t, uint64_t s); + ~ObjectCacheReadReplyData() override; + void encode_payload() override; + void decode_payload(bufferlist::const_iterator bl, + __u8 encode_version) override; + uint16_t get_request_type() override { return RBDSC_READ_REPLY; } + bool payload_empty() override { return false; } +}; + +class ObjectCacheReadRadosData : public ObjectCacheRequest { + public: + ObjectCacheReadRadosData(); + ObjectCacheReadRadosData(uint16_t t, uint64_t s); + ~ObjectCacheReadRadosData() override; + void encode_payload() override; + void decode_payload(bufferlist::const_iterator bl, + __u8 encode_version) override; + uint16_t get_request_type() override { return RBDSC_READ_RADOS; } + bool payload_empty() override { return true; } +}; + +ObjectCacheRequest* decode_object_cache_request(bufferlist payload_buffer); + +} // namespace immutable_obj_cache +} // namespace ceph +#endif // CEPH_CACHE_TYPES_H |