]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/cache/PassthroughImageCache.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / librbd / cache / PassthroughImageCache.cc
CommitLineData
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#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
14namespace librbd {
15namespace cache {
16
17template <typename I>
18PassthroughImageCache<I>::PassthroughImageCache(ImageCtx &image_ctx)
19 : m_image_ctx(image_ctx), m_image_writeback(image_ctx) {
20}
21
22template <typename I>
23void 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
33template <typename I>
34void 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
46template <typename I>
47void PassthroughImageCache<I>::aio_discard(uint64_t offset, uint64_t length,
11fdf7f2
TL
48 uint32_t discard_granularity_bytes,
49 Context *on_finish) {
7c673cae
FG
50 CephContext *cct = m_image_ctx.cct;
51 ldout(cct, 20) << "offset=" << offset << ", "
52 << "length=" << length << ", "
53 << "on_finish=" << on_finish << dendl;
54
11fdf7f2
TL
55 m_image_writeback.aio_discard(offset, length, discard_granularity_bytes,
56 on_finish);
7c673cae
FG
57}
58
59template <typename I>
60void PassthroughImageCache<I>::aio_flush(Context *on_finish) {
61 CephContext *cct = m_image_ctx.cct;
62 ldout(cct, 20) << "on_finish=" << on_finish << dendl;
63
64 m_image_writeback.aio_flush(on_finish);
65}
66
67template <typename I>
68void PassthroughImageCache<I>::aio_writesame(uint64_t offset, uint64_t length,
69 bufferlist&& bl, int fadvise_flags,
70 Context *on_finish) {
71 CephContext *cct = m_image_ctx.cct;
72 ldout(cct, 20) << "offset=" << offset << ", "
73 << "length=" << length << ", "
74 << "data_len=" << bl.length() << ", "
75 << "on_finish=" << on_finish << dendl;
76
77 m_image_writeback.aio_writesame(offset, length, std::move(bl), fadvise_flags,
78 on_finish);
79}
80
c07f9fc5
FG
81template <typename I>
82void PassthroughImageCache<I>::aio_compare_and_write(Extents &&image_extents,
83 bufferlist&& cmp_bl,
84 bufferlist&& bl,
85 uint64_t *mismatch_offset,
86 int fadvise_flags,
87 Context *on_finish) {
88 CephContext *cct = m_image_ctx.cct;
89 ldout(cct, 20) << "image_extents=" << image_extents << ", "
90 << "on_finish=" << on_finish << dendl;
91
92 m_image_writeback.aio_compare_and_write(
93 std::move(image_extents), std::move(cmp_bl), std::move(bl), mismatch_offset,
94 fadvise_flags, on_finish);
95}
96
7c673cae
FG
97template <typename I>
98void PassthroughImageCache<I>::init(Context *on_finish) {
99 CephContext *cct = m_image_ctx.cct;
100 ldout(cct, 20) << dendl;
101
102 on_finish->complete(0);
103}
104
105template <typename I>
106void PassthroughImageCache<I>::shut_down(Context *on_finish) {
107 CephContext *cct = m_image_ctx.cct;
108 ldout(cct, 20) << dendl;
109
110 on_finish->complete(0);
111}
112
113template <typename I>
114void PassthroughImageCache<I>::invalidate(Context *on_finish) {
115 CephContext *cct = m_image_ctx.cct;
116 ldout(cct, 20) << dendl;
117
118 // dump cache contents (don't have anything)
119 on_finish->complete(0);
120}
121
122template <typename I>
123void PassthroughImageCache<I>::flush(Context *on_finish) {
124 CephContext *cct = m_image_ctx.cct;
125 ldout(cct, 20) << dendl;
126
127 // internal flush -- nothing to writeback but make sure
128 // in-flight IO is flushed
129 aio_flush(on_finish);
130}
131
132} // namespace cache
133} // namespace librbd
134
135template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>;