]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_OPERATIONS_H | |
5 | #define CEPH_LIBRBD_OPERATIONS_H | |
6 | ||
7 | #include "cls/rbd/cls_rbd_types.h" | |
8 | #include "include/int_types.h" | |
9 | #include "librbd/operation/ObjectMapIterate.h" | |
10 | #include <atomic> | |
11 | #include <string> | |
12 | #include <boost/function.hpp> | |
13 | ||
14 | class Context; | |
15 | ||
16 | namespace librbd { | |
17 | ||
18 | class ImageCtx; | |
19 | class ProgressContext; | |
20 | ||
21 | template <typename ImageCtxT = ImageCtx> | |
22 | class Operations { | |
23 | public: | |
24 | Operations(ImageCtxT &image_ctx); | |
25 | ||
26 | int flatten(ProgressContext &prog_ctx); | |
27 | void execute_flatten(ProgressContext &prog_ctx, Context *on_finish); | |
28 | ||
29 | int rebuild_object_map(ProgressContext &prog_ctx); | |
30 | void execute_rebuild_object_map(ProgressContext &prog_ctx, | |
31 | Context *on_finish); | |
32 | ||
33 | int check_object_map(ProgressContext &prog_ctx); | |
34 | void check_object_map(ProgressContext &prog_ctx, Context *on_finish); | |
35 | ||
36 | void object_map_iterate(ProgressContext &prog_ctx, | |
37 | operation::ObjectIterateWork<ImageCtxT> handle_mismatch, | |
38 | Context* on_finish); | |
39 | ||
40 | int rename(const char *dstname); | |
41 | void execute_rename(const std::string &dest_name, Context *on_finish); | |
42 | ||
43 | int resize(uint64_t size, bool allow_shrink, ProgressContext& prog_ctx); | |
44 | void execute_resize(uint64_t size, bool allow_shrink, ProgressContext &prog_ctx, | |
45 | Context *on_finish, uint64_t journal_op_tid); | |
46 | ||
47 | int snap_create(const cls::rbd::SnapshotNamespace &snap_namespace, | |
48 | const char *snap_name); | |
49 | void snap_create(const cls::rbd::SnapshotNamespace &snap_namespace, | |
50 | const char *snap_name, | |
51 | Context *on_finish); | |
52 | void execute_snap_create(const cls::rbd::SnapshotNamespace &snap_namespace, | |
53 | const std::string &snap_name, | |
54 | Context *on_finish, | |
55 | uint64_t journal_op_tid, bool skip_object_map); | |
56 | ||
57 | int snap_rollback(const cls::rbd::SnapshotNamespace& snap_namespace, | |
58 | const char *snap_name, | |
59 | ProgressContext& prog_ctx); | |
60 | void execute_snap_rollback(const cls::rbd::SnapshotNamespace& snap_namespace, | |
61 | const std::string &snap_name, | |
62 | ProgressContext& prog_ctx, Context *on_finish); | |
63 | ||
64 | int snap_remove(const cls::rbd::SnapshotNamespace& snap_namespace, | |
65 | const char *snap_name); | |
66 | void snap_remove(const cls::rbd::SnapshotNamespace& snap_namespace, | |
67 | const char *snap_name, | |
68 | Context *on_finish); | |
69 | void execute_snap_remove(const cls::rbd::SnapshotNamespace& snap_namespace, | |
70 | const std::string &snap_name, | |
71 | Context *on_finish); | |
72 | ||
73 | int snap_rename(const char *srcname, const char *dstname); | |
74 | void execute_snap_rename(const uint64_t src_snap_id, | |
75 | const std::string &dest_snap_name, | |
76 | Context *on_finish); | |
77 | ||
78 | int snap_protect(const cls::rbd::SnapshotNamespace& snap_namespace, | |
79 | const char *snap_name); | |
80 | void execute_snap_protect(const cls::rbd::SnapshotNamespace& snap_namespace, | |
81 | const std::string &snap_name, | |
82 | Context *on_finish); | |
83 | ||
84 | int snap_unprotect(const cls::rbd::SnapshotNamespace& snap_namespace, | |
85 | const char *snap_name); | |
86 | void execute_snap_unprotect(const cls::rbd::SnapshotNamespace& snap_namespace, | |
87 | const std::string &snap_name, | |
88 | Context *on_finish); | |
89 | ||
90 | int snap_set_limit(uint64_t limit); | |
91 | void execute_snap_set_limit(uint64_t limit, Context *on_finish); | |
92 | ||
93 | int update_features(uint64_t features, bool enabled); | |
94 | void execute_update_features(uint64_t features, bool enabled, | |
95 | Context *on_finish, uint64_t journal_op_tid); | |
96 | ||
97 | int metadata_set(const std::string &key, const std::string &value); | |
98 | void execute_metadata_set(const std::string &key, const std::string &value, | |
99 | Context *on_finish); | |
100 | ||
101 | int metadata_remove(const std::string &key); | |
102 | void execute_metadata_remove(const std::string &key, Context *on_finish); | |
103 | ||
104 | int prepare_image_update(); | |
105 | ||
106 | private: | |
107 | ImageCtxT &m_image_ctx; | |
108 | std::atomic<int> m_async_request_seq; | |
109 | ||
110 | int invoke_async_request(const std::string& request_type, | |
111 | bool permit_snapshot, | |
112 | const boost::function<void(Context*)>& local, | |
113 | const boost::function<void(Context*)>& remote); | |
114 | }; | |
115 | ||
116 | } // namespace librbd | |
117 | ||
118 | extern template class librbd::Operations<librbd::ImageCtx>; | |
119 | ||
120 | #endif // CEPH_LIBRBD_OPERATIONS_H |