diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/librbd/cache/PassthroughImageCache.h | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librbd/cache/PassthroughImageCache.h')
-rw-r--r-- | src/librbd/cache/PassthroughImageCache.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/librbd/cache/PassthroughImageCache.h b/src/librbd/cache/PassthroughImageCache.h new file mode 100644 index 00000000..4be69a50 --- /dev/null +++ b/src/librbd/cache/PassthroughImageCache.h @@ -0,0 +1,59 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE +#define CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE + +#include "ImageCache.h" +#include "ImageWriteback.h" + +namespace librbd { + +struct ImageCtx; + +namespace cache { + +/** + * Example passthrough client-side, image extent cache + */ +template <typename ImageCtxT = librbd::ImageCtx> +class PassthroughImageCache : public ImageCache { +public: + explicit PassthroughImageCache(ImageCtx &image_ctx); + + /// client AIO methods + void aio_read(Extents&& image_extents, ceph::bufferlist *bl, + int fadvise_flags, Context *on_finish) override; + void aio_write(Extents&& image_extents, ceph::bufferlist&& bl, + int fadvise_flags, Context *on_finish) override; + void aio_discard(uint64_t offset, uint64_t length, + uint32_t discard_granularity_bytes, + Context *on_finish) override; + void aio_flush(Context *on_finish) override; + void aio_writesame(uint64_t offset, uint64_t length, + ceph::bufferlist&& bl, + int fadvise_flags, Context *on_finish) override; + void aio_compare_and_write(Extents&& image_extents, + ceph::bufferlist&& cmp_bl, ceph::bufferlist&& bl, + uint64_t *mismatch_offset,int fadvise_flags, + Context *on_finish) override; + + /// internal state methods + void init(Context *on_finish) override; + void shut_down(Context *on_finish) override; + + void invalidate(Context *on_finish) override; + void flush(Context *on_finish) override; + +private: + ImageCtxT &m_image_ctx; + ImageWriteback<ImageCtxT> m_image_writeback; + +}; + +} // namespace cache +} // namespace librbd + +extern template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>; + +#endif // CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE |