]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/cache/PassthroughImageCache.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / librbd / cache / PassthroughImageCache.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "PassthroughImageCache.h"
5 #include "include/buffer.h"
6 #include "common/dout.h"
7 #include "librbd/ImageCtx.h"
8
9 #define dout_subsys ceph_subsys_rbd
10 #undef dout_prefix
11 #define dout_prefix *_dout << "librbd::PassthroughImageCache: " << this << " " \
12 << __func__ << ": "
13
14 namespace librbd {
15 namespace cache {
16
17 template <typename I>
18 PassthroughImageCache<I>::PassthroughImageCache(ImageCtx &image_ctx)
19 : m_image_ctx(image_ctx), m_image_writeback(image_ctx) {
20 }
21
22 template <typename I>
23 void PassthroughImageCache<I>::aio_read(Extents &&image_extents, bufferlist *bl,
24 int fadvise_flags, Context *on_finish) {
25 CephContext *cct = m_image_ctx.cct;
26 ldout(cct, 20) << "image_extents=" << image_extents << ", "
27 << "on_finish=" << on_finish << dendl;
28
29 m_image_writeback.aio_read(std::move(image_extents), bl, fadvise_flags,
30 on_finish);
31 }
32
33 template <typename I>
34 void PassthroughImageCache<I>::aio_write(Extents &&image_extents,
35 bufferlist&& bl,
36 int fadvise_flags,
37 Context *on_finish) {
38 CephContext *cct = m_image_ctx.cct;
39 ldout(cct, 20) << "image_extents=" << image_extents << ", "
40 << "on_finish=" << on_finish << dendl;
41
42 m_image_writeback.aio_write(std::move(image_extents), std::move(bl),
43 fadvise_flags, on_finish);
44 }
45
46 template <typename I>
47 void PassthroughImageCache<I>::aio_discard(uint64_t offset, uint64_t length,
48 bool skip_partial_discard, Context *on_finish) {
49 CephContext *cct = m_image_ctx.cct;
50 ldout(cct, 20) << "offset=" << offset << ", "
51 << "length=" << length << ", "
52 << "on_finish=" << on_finish << dendl;
53
54 m_image_writeback.aio_discard(offset, length, skip_partial_discard, on_finish);
55 }
56
57 template <typename I>
58 void PassthroughImageCache<I>::aio_flush(Context *on_finish) {
59 CephContext *cct = m_image_ctx.cct;
60 ldout(cct, 20) << "on_finish=" << on_finish << dendl;
61
62 m_image_writeback.aio_flush(on_finish);
63 }
64
65 template <typename I>
66 void PassthroughImageCache<I>::aio_writesame(uint64_t offset, uint64_t length,
67 bufferlist&& bl, int fadvise_flags,
68 Context *on_finish) {
69 CephContext *cct = m_image_ctx.cct;
70 ldout(cct, 20) << "offset=" << offset << ", "
71 << "length=" << length << ", "
72 << "data_len=" << bl.length() << ", "
73 << "on_finish=" << on_finish << dendl;
74
75 m_image_writeback.aio_writesame(offset, length, std::move(bl), fadvise_flags,
76 on_finish);
77 }
78
79 template <typename I>
80 void PassthroughImageCache<I>::init(Context *on_finish) {
81 CephContext *cct = m_image_ctx.cct;
82 ldout(cct, 20) << dendl;
83
84 on_finish->complete(0);
85 }
86
87 template <typename I>
88 void PassthroughImageCache<I>::shut_down(Context *on_finish) {
89 CephContext *cct = m_image_ctx.cct;
90 ldout(cct, 20) << dendl;
91
92 on_finish->complete(0);
93 }
94
95 template <typename I>
96 void PassthroughImageCache<I>::invalidate(Context *on_finish) {
97 CephContext *cct = m_image_ctx.cct;
98 ldout(cct, 20) << dendl;
99
100 // dump cache contents (don't have anything)
101 on_finish->complete(0);
102 }
103
104 template <typename I>
105 void PassthroughImageCache<I>::flush(Context *on_finish) {
106 CephContext *cct = m_image_ctx.cct;
107 ldout(cct, 20) << dendl;
108
109 // internal flush -- nothing to writeback but make sure
110 // in-flight IO is flushed
111 aio_flush(on_finish);
112 }
113
114 } // namespace cache
115 } // namespace librbd
116
117 template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>;