]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/operation/SparsifyRequest.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / librbd / operation / SparsifyRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_LIBRBD_OPERATION_SPARSIFY_REQUEST_H
4 #define CEPH_LIBRBD_OPERATION_SPARSIFY_REQUEST_H
5
6 #include "librbd/operation/Request.h"
7 #include "common/snap_types.h"
8
9 namespace librbd {
10
11 class ImageCtx;
12 class ProgressContext;
13
14 namespace operation {
15
16 template <typename ImageCtxT = ImageCtx>
17 class SparsifyRequest : public Request<ImageCtxT>
18 {
19 public:
20 SparsifyRequest(ImageCtxT &image_ctx, size_t sparse_size, Context *on_finish,
21 ProgressContext &prog_ctx)
22 : Request<ImageCtxT>(image_ctx, on_finish), m_sparse_size(sparse_size),
23 m_prog_ctx(prog_ctx) {
24 }
25
26 protected:
27 void send_op() override;
28 bool should_complete(int r) override;
29 bool can_affect_io() const override {
30 return true;
31 }
32 journal::Event create_event(uint64_t op_tid) const override {
33 ceph_abort();
34 return journal::UnknownEvent();
35 }
36
37 private:
38 /**
39 * @verbatim
40 *
41 * <start>
42 * |
43 * v
44 * SPARSIFY OBJECTS
45 * |
46 * v
47 * <finish>
48 *
49 * @endverbatim
50 */
51
52 size_t m_sparse_size;
53 ProgressContext &m_prog_ctx;
54
55 void sparsify_objects();
56 void handle_sparsify_objects(int r);
57 };
58
59 } // namespace operation
60 } // namespace librbd
61
62 extern template class librbd::operation::SparsifyRequest<librbd::ImageCtx>;
63
64 #endif // CEPH_LIBRBD_OPERATION_SPARSIFY_REQUEST_H