]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/image/DetachChildRequest.h
import ceph quincy 17.2.1
[ceph.git] / ceph / src / librbd / image / DetachChildRequest.h
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_LIBRBD_IMAGE_DETACH_CHILD_REQUEST_H
5#define CEPH_LIBRBD_IMAGE_DETACH_CHILD_REQUEST_H
6
7#include "include/int_types.h"
8#include "include/buffer.h"
9#include "include/rados/librados.hpp"
10#include "librbd/Types.h"
9f95a23c 11#include "librbd/internal.h"
11fdf7f2
TL
12
13class Context;
14
15namespace librbd {
16
17class ImageCtx;
18
19namespace image {
20
21template <typename ImageCtxT = ImageCtx>
22class DetachChildRequest {
23public:
24 static DetachChildRequest* create(ImageCtxT& image_ctx, Context* on_finish) {
25 return new DetachChildRequest(image_ctx, on_finish);
26 }
27
28 DetachChildRequest(ImageCtxT& image_ctx, Context* on_finish)
29 : m_image_ctx(image_ctx), m_on_finish(on_finish) {
30 }
31 ~DetachChildRequest();
32
33 void send();
34
35private:
36 /**
37 * @verbatim
38 *
39 * <start>
40 * |
41 * (v1) | (v2)
42 * /--------------/ \--------------\
43 * | |
44 * v v
45 * REMOVE_CHILD CHILD_DETACH
46 * | |
47 * | v
48 * | GET_SNAPSHOT
49 * | (snapshot in-use) . |
50 * |/. . . . . . . . . . . . . . . |
51 * | v
52 * | OPEN_PARENT
53 * | |
9f95a23c
TL
54 * | v (has more children)
55 * | REMOVE_SNAPSHOT ---------------\
56 * | | |
57 * | v (noent) |
58 * | (auto-delete when GET_PARENT_TRASH_ENTRY . . . .\|
59 * | last child detached) | |
60 * | v v
61 * | REMOVE_PARENT_FROM_TRASH CLOSE_PARENT
62 * | | |
63 * |/------------------------------/--------------------------/
11fdf7f2
TL
64 * |
65 * v
66 * <finish>
67 *
68 * @endverbatim
69 */
70
71 ImageCtxT& m_image_ctx;
72 Context* m_on_finish;
73
74 librados::IoCtx m_parent_io_ctx;
75 cls::rbd::ParentImageSpec m_parent_spec;
76 std::string m_parent_header_name;
77
78 cls::rbd::SnapshotNamespace m_parent_snap_namespace;
79 std::string m_parent_snap_name;
80
81 ImageCtxT* m_parent_image_ctx = nullptr;
82
83 ceph::bufferlist m_out_bl;
9f95a23c 84 NoOpProgressContext m_no_op;
11fdf7f2
TL
85
86 void clone_v2_child_detach();
87 void handle_clone_v2_child_detach(int r);
88
89 void clone_v2_get_snapshot();
90 void handle_clone_v2_get_snapshot(int r);
91
92 void clone_v2_open_parent();
93 void handle_clone_v2_open_parent(int r);
94
95 void clone_v2_remove_snapshot();
96 void handle_clone_v2_remove_snapshot(int r);
97
9f95a23c
TL
98 void clone_v2_get_parent_trash_entry();
99 void handle_clone_v2_get_parent_trash_entry(int r);
100
101 void clone_v2_remove_parent_from_trash();
102 void handle_clone_v2_remove_parent_from_trash(int r);
103
11fdf7f2
TL
104 void clone_v2_close_parent();
105 void handle_clone_v2_close_parent(int r);
106
107 void clone_v1_remove_child();
108 void handle_clone_v1_remove_child(int r);
109
110 void finish(int r);
111
112};
113
114} // namespace image
115} // namespace librbd
116
117extern template class librbd::image::DetachChildRequest<librbd::ImageCtx>;
118
119#endif // CEPH_LIBRBD_IMAGE_DETACH_CHILD_REQUEST_H