]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/api/Image.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / librbd / api / Image.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef LIBRBD_API_IMAGE_H
5 #define LIBRBD_API_IMAGE_H
6
7 #include "include/rbd/librbd.hpp"
8 #include "include/rados/librados_fwd.hpp"
9 #include "librbd/Types.h"
10 #include <map>
11 #include <set>
12 #include <string>
13
14 namespace librbd {
15
16 class ImageOptions;
17 class ProgressContext;
18
19 struct ImageCtx;
20
21 namespace api {
22
23 template <typename ImageCtxT = librbd::ImageCtx>
24 struct Image {
25 typedef std::map<std::string, std::string> ImageNameToIds;
26
27 static int64_t get_data_pool_id(ImageCtxT *ictx);
28
29 static int get_op_features(ImageCtxT *ictx, uint64_t *op_features);
30
31 static int list_images(librados::IoCtx& io_ctx,
32 std::vector<image_spec_t> *images);
33 static int list_images_v2(librados::IoCtx& io_ctx,
34 ImageNameToIds *images);
35
36 static int get_parent(ImageCtxT *ictx,
37 librbd::linked_image_spec_t *parent_image,
38 librbd::snap_spec_t *parent_snap);
39
40 static int list_children(ImageCtxT *ictx,
41 std::vector<librbd::linked_image_spec_t> *images);
42 static int list_children(ImageCtxT *ictx,
43 const cls::rbd::ParentImageSpec &parent_spec,
44 std::vector<librbd::linked_image_spec_t> *images);
45
46 static int list_descendants(IoCtx& io_ctx, const std::string &image_id,
47 const std::optional<size_t> &max_level,
48 std::vector<librbd::linked_image_spec_t> *images);
49 static int list_descendants(ImageCtxT *ictx,
50 const std::optional<size_t> &max_level,
51 std::vector<librbd::linked_image_spec_t> *images);
52 static int list_descendants(ImageCtxT *ictx,
53 const cls::rbd::ParentImageSpec &parent_spec,
54 const std::optional<size_t> &max_level,
55 std::vector<librbd::linked_image_spec_t> *images);
56
57 static int deep_copy(ImageCtxT *ictx, librados::IoCtx& dest_md_ctx,
58 const char *destname, ImageOptions& opts,
59 ProgressContext &prog_ctx);
60 static int deep_copy(ImageCtxT *src, ImageCtxT *dest, bool flatten,
61 ProgressContext &prog_ctx);
62
63 static int snap_set(ImageCtxT *ictx,
64 const cls::rbd::SnapshotNamespace &snap_namespace,
65 const char *snap_name);
66 static int snap_set(ImageCtxT *ictx, uint64_t snap_id);
67
68 static int remove(librados::IoCtx& io_ctx, const std::string &image_name,
69 ProgressContext& prog_ctx);
70
71 static int flatten_children(ImageCtxT *ictx, const char* snap_name, ProgressContext& pctx);
72
73 static int encryption_format(ImageCtxT *ictx, encryption_format_t format,
74 encryption_options_t opts, size_t opts_size,
75 bool c_api);
76 static int encryption_load(ImageCtxT *ictx, const encryption_spec_t *specs,
77 size_t spec_count, bool c_api);
78 };
79
80 } // namespace api
81 } // namespace librbd
82
83 extern template class librbd::api::Image<librbd::ImageCtx>;
84
85 #endif // LIBRBD_API_IMAGE_H