]>
git.proxmox.com Git - ceph.git/blob - 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
4 #include "PassthroughImageCache.h"
5 #include "include/buffer.h"
6 #include "common/dout.h"
7 #include "librbd/ImageCtx.h"
9 #define dout_subsys ceph_subsys_rbd
11 #define dout_prefix *_dout << "librbd::PassthroughImageCache: " << this << " " \
18 PassthroughImageCache
<I
>::PassthroughImageCache(ImageCtx
&image_ctx
)
19 : m_image_ctx(image_ctx
), m_image_writeback(image_ctx
) {
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
;
29 m_image_writeback
.aio_read(std::move(image_extents
), bl
, fadvise_flags
,
34 void PassthroughImageCache
<I
>::aio_write(Extents
&&image_extents
,
38 CephContext
*cct
= m_image_ctx
.cct
;
39 ldout(cct
, 20) << "image_extents=" << image_extents
<< ", "
40 << "on_finish=" << on_finish
<< dendl
;
42 m_image_writeback
.aio_write(std::move(image_extents
), std::move(bl
),
43 fadvise_flags
, on_finish
);
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
;
54 m_image_writeback
.aio_discard(offset
, length
, skip_partial_discard
, on_finish
);
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
;
62 m_image_writeback
.aio_flush(on_finish
);
66 void PassthroughImageCache
<I
>::aio_writesame(uint64_t offset
, uint64_t length
,
67 bufferlist
&& bl
, int fadvise_flags
,
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
;
75 m_image_writeback
.aio_writesame(offset
, length
, std::move(bl
), fadvise_flags
,
80 void PassthroughImageCache
<I
>::aio_compare_and_write(Extents
&&image_extents
,
83 uint64_t *mismatch_offset
,
86 CephContext
*cct
= m_image_ctx
.cct
;
87 ldout(cct
, 20) << "image_extents=" << image_extents
<< ", "
88 << "on_finish=" << on_finish
<< dendl
;
90 m_image_writeback
.aio_compare_and_write(
91 std::move(image_extents
), std::move(cmp_bl
), std::move(bl
), mismatch_offset
,
92 fadvise_flags
, on_finish
);
96 void PassthroughImageCache
<I
>::init(Context
*on_finish
) {
97 CephContext
*cct
= m_image_ctx
.cct
;
98 ldout(cct
, 20) << dendl
;
100 on_finish
->complete(0);
103 template <typename I
>
104 void PassthroughImageCache
<I
>::shut_down(Context
*on_finish
) {
105 CephContext
*cct
= m_image_ctx
.cct
;
106 ldout(cct
, 20) << dendl
;
108 on_finish
->complete(0);
111 template <typename I
>
112 void PassthroughImageCache
<I
>::invalidate(Context
*on_finish
) {
113 CephContext
*cct
= m_image_ctx
.cct
;
114 ldout(cct
, 20) << dendl
;
116 // dump cache contents (don't have anything)
117 on_finish
->complete(0);
120 template <typename I
>
121 void PassthroughImageCache
<I
>::flush(Context
*on_finish
) {
122 CephContext
*cct
= m_image_ctx
.cct
;
123 ldout(cct
, 20) << dendl
;
125 // internal flush -- nothing to writeback but make sure
126 // in-flight IO is flushed
127 aio_flush(on_finish
);
131 } // namespace librbd
133 template class librbd::cache::PassthroughImageCache
<librbd::ImageCtx
>;