]>
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" | |
11fdf7f2 | 18 | #include "common/ceph_time.h" |
7c673cae FG |
19 | #include "librbd/Types.h" |
20 | ||
7c673cae FG |
21 | namespace librbd { |
22 | ||
23 | struct ImageCtx; | |
24 | namespace io { struct AioCompletion; } | |
25 | ||
26 | class NoOpProgressContext : public ProgressContext | |
27 | { | |
28 | public: | |
29 | NoOpProgressContext() | |
30 | { | |
31 | } | |
32 | int update_progress(uint64_t offset, uint64_t src_size) override | |
33 | { | |
34 | return 0; | |
35 | } | |
36 | }; | |
37 | ||
38 | int detect_format(librados::IoCtx &io_ctx, const std::string &name, | |
39 | bool *old_format, uint64_t *size); | |
40 | ||
41 | bool has_parent(int64_t parent_pool_id, uint64_t off, uint64_t overlap); | |
42 | ||
43 | std::string image_option_name(int optname); | |
44 | void image_options_create(rbd_image_options_t* opts); | |
45 | void image_options_create_ref(rbd_image_options_t* opts, | |
46 | rbd_image_options_t orig); | |
47 | void image_options_copy(rbd_image_options_t *opts, | |
48 | const ImageOptions &orig); | |
49 | void image_options_destroy(rbd_image_options_t opts); | |
50 | int image_options_set(rbd_image_options_t opts, int optname, | |
51 | const std::string& optval); | |
52 | int image_options_set(rbd_image_options_t opts, int optname, uint64_t optval); | |
53 | int image_options_get(rbd_image_options_t opts, int optname, | |
54 | std::string* optval); | |
55 | int image_options_get(rbd_image_options_t opts, int optname, | |
56 | uint64_t* optval); | |
57 | int image_options_is_set(rbd_image_options_t opts, int optname, | |
58 | bool* is_set); | |
59 | int image_options_unset(rbd_image_options_t opts, int optname); | |
60 | void image_options_clear(rbd_image_options_t opts); | |
61 | bool image_options_is_empty(rbd_image_options_t opts); | |
62 | ||
7c673cae FG |
63 | int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, |
64 | int *order); | |
65 | int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, | |
66 | bool old_format, uint64_t features, int *order, | |
67 | uint64_t stripe_unit, uint64_t stripe_count); | |
68 | int create(IoCtx& io_ctx, const std::string &image_name, | |
69 | const std::string &image_id, uint64_t size, ImageOptions& opts, | |
70 | const std::string &non_primary_global_image_id, | |
71 | const std::string &primary_mirror_uuid, | |
72 | bool skip_mirror_enable); | |
73 | int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name, | |
74 | IoCtx& c_ioctx, const char *c_name, | |
75 | uint64_t features, int *c_order, | |
76 | uint64_t stripe_unit, int stripe_count); | |
11fdf7f2 TL |
77 | int clone(IoCtx& p_ioctx, const char *p_id, const char *p_name, |
78 | const char *p_snap_name, IoCtx& c_ioctx, const char *c_id, | |
79 | const char *c_name, ImageOptions& c_opts, | |
7c673cae FG |
80 | const std::string &non_primary_global_image_id, |
81 | const std::string &primary_mirror_uuid); | |
82 | int rename(librados::IoCtx& io_ctx, const char *srcname, const char *dstname); | |
83 | int info(ImageCtx *ictx, image_info_t& info, size_t image_size); | |
84 | int get_old_format(ImageCtx *ictx, uint8_t *old); | |
85 | int get_size(ImageCtx *ictx, uint64_t *size); | |
86 | int get_features(ImageCtx *ictx, uint64_t *features); | |
87 | int get_overlap(ImageCtx *ictx, uint64_t *overlap); | |
7c673cae FG |
88 | int get_flags(ImageCtx *ictx, uint64_t *flags); |
89 | int set_image_notification(ImageCtx *ictx, int fd, int type); | |
90 | int is_exclusive_lock_owner(ImageCtx *ictx, bool *is_owner); | |
91 | int lock_acquire(ImageCtx *ictx, rbd_lock_mode_t lock_mode); | |
92 | int lock_release(ImageCtx *ictx); | |
93 | int lock_get_owners(ImageCtx *ictx, rbd_lock_mode_t *lock_mode, | |
94 | std::list<std::string> *lock_owners); | |
95 | int lock_break(ImageCtx *ictx, rbd_lock_mode_t lock_mode, | |
96 | const std::string &lock_owner); | |
97 | ||
7c673cae FG |
98 | int copy(ImageCtx *ictx, IoCtx& dest_md_ctx, const char *destname, |
99 | ImageOptions& opts, ProgressContext &prog_ctx, size_t sparse_size); | |
100 | int copy(ImageCtx *src, ImageCtx *dest, ProgressContext &prog_ctx, size_t sparse_size); | |
101 | ||
102 | /* cooperative locking */ | |
103 | int list_lockers(ImageCtx *ictx, | |
104 | std::list<locker_t> *locks, | |
105 | bool *exclusive, | |
106 | std::string *tag); | |
107 | int lock(ImageCtx *ictx, bool exclusive, const std::string& cookie, | |
108 | const std::string& tag); | |
109 | int lock_shared(ImageCtx *ictx, const std::string& cookie, | |
110 | const std::string& tag); | |
111 | int unlock(ImageCtx *ictx, const std::string& cookie); | |
112 | int break_lock(ImageCtx *ictx, const std::string& client, | |
113 | const std::string& cookie); | |
114 | ||
115 | void trim_image(ImageCtx *ictx, uint64_t newsize, ProgressContext& prog_ctx); | |
116 | ||
117 | int read_header_bl(librados::IoCtx& io_ctx, const std::string& md_oid, | |
118 | ceph::bufferlist& header, uint64_t *ver); | |
119 | int read_header(librados::IoCtx& io_ctx, const std::string& md_oid, | |
120 | struct rbd_obj_header_ondisk *header, uint64_t *ver); | |
121 | int tmap_set(librados::IoCtx& io_ctx, const std::string& imgname); | |
122 | int tmap_rm(librados::IoCtx& io_ctx, const std::string& imgname); | |
123 | void image_info(const ImageCtx *ictx, image_info_t& info, size_t info_size); | |
124 | uint64_t oid_to_object_no(const std::string& oid, | |
125 | const std::string& object_prefix); | |
126 | int clip_io(ImageCtx *ictx, uint64_t off, uint64_t *len); | |
127 | void init_rbd_header(struct rbd_obj_header_ondisk& ondisk, | |
128 | uint64_t size, int order, uint64_t bid); | |
129 | ||
130 | int64_t read_iterate(ImageCtx *ictx, uint64_t off, uint64_t len, | |
131 | int (*cb)(uint64_t, size_t, const char *, void *), | |
132 | void *arg); | |
7c673cae | 133 | |
7c673cae FG |
134 | int invalidate_cache(ImageCtx *ictx); |
135 | int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp); | |
136 | int metadata_list(ImageCtx *ictx, const string &last, uint64_t max, map<string, bufferlist> *pairs); | |
137 | int metadata_get(ImageCtx *ictx, const std::string &key, std::string *value); | |
138 | ||
11fdf7f2 | 139 | int list_watchers(ImageCtx *ictx, std::list<librbd::image_watcher_t> &watchers); |
7c673cae FG |
140 | } |
141 | ||
11fdf7f2 TL |
142 | std::ostream &operator<<(std::ostream &os, const librbd::ImageOptions &opts); |
143 | ||
7c673cae | 144 | #endif |