]>
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 | ||
7c673cae FG |
20 | namespace librbd { |
21 | ||
22 | struct ImageCtx; | |
23 | namespace io { struct AioCompletion; } | |
24 | ||
25 | class NoOpProgressContext : public ProgressContext | |
26 | { | |
27 | public: | |
28 | NoOpProgressContext() | |
29 | { | |
30 | } | |
31 | int update_progress(uint64_t offset, uint64_t src_size) override | |
32 | { | |
33 | return 0; | |
34 | } | |
35 | }; | |
36 | ||
37 | int detect_format(librados::IoCtx &io_ctx, const std::string &name, | |
38 | bool *old_format, uint64_t *size); | |
39 | ||
40 | bool has_parent(int64_t parent_pool_id, uint64_t off, uint64_t overlap); | |
41 | ||
42 | std::string image_option_name(int optname); | |
43 | void image_options_create(rbd_image_options_t* opts); | |
44 | void image_options_create_ref(rbd_image_options_t* opts, | |
45 | rbd_image_options_t orig); | |
46 | void image_options_copy(rbd_image_options_t *opts, | |
47 | const ImageOptions &orig); | |
48 | void image_options_destroy(rbd_image_options_t opts); | |
49 | int image_options_set(rbd_image_options_t opts, int optname, | |
50 | const std::string& optval); | |
51 | int image_options_set(rbd_image_options_t opts, int optname, uint64_t optval); | |
52 | int image_options_get(rbd_image_options_t opts, int optname, | |
53 | std::string* optval); | |
54 | int image_options_get(rbd_image_options_t opts, int optname, | |
55 | uint64_t* optval); | |
56 | int image_options_is_set(rbd_image_options_t opts, int optname, | |
57 | bool* is_set); | |
58 | int image_options_unset(rbd_image_options_t opts, int optname); | |
59 | void image_options_clear(rbd_image_options_t opts); | |
60 | bool image_options_is_empty(rbd_image_options_t opts); | |
61 | ||
62 | int snap_set(ImageCtx *ictx, const cls::rbd::SnapshotNamespace &snap_namespace, | |
63 | const char *snap_name); | |
64 | ||
65 | int list(librados::IoCtx& io_ctx, std::vector<std::string>& names); | |
66 | int list_children(ImageCtx *ictx, | |
67 | std::set<std::pair<std::string, std::string> > & names); | |
68 | int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, | |
69 | int *order); | |
70 | int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, | |
71 | bool old_format, uint64_t features, int *order, | |
72 | uint64_t stripe_unit, uint64_t stripe_count); | |
73 | int create(IoCtx& io_ctx, const std::string &image_name, | |
74 | const std::string &image_id, uint64_t size, ImageOptions& opts, | |
75 | const std::string &non_primary_global_image_id, | |
76 | const std::string &primary_mirror_uuid, | |
77 | bool skip_mirror_enable); | |
78 | int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name, | |
79 | IoCtx& c_ioctx, const char *c_name, | |
80 | uint64_t features, int *c_order, | |
81 | uint64_t stripe_unit, int stripe_count); | |
82 | int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name, | |
83 | IoCtx& c_ioctx, const char *c_name, ImageOptions& c_opts); | |
84 | int clone(ImageCtx *p_imctx, IoCtx& c_ioctx, const std::string &c_name, | |
85 | const std::string &c_id, ImageOptions& c_opts, | |
86 | const std::string &non_primary_global_image_id, | |
87 | const std::string &primary_mirror_uuid); | |
88 | int rename(librados::IoCtx& io_ctx, const char *srcname, const char *dstname); | |
89 | int info(ImageCtx *ictx, image_info_t& info, size_t image_size); | |
90 | int get_old_format(ImageCtx *ictx, uint8_t *old); | |
91 | int get_size(ImageCtx *ictx, uint64_t *size); | |
92 | int get_features(ImageCtx *ictx, uint64_t *features); | |
93 | int get_overlap(ImageCtx *ictx, uint64_t *overlap); | |
94 | int get_parent_info(ImageCtx *ictx, std::string *parent_pool_name, | |
95 | std::string *parent_name, std::string *parent_id, | |
96 | std::string *parent_snap_name); | |
97 | int get_flags(ImageCtx *ictx, uint64_t *flags); | |
98 | int set_image_notification(ImageCtx *ictx, int fd, int type); | |
99 | int is_exclusive_lock_owner(ImageCtx *ictx, bool *is_owner); | |
100 | int lock_acquire(ImageCtx *ictx, rbd_lock_mode_t lock_mode); | |
101 | int lock_release(ImageCtx *ictx); | |
102 | int lock_get_owners(ImageCtx *ictx, rbd_lock_mode_t *lock_mode, | |
103 | std::list<std::string> *lock_owners); | |
104 | int lock_break(ImageCtx *ictx, rbd_lock_mode_t lock_mode, | |
105 | const std::string &lock_owner); | |
106 | ||
107 | int remove(librados::IoCtx& io_ctx, const std::string &image_name, | |
108 | const std::string &image_id, ProgressContext& prog_ctx, | |
109 | bool force=false, bool from_trash_remove=false); | |
110 | ||
111 | int trash_move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, | |
112 | const std::string &image_name, uint64_t delay); | |
113 | int trash_get(IoCtx &io_ctx, const std::string &id, trash_image_info_t *info); | |
114 | int trash_list(librados::IoCtx &io_ctx, | |
115 | std::vector<trash_image_info_t> &entries); | |
116 | int trash_remove(librados::IoCtx &io_ctx, const std::string &image_id, | |
117 | bool force, ProgressContext& prog_ctx); | |
118 | int trash_restore(librados::IoCtx &io_ctx, const std::string &image_id, | |
119 | const std::string &image_new_name); | |
120 | ||
121 | int snap_list(ImageCtx *ictx, std::vector<snap_info_t>& snaps); | |
122 | int snap_exists(ImageCtx *ictx, const cls::rbd::SnapshotNamespace& snap_namespace, | |
123 | const char *snap_name, bool *exists); | |
124 | int snap_get_limit(ImageCtx *ictx, uint64_t *limit); | |
125 | int snap_set_limit(ImageCtx *ictx, uint64_t limit); | |
126 | int snap_get_timestamp(ImageCtx *ictx, uint64_t snap_id, struct timespec *timestamp); | |
127 | int snap_remove(ImageCtx *ictx, const char *snap_name, uint32_t flags, ProgressContext& pctx); | |
128 | int snap_is_protected(ImageCtx *ictx, const char *snap_name, | |
129 | bool *is_protected); | |
130 | int copy(ImageCtx *ictx, IoCtx& dest_md_ctx, const char *destname, | |
131 | ImageOptions& opts, ProgressContext &prog_ctx, size_t sparse_size); | |
132 | int copy(ImageCtx *src, ImageCtx *dest, ProgressContext &prog_ctx, size_t sparse_size); | |
133 | ||
134 | /* cooperative locking */ | |
135 | int list_lockers(ImageCtx *ictx, | |
136 | std::list<locker_t> *locks, | |
137 | bool *exclusive, | |
138 | std::string *tag); | |
139 | int lock(ImageCtx *ictx, bool exclusive, const std::string& cookie, | |
140 | const std::string& tag); | |
141 | int lock_shared(ImageCtx *ictx, const std::string& cookie, | |
142 | const std::string& tag); | |
143 | int unlock(ImageCtx *ictx, const std::string& cookie); | |
144 | int break_lock(ImageCtx *ictx, const std::string& client, | |
145 | const std::string& cookie); | |
146 | ||
147 | void trim_image(ImageCtx *ictx, uint64_t newsize, ProgressContext& prog_ctx); | |
148 | ||
149 | int read_header_bl(librados::IoCtx& io_ctx, const std::string& md_oid, | |
150 | ceph::bufferlist& header, uint64_t *ver); | |
151 | int read_header(librados::IoCtx& io_ctx, const std::string& md_oid, | |
152 | struct rbd_obj_header_ondisk *header, uint64_t *ver); | |
153 | int tmap_set(librados::IoCtx& io_ctx, const std::string& imgname); | |
154 | int tmap_rm(librados::IoCtx& io_ctx, const std::string& imgname); | |
155 | void image_info(const ImageCtx *ictx, image_info_t& info, size_t info_size); | |
156 | uint64_t oid_to_object_no(const std::string& oid, | |
157 | const std::string& object_prefix); | |
158 | int clip_io(ImageCtx *ictx, uint64_t off, uint64_t *len); | |
159 | void init_rbd_header(struct rbd_obj_header_ondisk& ondisk, | |
160 | uint64_t size, int order, uint64_t bid); | |
161 | ||
162 | int64_t read_iterate(ImageCtx *ictx, uint64_t off, uint64_t len, | |
163 | int (*cb)(uint64_t, size_t, const char *, void *), | |
164 | void *arg); | |
165 | void readahead(ImageCtx *ictx, | |
166 | const vector<pair<uint64_t,uint64_t> >& image_extents); | |
167 | ||
168 | int flush(ImageCtx *ictx); | |
169 | int invalidate_cache(ImageCtx *ictx); | |
170 | int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp); | |
171 | int metadata_list(ImageCtx *ictx, const string &last, uint64_t max, map<string, bufferlist> *pairs); | |
172 | int metadata_get(ImageCtx *ictx, const std::string &key, std::string *value); | |
173 | ||
174 | } | |
175 | ||
176 | #endif |