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