]>
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_IMAGE_CACHE | |
5 | #define CEPH_LIBRBD_CACHE_IMAGE_CACHE | |
6 | ||
7 | #include "include/buffer_fwd.h" | |
8 | #include "include/int_types.h" | |
9f95a23c | 9 | #include "librbd/io/Types.h" |
7c673cae FG |
10 | #include <vector> |
11 | ||
12 | class Context; | |
13 | ||
14 | namespace librbd { | |
9f95a23c | 15 | struct ImageCtx; |
7c673cae FG |
16 | namespace cache { |
17 | ||
18 | /** | |
19 | * client-side, image extent cache interface | |
20 | */ | |
9f95a23c | 21 | template <typename ImageCtxT = ImageCtx> |
7c673cae | 22 | struct ImageCache { |
9f95a23c TL |
23 | protected: |
24 | ImageCache() {} | |
25 | public: | |
26 | typedef io::Extent Extent; | |
27 | typedef io::Extents Extents; | |
7c673cae | 28 | |
9f95a23c | 29 | virtual ~ImageCache() {} |
7c673cae FG |
30 | |
31 | /// client AIO methods | |
32 | virtual void aio_read(Extents&& image_extents, ceph::bufferlist* bl, | |
33 | int fadvise_flags, Context *on_finish) = 0; | |
34 | virtual void aio_write(Extents&& image_extents, ceph::bufferlist&& bl, | |
35 | int fadvise_flags, Context *on_finish) = 0; | |
36 | virtual void aio_discard(uint64_t offset, uint64_t length, | |
11fdf7f2 TL |
37 | uint32_t discard_granularity_bytes, |
38 | Context *on_finish) = 0; | |
7c673cae FG |
39 | virtual void aio_flush(Context *on_finish) = 0; |
40 | virtual void aio_writesame(uint64_t offset, uint64_t length, | |
41 | ceph::bufferlist&& bl, | |
42 | int fadvise_flags, Context *on_finish) = 0; | |
c07f9fc5 FG |
43 | virtual void aio_compare_and_write(Extents&& image_extents, |
44 | ceph::bufferlist&& cmp_bl, | |
45 | ceph::bufferlist&& bl, | |
46 | uint64_t *mismatch_offset, | |
47 | int fadvise_flags, | |
48 | Context *on_finish) = 0; | |
7c673cae FG |
49 | |
50 | /// internal state methods | |
51 | virtual void init(Context *on_finish) = 0; | |
52 | virtual void shut_down(Context *on_finish) = 0; | |
53 | ||
54 | virtual void invalidate(Context *on_finish) = 0; | |
55 | virtual void flush(Context *on_finish) = 0; | |
7c673cae FG |
56 | }; |
57 | ||
58 | } // namespace cache | |
59 | } // namespace librbd | |
60 | ||
9f95a23c TL |
61 | extern template class librbd::cache::ImageCache<librbd::ImageCtx>; |
62 | ||
7c673cae | 63 | #endif // CEPH_LIBRBD_CACHE_IMAGE_CACHE |