]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/Types.h
import ceph quincy 17.2.1
[ceph.git] / ceph / src / librbd / Types.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_TYPES_H
5 #define LIBRBD_TYPES_H
6
7 #include "include/types.h"
8 #include "cls/rbd/cls_rbd_types.h"
9 #include "deep_copy/Types.h"
10 #include <map>
11 #include <memory>
12 #include <string>
13
14 namespace neorados { class IOContext; }
15
16 namespace librbd {
17
18 // Performance counters
19 enum {
20 l_librbd_first = 26000,
21
22 l_librbd_rd, // read ops
23 l_librbd_rd_bytes, // bytes read
24 l_librbd_rd_latency, // average latency
25 l_librbd_wr,
26 l_librbd_wr_bytes,
27 l_librbd_wr_latency,
28 l_librbd_discard,
29 l_librbd_discard_bytes,
30 l_librbd_discard_latency,
31 l_librbd_flush,
32 l_librbd_flush_latency,
33
34 l_librbd_ws,
35 l_librbd_ws_bytes,
36 l_librbd_ws_latency,
37
38 l_librbd_cmp,
39 l_librbd_cmp_bytes,
40 l_librbd_cmp_latency,
41
42 l_librbd_snap_create,
43 l_librbd_snap_remove,
44 l_librbd_snap_rollback,
45 l_librbd_snap_rename,
46
47 l_librbd_notify,
48 l_librbd_resize,
49
50 l_librbd_readahead,
51 l_librbd_readahead_bytes,
52
53 l_librbd_invalidate_cache,
54
55 l_librbd_opened_time,
56 l_librbd_lock_acquired_time,
57
58 l_librbd_last,
59 };
60
61 typedef std::shared_ptr<neorados::IOContext> IOContext;
62
63 typedef std::map<uint64_t, uint64_t> SnapSeqs;
64
65 /// Full information about an image's parent.
66 struct ParentImageInfo {
67 /// Identification of the parent.
68 cls::rbd::ParentImageSpec spec;
69
70 /** @brief Where the portion of data shared with the child image ends.
71 * Since images can be resized multiple times, the portion of data shared
72 * with the child image is not necessarily min(parent size, child size).
73 * If the child image is first shrunk and then enlarged, the common portion
74 * will be shorter. */
75 uint64_t overlap = 0;
76 };
77
78 struct SnapInfo {
79 std::string name;
80 cls::rbd::SnapshotNamespace snap_namespace;
81 uint64_t size;
82 ParentImageInfo parent;
83 uint8_t protection_status;
84 uint64_t flags;
85 utime_t timestamp;
86 SnapInfo(std::string _name,
87 const cls::rbd::SnapshotNamespace &_snap_namespace,
88 uint64_t _size, const ParentImageInfo &_parent,
89 uint8_t _protection_status, uint64_t _flags, utime_t _timestamp)
90 : name(_name), snap_namespace(_snap_namespace), size(_size),
91 parent(_parent), protection_status(_protection_status), flags(_flags),
92 timestamp(_timestamp) {
93 }
94 };
95
96 enum {
97 OPEN_FLAG_SKIP_OPEN_PARENT = 1 << 0,
98 OPEN_FLAG_OLD_FORMAT = 1 << 1,
99 OPEN_FLAG_IGNORE_MIGRATING = 1 << 2
100 };
101
102 enum ImageReadOnlyFlag {
103 IMAGE_READ_ONLY_FLAG_USER = 1 << 0,
104 IMAGE_READ_ONLY_FLAG_NON_PRIMARY = 1 << 1,
105 };
106
107 enum SnapCreateFlag {
108 SNAP_CREATE_FLAG_SKIP_OBJECT_MAP = 1 << 0,
109 SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE = 1 << 1,
110 SNAP_CREATE_FLAG_IGNORE_NOTIFY_QUIESCE_ERROR = 1 << 2,
111 };
112
113 struct MigrationInfo {
114 int64_t pool_id = -1;
115 std::string pool_namespace;
116 std::string image_name;
117 std::string image_id;
118 std::string source_spec;
119 deep_copy::SnapMap snap_map;
120 uint64_t overlap = 0;
121 bool flatten = false;
122
123 MigrationInfo() {
124 }
125 MigrationInfo(int64_t pool_id, const std::string& pool_namespace,
126 const std::string& image_name, const std::string& image_id,
127 const std::string& source_spec,
128 const deep_copy::SnapMap &snap_map, uint64_t overlap,
129 bool flatten)
130 : pool_id(pool_id), pool_namespace(pool_namespace), image_name(image_name),
131 image_id(image_id), source_spec(source_spec), snap_map(snap_map),
132 overlap(overlap), flatten(flatten) {
133 }
134
135 bool empty() const {
136 return (pool_id == -1 && source_spec.empty());
137 }
138 };
139
140 } // namespace librbd
141
142 #endif // LIBRBD_TYPES_H