]>
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 | #ifndef CEPH_LIBRBD_INTERNAL_H | |
4 | #define CEPH_LIBRBD_INTERNAL_H | |
5 | ||
6 | #include "include/int_types.h" | |
7 | ||
8 | #include <map> | |
9 | #include <set> | |
10 | #include <string> | |
11 | #include <vector> | |
12 | ||
13 | #include "include/buffer_fwd.h" | |
14 | #include "include/rbd/librbd.hpp" | |
15 | #include "include/rbd_types.h" | |
16 | #include "cls/rbd/cls_rbd_types.h" | |
17 | #include "common/WorkQueue.h" | |
18 | #include "librbd/Types.h" | |
19 | ||
20 | enum { | |
21 | l_librbd_first = 26000, | |
22 | ||
23 | l_librbd_rd, // read ops | |
24 | l_librbd_rd_bytes, // bytes read | |
25 | l_librbd_rd_latency, // average latency | |
26 | l_librbd_wr, | |
27 | l_librbd_wr_bytes, | |
28 | l_librbd_wr_latency, | |
29 | l_librbd_discard, | |
30 | l_librbd_discard_bytes, | |
31 | l_librbd_discard_latency, | |
32 | l_librbd_flush, | |
33 | ||
34 | l_librbd_aio_flush, | |
35 | l_librbd_aio_flush_latency, | |
36 | l_librbd_ws, | |
37 | l_librbd_ws_bytes, | |
38 | l_librbd_ws_latency, | |
39 | ||
c07f9fc5 FG |
40 | l_librbd_cmp, |
41 | l_librbd_cmp_bytes, | |
42 | l_librbd_cmp_latency, | |
43 | ||
7c673cae FG |
44 | l_librbd_snap_create, |
45 | l_librbd_snap_remove, | |
46 | l_librbd_snap_rollback, | |
47 | l_librbd_snap_rename, | |
48 | ||
49 | l_librbd_notify, | |
50 | l_librbd_resize, | |
51 | ||
52 | l_librbd_readahead, | |
53 | l_librbd_readahead_bytes, | |
54 | ||
55 | l_librbd_invalidate_cache, | |
56 | ||
57 | l_librbd_last, | |
58 | }; | |
59 | ||
60 | namespace librbd { | |
61 | ||
62 | struct ImageCtx; | |
63 | namespace io { struct AioCompletion; } | |
64 | ||
65 | class NoOpProgressContext : public ProgressContext | |
66 | { | |
67 | public: | |
68 | NoOpProgressContext() | |
69 | { | |
70 | } | |
71 | int update_progress(uint64_t offset, uint64_t src_size) override | |
72 | { | |
73 | return 0; | |
74 | } | |
75 | }; | |
76 | ||
77 | int detect_format(librados::IoCtx &io_ctx, const std::string &name, | |
78 | bool *old_format, uint64_t *size); | |
79 | ||
80 | bool has_parent(int64_t parent_pool_id, uint64_t off, uint64_t overlap); | |
81 | ||
82 | std::string image_option_name(int optname); | |
83 | void image_options_create(rbd_image_options_t* opts); | |
84 | void image_options_create_ref(rbd_image_options_t* opts, | |
85 | rbd_image_options_t orig); | |
86 | void image_options_copy(rbd_image_options_t *opts, | |
87 | const ImageOptions &orig); | |
88 | void image_options_destroy(rbd_image_options_t opts); | |
89 | int image_options_set(rbd_image_options_t opts, int optname, | |
90 | const std::string& optval); | |
91 | int image_options_set(rbd_image_options_t opts, int optname, uint64_t optval); | |
92 | int image_options_get(rbd_image_options_t opts, int optname, | |
93 | std::string* optval); | |
94 | int image_options_get(rbd_image_options_t opts, int optname, | |
95 | uint64_t* optval); | |
96 | int image_options_is_set(rbd_image_options_t opts, int optname, | |
97 | bool* is_set); | |
98 | int image_options_unset(rbd_image_options_t opts, int optname); | |
99 | void image_options_clear(rbd_image_options_t opts); | |
100 | bool image_options_is_empty(rbd_image_options_t opts); | |
101 | ||
102 | int snap_set(ImageCtx *ictx, const cls::rbd::SnapshotNamespace &snap_namespace, | |
103 | const char *snap_name); | |
104 | ||
105 | int list(librados::IoCtx& io_ctx, std::vector<std::string>& names); | |
106 | int list_children(ImageCtx *ictx, | |
107 | std::set<std::pair<std::string, std::string> > & names); | |
108 | int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, | |
109 | int *order); | |
110 | int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, | |
111 | bool old_format, uint64_t features, int *order, | |
112 | uint64_t stripe_unit, uint64_t stripe_count); | |
113 | int create(IoCtx& io_ctx, const std::string &image_name, | |
114 | const std::string &image_id, uint64_t size, ImageOptions& opts, | |
115 | const std::string &non_primary_global_image_id, | |
116 | const std::string &primary_mirror_uuid, | |
117 | bool skip_mirror_enable); | |
118 | int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name, | |
119 | IoCtx& c_ioctx, const char *c_name, | |
120 | uint64_t features, int *c_order, | |
121 | uint64_t stripe_unit, int stripe_count); | |
122 | int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name, | |
123 | IoCtx& c_ioctx, const char *c_name, ImageOptions& c_opts); | |
124 | int clone(ImageCtx *p_imctx, IoCtx& c_ioctx, const std::string &c_name, | |
125 | const std::string &c_id, ImageOptions& c_opts, | |
126 | const std::string &non_primary_global_image_id, | |
127 | const std::string &primary_mirror_uuid); | |
128 | int rename(librados::IoCtx& io_ctx, const char *srcname, const char *dstname); | |
129 | int info(ImageCtx *ictx, image_info_t& info, size_t image_size); | |
130 | int get_old_format(ImageCtx *ictx, uint8_t *old); | |
131 | int get_size(ImageCtx *ictx, uint64_t *size); | |
132 | int get_features(ImageCtx *ictx, uint64_t *features); | |
133 | int get_overlap(ImageCtx *ictx, uint64_t *overlap); | |
134 | int get_parent_info(ImageCtx *ictx, std::string *parent_pool_name, | |
135 | std::string *parent_name, std::string *parent_id, | |
136 | std::string *parent_snap_name); | |
137 | int get_flags(ImageCtx *ictx, uint64_t *flags); | |
138 | int set_image_notification(ImageCtx *ictx, int fd, int type); | |
139 | int is_exclusive_lock_owner(ImageCtx *ictx, bool *is_owner); | |
140 | int lock_acquire(ImageCtx *ictx, rbd_lock_mode_t lock_mode); | |
141 | int lock_release(ImageCtx *ictx); | |
142 | int lock_get_owners(ImageCtx *ictx, rbd_lock_mode_t *lock_mode, | |
143 | std::list<std::string> *lock_owners); | |
144 | int lock_break(ImageCtx *ictx, rbd_lock_mode_t lock_mode, | |
145 | const std::string &lock_owner); | |
146 | ||
147 | int remove(librados::IoCtx& io_ctx, const std::string &image_name, | |
148 | const std::string &image_id, ProgressContext& prog_ctx, | |
149 | bool force=false, bool from_trash_remove=false); | |
150 | ||
151 | int trash_move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, | |
152 | const std::string &image_name, uint64_t delay); | |
153 | int trash_get(IoCtx &io_ctx, const std::string &id, trash_image_info_t *info); | |
154 | int trash_list(librados::IoCtx &io_ctx, | |
155 | std::vector<trash_image_info_t> &entries); | |
156 | int trash_remove(librados::IoCtx &io_ctx, const std::string &image_id, | |
157 | bool force, ProgressContext& prog_ctx); | |
158 | int trash_restore(librados::IoCtx &io_ctx, const std::string &image_id, | |
159 | const std::string &image_new_name); | |
160 | ||
161 | int snap_list(ImageCtx *ictx, std::vector<snap_info_t>& snaps); | |
162 | int snap_exists(ImageCtx *ictx, const cls::rbd::SnapshotNamespace& snap_namespace, | |
163 | const char *snap_name, bool *exists); | |
164 | int snap_get_limit(ImageCtx *ictx, uint64_t *limit); | |
165 | int snap_set_limit(ImageCtx *ictx, uint64_t limit); | |
166 | int snap_get_timestamp(ImageCtx *ictx, uint64_t snap_id, struct timespec *timestamp); | |
167 | int snap_remove(ImageCtx *ictx, const char *snap_name, uint32_t flags, ProgressContext& pctx); | |
168 | int snap_is_protected(ImageCtx *ictx, const char *snap_name, | |
169 | bool *is_protected); | |
170 | int copy(ImageCtx *ictx, IoCtx& dest_md_ctx, const char *destname, | |
171 | ImageOptions& opts, ProgressContext &prog_ctx, size_t sparse_size); | |
172 | int copy(ImageCtx *src, ImageCtx *dest, ProgressContext &prog_ctx, size_t sparse_size); | |
173 | ||
174 | /* cooperative locking */ | |
175 | int list_lockers(ImageCtx *ictx, | |
176 | std::list<locker_t> *locks, | |
177 | bool *exclusive, | |
178 | std::string *tag); | |
179 | int lock(ImageCtx *ictx, bool exclusive, const std::string& cookie, | |
180 | const std::string& tag); | |
181 | int lock_shared(ImageCtx *ictx, const std::string& cookie, | |
182 | const std::string& tag); | |
183 | int unlock(ImageCtx *ictx, const std::string& cookie); | |
184 | int break_lock(ImageCtx *ictx, const std::string& client, | |
185 | const std::string& cookie); | |
186 | ||
187 | void trim_image(ImageCtx *ictx, uint64_t newsize, ProgressContext& prog_ctx); | |
188 | ||
189 | int read_header_bl(librados::IoCtx& io_ctx, const std::string& md_oid, | |
190 | ceph::bufferlist& header, uint64_t *ver); | |
191 | int read_header(librados::IoCtx& io_ctx, const std::string& md_oid, | |
192 | struct rbd_obj_header_ondisk *header, uint64_t *ver); | |
193 | int tmap_set(librados::IoCtx& io_ctx, const std::string& imgname); | |
194 | int tmap_rm(librados::IoCtx& io_ctx, const std::string& imgname); | |
195 | void image_info(const ImageCtx *ictx, image_info_t& info, size_t info_size); | |
196 | uint64_t oid_to_object_no(const std::string& oid, | |
197 | const std::string& object_prefix); | |
198 | int clip_io(ImageCtx *ictx, uint64_t off, uint64_t *len); | |
199 | void init_rbd_header(struct rbd_obj_header_ondisk& ondisk, | |
200 | uint64_t size, int order, uint64_t bid); | |
201 | ||
202 | int64_t read_iterate(ImageCtx *ictx, uint64_t off, uint64_t len, | |
203 | int (*cb)(uint64_t, size_t, const char *, void *), | |
204 | void *arg); | |
205 | void readahead(ImageCtx *ictx, | |
206 | const vector<pair<uint64_t,uint64_t> >& image_extents); | |
207 | ||
208 | int flush(ImageCtx *ictx); | |
209 | int invalidate_cache(ImageCtx *ictx); | |
210 | int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp); | |
211 | int metadata_list(ImageCtx *ictx, const string &last, uint64_t max, map<string, bufferlist> *pairs); | |
212 | int metadata_get(ImageCtx *ictx, const std::string &key, std::string *value); | |
213 | ||
214 | } | |
215 | ||
216 | #endif |