]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE | |
5 | #define CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE | |
6 | ||
7 | #include "ImageCache.h" | |
8 | #include "ImageWriteback.h" | |
9 | ||
10 | namespace librbd { | |
11 | ||
12 | struct ImageCtx; | |
13 | ||
14 | namespace cache { | |
15 | ||
16 | /** | |
17 | * Example passthrough client-side, image extent cache | |
18 | */ | |
19 | template <typename ImageCtxT = librbd::ImageCtx> | |
9f95a23c | 20 | class PassthroughImageCache : public ImageCache<ImageCtxT> { |
7c673cae | 21 | public: |
9f95a23c | 22 | using typename ImageCache<ImageCtxT>::Extents; |
11fdf7f2 | 23 | explicit PassthroughImageCache(ImageCtx &image_ctx); |
7c673cae FG |
24 | |
25 | /// client AIO methods | |
26 | void aio_read(Extents&& image_extents, ceph::bufferlist *bl, | |
27 | int fadvise_flags, Context *on_finish) override; | |
28 | void aio_write(Extents&& image_extents, ceph::bufferlist&& bl, | |
29 | int fadvise_flags, Context *on_finish) override; | |
30 | void aio_discard(uint64_t offset, uint64_t length, | |
11fdf7f2 TL |
31 | uint32_t discard_granularity_bytes, |
32 | Context *on_finish) override; | |
7c673cae FG |
33 | void aio_flush(Context *on_finish) override; |
34 | void aio_writesame(uint64_t offset, uint64_t length, | |
35 | ceph::bufferlist&& bl, | |
36 | int fadvise_flags, Context *on_finish) override; | |
c07f9fc5 FG |
37 | void aio_compare_and_write(Extents&& image_extents, |
38 | ceph::bufferlist&& cmp_bl, ceph::bufferlist&& bl, | |
39 | uint64_t *mismatch_offset,int fadvise_flags, | |
40 | Context *on_finish) override; | |
7c673cae FG |
41 | |
42 | /// internal state methods | |
43 | void init(Context *on_finish) override; | |
44 | void shut_down(Context *on_finish) override; | |
45 | ||
46 | void invalidate(Context *on_finish) override; | |
47 | void flush(Context *on_finish) override; | |
48 | ||
49 | private: | |
50 | ImageCtxT &m_image_ctx; | |
51 | ImageWriteback<ImageCtxT> m_image_writeback; | |
52 | ||
53 | }; | |
54 | ||
55 | } // namespace cache | |
56 | } // namespace librbd | |
57 | ||
58 | extern template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>; | |
59 | ||
60 | #endif // CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE |