]>
Commit | Line | Data |
---|---|---|
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> | |
20 | class PassthroughImageCache : public ImageCache { | |
21 | public: | |
22 | PassthroughImageCache(ImageCtx &image_ctx); | |
23 | ||
24 | /// client AIO methods | |
25 | void aio_read(Extents&& image_extents, ceph::bufferlist *bl, | |
26 | int fadvise_flags, Context *on_finish) override; | |
27 | void aio_write(Extents&& image_extents, ceph::bufferlist&& bl, | |
28 | int fadvise_flags, Context *on_finish) override; | |
29 | void aio_discard(uint64_t offset, uint64_t length, | |
30 | bool skip_partial_discard, Context *on_finish); | |
31 | void aio_flush(Context *on_finish) override; | |
32 | void aio_writesame(uint64_t offset, uint64_t length, | |
33 | ceph::bufferlist&& bl, | |
34 | int fadvise_flags, Context *on_finish) override; | |
35 | void aio_compare_and_write(Extents&& image_extents, | |
36 | ceph::bufferlist&& cmp_bl, ceph::bufferlist&& bl, | |
37 | uint64_t *mismatch_offset,int fadvise_flags, | |
38 | Context *on_finish) override; | |
39 | ||
40 | /// internal state methods | |
41 | void init(Context *on_finish) override; | |
42 | void shut_down(Context *on_finish) override; | |
43 | ||
44 | void invalidate(Context *on_finish) override; | |
45 | void flush(Context *on_finish) override; | |
46 | ||
47 | private: | |
48 | ImageCtxT &m_image_ctx; | |
49 | ImageWriteback<ImageCtxT> m_image_writeback; | |
50 | ||
51 | }; | |
52 | ||
53 | } // namespace cache | |
54 | } // namespace librbd | |
55 | ||
56 | extern template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>; | |
57 | ||
58 | #endif // CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE |