1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_OPERATIONS_H
5 #define CEPH_LIBRBD_OPERATIONS_H
7 #include "cls/rbd/cls_rbd_types.h"
8 #include "include/int_types.h"
9 #include "librbd/exclusive_lock/Policy.h"
10 #include "librbd/operation/ObjectMapIterate.h"
13 #include <boost/function.hpp>
20 class ProgressContext
;
22 template <typename ImageCtxT
= ImageCtx
>
25 Operations(ImageCtxT
&image_ctx
);
27 int flatten(ProgressContext
&prog_ctx
);
28 void execute_flatten(ProgressContext
&prog_ctx
, Context
*on_finish
);
30 int rebuild_object_map(ProgressContext
&prog_ctx
);
31 void execute_rebuild_object_map(ProgressContext
&prog_ctx
,
34 int check_object_map(ProgressContext
&prog_ctx
);
35 void check_object_map(ProgressContext
&prog_ctx
, Context
*on_finish
);
37 void object_map_iterate(ProgressContext
&prog_ctx
,
38 operation::ObjectIterateWork
<ImageCtxT
> handle_mismatch
,
41 int rename(const char *dstname
);
42 void execute_rename(const std::string
&dest_name
, Context
*on_finish
);
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
);
48 int snap_create(const cls::rbd::SnapshotNamespace
&snap_namespace
,
49 const std::string
& snap_name
);
50 void snap_create(const cls::rbd::SnapshotNamespace
&snap_namespace
,
51 const std::string
& snap_name
, Context
*on_finish
);
52 void execute_snap_create(const cls::rbd::SnapshotNamespace
&snap_namespace
,
53 const std::string
&snap_name
,
55 uint64_t journal_op_tid
, bool skip_object_map
);
57 int snap_rollback(const cls::rbd::SnapshotNamespace
& snap_namespace
,
58 const std::string
& 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
);
64 int snap_remove(const cls::rbd::SnapshotNamespace
& snap_namespace
,
65 const std::string
& snap_name
);
66 void snap_remove(const cls::rbd::SnapshotNamespace
& snap_namespace
,
67 const std::string
& snap_name
,
69 void execute_snap_remove(const cls::rbd::SnapshotNamespace
& snap_namespace
,
70 const std::string
&snap_name
,
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
,
78 int snap_protect(const cls::rbd::SnapshotNamespace
& snap_namespace
,
79 const std::string
& snap_name
);
80 void execute_snap_protect(const cls::rbd::SnapshotNamespace
& snap_namespace
,
81 const std::string
&snap_name
,
84 int snap_unprotect(const cls::rbd::SnapshotNamespace
& snap_namespace
,
85 const std::string
& snap_name
);
86 void execute_snap_unprotect(const cls::rbd::SnapshotNamespace
& snap_namespace
,
87 const std::string
&snap_name
,
90 int snap_set_limit(uint64_t limit
);
91 void execute_snap_set_limit(uint64_t limit
, Context
*on_finish
);
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
);
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
,
101 int metadata_remove(const std::string
&key
);
102 void execute_metadata_remove(const std::string
&key
, Context
*on_finish
);
104 int migrate(ProgressContext
&prog_ctx
);
105 void execute_migrate(ProgressContext
&prog_ctx
, Context
*on_finish
);
107 int sparsify(size_t sparse_size
, ProgressContext
&prog_ctx
);
108 void execute_sparsify(size_t sparse_size
, ProgressContext
&prog_ctx
,
111 int prepare_image_update(exclusive_lock::OperationRequestType request_type
,
115 ImageCtxT
&m_image_ctx
;
116 std::atomic
<int> m_async_request_seq
;
118 int invoke_async_request(const std::string
& name
,
119 exclusive_lock::OperationRequestType request_type
,
120 bool permit_snapshot
,
121 const boost::function
<void(Context
*)>& local
,
122 const boost::function
<void(Context
*)>& remote
);
125 } // namespace librbd
127 extern template class librbd::Operations
<librbd::ImageCtx
>;
129 #endif // CEPH_LIBRBD_OPERATIONS_H