1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_IO_READ_RESULT_H
5 #define CEPH_LIBRBD_IO_READ_RESULT_H
7 #include "include/int_types.h"
8 #include "include/buffer_fwd.h"
9 #include "include/Context.h"
10 #include "librbd/io/Types.h"
11 #include "osdc/Striper.h"
13 #include <boost/variant/variant.hpp>
24 template <typename
> struct ObjectReadRequest
;
28 struct C_ReadRequest
: public Context
{
29 AioCompletion
*aio_completion
;
32 C_ReadRequest(AioCompletion
*aio_completion
);
34 void finish(int r
) override
;
39 struct C_ImageReadRequest
: public C_ReadRequest
{
40 Extents image_extents
;
42 C_ImageReadRequest(AioCompletion
*aio_completion
,
43 const Extents image_extents
)
44 : C_ReadRequest(aio_completion
), image_extents(image_extents
) {
47 void finish(int r
) override
;
50 struct C_SparseReadRequestBase
: public C_ReadRequest
{
53 C_SparseReadRequestBase(AioCompletion
*aio_completion
, bool ignore_enoent
)
54 : C_ReadRequest(aio_completion
), ignore_enoent(ignore_enoent
) {
57 using C_ReadRequest::finish
;
58 void finish(ExtentMap
&extent_map
, const Extents
&buffer_extents
,
59 uint64_t offset
, size_t length
, bufferlist
&bl
, int r
);
62 template <typename ImageCtxT
= ImageCtx
>
63 struct C_SparseReadRequest
: public C_SparseReadRequestBase
{
64 ObjectReadRequest
<ImageCtxT
> *request
;
65 Extents buffer_extents
;
67 C_SparseReadRequest(AioCompletion
*aio_completion
, Extents
&& buffer_extents
,
69 : C_SparseReadRequestBase(aio_completion
, ignore_enoent
),
70 buffer_extents(std::move(buffer_extents
)) {
73 void finish(int r
) override
{
74 C_SparseReadRequestBase::finish(request
->get_extent_map(), buffer_extents
,
75 request
->get_offset(),
76 request
->get_length(), request
->data(),
82 ReadResult(char *buf
, size_t buf_len
);
83 ReadResult(const struct iovec
*iov
, int iov_count
);
84 ReadResult(ceph::bufferlist
*bl
);
86 void set_clip_length(size_t length
);
87 void assemble_result(CephContext
*cct
);
97 Linear(char *buf
, size_t buf_len
) : buf(buf
), buf_len(buf_len
) {
102 const struct iovec
*iov
;
105 Vector(const struct iovec
*iov
, int iov_count
)
106 : iov(iov
), iov_count(iov_count
) {
111 ceph::bufferlist
*bl
;
113 Bufferlist(ceph::bufferlist
*bl
) : bl(bl
) {
117 typedef boost::variant
<Empty
,
121 struct SetClipLengthVisitor
;
122 struct AssembleResultVisitor
;
125 Striper::StripedReadResult m_destriper
;
130 } // namespace librbd
132 #endif // CEPH_LIBRBD_IO_READ_RESULT_H