]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/Operations.h
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / librbd / Operations.h
CommitLineData
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"
92f5a8d4 9#include "librbd/exclusive_lock/Policy.h"
7c673cae
FG
10#include "librbd/operation/ObjectMapIterate.h"
11#include <atomic>
12#include <string>
13#include <boost/function.hpp>
14
15class Context;
16
17namespace librbd {
18
19class ImageCtx;
20class ProgressContext;
21
22template <typename ImageCtxT = ImageCtx>
23class Operations {
24public:
25 Operations(ImageCtxT &image_ctx);
26
27 int flatten(ProgressContext &prog_ctx);
28 void execute_flatten(ProgressContext &prog_ctx, Context *on_finish);
29
30 int rebuild_object_map(ProgressContext &prog_ctx);
31 void execute_rebuild_object_map(ProgressContext &prog_ctx,
32 Context *on_finish);
33
34 int check_object_map(ProgressContext &prog_ctx);
35 void check_object_map(ProgressContext &prog_ctx, Context *on_finish);
36
37 void object_map_iterate(ProgressContext &prog_ctx,
38 operation::ObjectIterateWork<ImageCtxT> handle_mismatch,
39 Context* on_finish);
40
41 int rename(const char *dstname);
42 void execute_rename(const std::string &dest_name, Context *on_finish);
43
44 int resize(uint64_t size, bool allow_shrink, ProgressContext& prog_ctx);
45 void execute_resize(uint64_t size, bool allow_shrink, ProgressContext &prog_ctx,
46 Context *on_finish, uint64_t journal_op_tid);
47
48 int snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
91327a77 49 const std::string& snap_name);
7c673cae 50 void snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
91327a77 51 const std::string& snap_name, Context *on_finish);
7c673cae
FG
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,
91327a77 58 const std::string& snap_name,
7c673cae
FG
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,
91327a77 65 const std::string& snap_name);
7c673cae 66 void snap_remove(const cls::rbd::SnapshotNamespace& snap_namespace,
91327a77 67 const std::string& snap_name,
7c673cae
FG
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,
91327a77 79 const std::string& snap_name);
7c673cae
FG
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,
91327a77 85 const std::string& snap_name);
7c673cae
FG
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
11fdf7f2
TL
104 int migrate(ProgressContext &prog_ctx);
105 void execute_migrate(ProgressContext &prog_ctx, Context *on_finish);
106
107 int sparsify(size_t sparse_size, ProgressContext &prog_ctx);
108 void execute_sparsify(size_t sparse_size, ProgressContext &prog_ctx,
109 Context *on_finish);
110
92f5a8d4
TL
111 int prepare_image_update(exclusive_lock::OperationRequestType request_type,
112 bool request_lock);
7c673cae
FG
113
114private:
115 ImageCtxT &m_image_ctx;
116 std::atomic<int> m_async_request_seq;
117
92f5a8d4
TL
118 int invoke_async_request(const std::string& name,
119 exclusive_lock::OperationRequestType request_type,
7c673cae
FG
120 bool permit_snapshot,
121 const boost::function<void(Context*)>& local,
122 const boost::function<void(Context*)>& remote);
123};
124
125} // namespace librbd
126
127extern template class librbd::Operations<librbd::ImageCtx>;
128
129#endif // CEPH_LIBRBD_OPERATIONS_H