]>
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
>::init(Context
*on_finish
) {
81 CephContext
*cct
= m_image_ctx
.cct
;
82 ldout(cct
, 20) << dendl
;
84 on_finish
->complete(0);
88 void PassthroughImageCache
<I
>::shut_down(Context
*on_finish
) {
89 CephContext
*cct
= m_image_ctx
.cct
;
90 ldout(cct
, 20) << dendl
;
92 on_finish
->complete(0);
96 void PassthroughImageCache
<I
>::invalidate(Context
*on_finish
) {
97 CephContext
*cct
= m_image_ctx
.cct
;
98 ldout(cct
, 20) << dendl
;
100 // dump cache contents (don't have anything)
101 on_finish
->complete(0);
104 template <typename I
>
105 void PassthroughImageCache
<I
>::flush(Context
*on_finish
) {
106 CephContext
*cct
= m_image_ctx
.cct
;
107 ldout(cct
, 20) << dendl
;
109 // internal flush -- nothing to writeback but make sure
110 // in-flight IO is flushed
111 aio_flush(on_finish
);
115 } // namespace librbd
117 template class librbd::cache::PassthroughImageCache
<librbd::ImageCtx
>;