blob: aeced5d4f3dfcc599fffd4e3a2ef31d3c1acf2c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_LIBRBD_MIGRATION_NBD_STREAM_H
#define CEPH_LIBRBD_MIGRATION_NBD_STREAM_H
#include "include/int_types.h"
#include "librbd/migration/StreamInterface.h"
#include <json_spirit/json_spirit.h>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
struct Context;
namespace librbd {
struct AsioEngine;
struct ImageCtx;
namespace migration {
template <typename> class NBDClient;
template <typename ImageCtxT>
class NBDStream : public StreamInterface {
public:
static NBDStream* create(ImageCtxT* image_ctx,
const json_spirit::mObject& json_object) {
return new NBDStream(image_ctx, json_object);
}
NBDStream(ImageCtxT* image_ctx, const json_spirit::mObject& json_object);
~NBDStream() override;
NBDStream(const NBDStream&) = delete;
NBDStream& operator=(const NBDStream&) = delete;
void open(Context* on_finish) override;
void close(Context* on_finish) override;
void get_size(uint64_t* size, Context* on_finish) override;
void read(io::Extents&& byte_extents, bufferlist* data,
Context* on_finish) override;
void list_sparse_extents(io::Extents&& byte_extents,
io::SparseExtents* sparse_extents,
Context* on_finish) override;
private:
CephContext* m_cct;
std::shared_ptr<AsioEngine> m_asio_engine;
json_spirit::mObject m_json_object;
boost::asio::strand<boost::asio::io_context::executor_type> m_strand;
std::unique_ptr<NBDClient<ImageCtxT>> m_nbd_client;
struct ReadRequest;
struct ListSparseExtentsRequest;
};
} // namespace migration
} // namespace librbd
extern template class librbd::migration::NBDStream<librbd::ImageCtx>;
#endif // CEPH_LIBRBD_MIGRATION_NBD_STREAM_H
|