]>
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_INCLUDE_FS_TYPES_H | |
4 | #define CEPH_INCLUDE_FS_TYPES_H | |
5 | ||
6 | #include "types.h" | |
f67539c2 TL |
7 | class JSONObj; |
8 | ||
9 | #define CEPHFS_EBLOCKLISTED 108 | |
10 | #define CEPHFS_EPERM 1 | |
11 | #define CEPHFS_ESTALE 116 | |
12 | #define CEPHFS_ENOSPC 28 | |
13 | #define CEPHFS_ETIMEDOUT 110 | |
14 | #define CEPHFS_EIO 5 | |
15 | #define CEPHFS_ENOTCONN 107 | |
16 | #define CEPHFS_EEXIST 17 | |
17 | #define CEPHFS_EINTR 4 | |
18 | #define CEPHFS_EINVAL 22 | |
19 | #define CEPHFS_EBADF 9 | |
20 | #define CEPHFS_EROFS 30 | |
21 | #define CEPHFS_EAGAIN 11 | |
22 | #define CEPHFS_EACCES 13 | |
23 | #define CEPHFS_ELOOP 40 | |
24 | #define CEPHFS_EISDIR 21 | |
25 | #define CEPHFS_ENOENT 2 | |
26 | #define CEPHFS_ENOTDIR 20 | |
27 | #define CEPHFS_ENAMETOOLONG 36 | |
28 | #define CEPHFS_EBUSY 16 | |
29 | #define CEPHFS_EDQUOT 122 | |
30 | #define CEPHFS_EFBIG 27 | |
31 | #define CEPHFS_ERANGE 34 | |
32 | #define CEPHFS_ENXIO 6 | |
33 | #define CEPHFS_ECANCELED 125 | |
34 | #define CEPHFS_ENODATA 61 | |
35 | #define CEPHFS_EOPNOTSUPP 95 | |
36 | #define CEPHFS_EXDEV 18 | |
37 | #define CEPHFS_ENOMEM 12 | |
38 | #define CEPHFS_ENOTRECOVERABLE 131 | |
39 | #define CEPHFS_ENOSYS 38 | |
40 | #define CEPHFS_EWOULDBLOCK CEPHFS_EAGAIN | |
41 | #define CEPHFS_ENOTEMPTY 39 | |
42 | #define CEPHFS_EDEADLK 35 | |
43 | #define CEPHFS_EDEADLOCK CEPHFS_EDEADLK | |
44 | #define CEPHFS_EDOM 33 | |
45 | #define CEPHFS_EMLINK 31 | |
46 | #define CEPHFS_ETIME 62 | |
47 | #define CEPHFS_EOLDSNAPC 85 | |
48 | ||
b3b6e05e TL |
49 | // taken from linux kernel: include/uapi/linux/fcntl.h |
50 | #define CEPHFS_AT_FDCWD -100 /* Special value used to indicate | |
51 | openat should use the current | |
52 | working directory. */ | |
7c673cae FG |
53 | |
54 | // -------------------------------------- | |
55 | // ino | |
56 | ||
57 | typedef uint64_t _inodeno_t; | |
58 | ||
59 | struct inodeno_t { | |
60 | _inodeno_t val; | |
61 | inodeno_t() : val(0) {} | |
62 | // cppcheck-suppress noExplicitConstructor | |
63 | inodeno_t(_inodeno_t v) : val(v) {} | |
64 | inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; } | |
65 | operator _inodeno_t() const { return val; } | |
66 | ||
9f95a23c | 67 | void encode(ceph::buffer::list& bl) const { |
11fdf7f2 TL |
68 | using ceph::encode; |
69 | encode(val, bl); | |
7c673cae | 70 | } |
9f95a23c | 71 | void decode(ceph::buffer::list::const_iterator& p) { |
11fdf7f2 TL |
72 | using ceph::decode; |
73 | decode(val, p); | |
7c673cae FG |
74 | } |
75 | } __attribute__ ((__may_alias__)); | |
76 | WRITE_CLASS_ENCODER(inodeno_t) | |
77 | ||
78 | template<> | |
79 | struct denc_traits<inodeno_t> { | |
80 | static constexpr bool supported = true; | |
81 | static constexpr bool featured = false; | |
82 | static constexpr bool bounded = true; | |
31f18b77 | 83 | static constexpr bool need_contiguous = true; |
7c673cae FG |
84 | static void bound_encode(const inodeno_t &o, size_t& p) { |
85 | denc(o.val, p); | |
86 | } | |
9f95a23c | 87 | static void encode(const inodeno_t &o, ceph::buffer::list::contiguous_appender& p) { |
7c673cae FG |
88 | denc(o.val, p); |
89 | } | |
9f95a23c | 90 | static void decode(inodeno_t& o, ceph::buffer::ptr::const_iterator &p) { |
7c673cae FG |
91 | denc(o.val, p); |
92 | } | |
93 | }; | |
94 | ||
9f95a23c TL |
95 | inline std::ostream& operator<<(std::ostream& out, const inodeno_t& ino) { |
96 | return out << std::hex << "0x" << ino.val << std::dec; | |
7c673cae FG |
97 | } |
98 | ||
99 | namespace std { | |
9f95a23c TL |
100 | template<> |
101 | struct hash<inodeno_t> { | |
102 | size_t operator()( const inodeno_t& x ) const { | |
103 | static rjhash<uint64_t> H; | |
104 | return H(x.val); | |
105 | } | |
106 | }; | |
7c673cae FG |
107 | } // namespace std |
108 | ||
109 | ||
110 | // file modes | |
111 | ||
11fdf7f2 | 112 | inline bool file_mode_is_readonly(int mode) { |
7c673cae FG |
113 | return (mode & CEPH_FILE_MODE_WR) == 0; |
114 | } | |
115 | ||
116 | ||
117 | // dentries | |
118 | #define MAX_DENTRY_LEN 255 | |
119 | ||
120 | // -- | |
121 | namespace ceph { | |
122 | class Formatter; | |
123 | } | |
124 | void dump(const ceph_file_layout& l, ceph::Formatter *f); | |
125 | void dump(const ceph_dir_layout& l, ceph::Formatter *f); | |
126 | ||
127 | ||
128 | ||
129 | // file_layout_t | |
130 | ||
131 | struct file_layout_t { | |
132 | // file -> object mapping | |
133 | uint32_t stripe_unit; ///< stripe unit, in bytes, | |
134 | uint32_t stripe_count; ///< over this many objects | |
135 | uint32_t object_size; ///< until objects are this big | |
136 | ||
137 | int64_t pool_id; ///< rados pool id | |
9f95a23c | 138 | std::string pool_ns; ///< rados pool namespace |
7c673cae FG |
139 | |
140 | file_layout_t(uint32_t su=0, uint32_t sc=0, uint32_t os=0) | |
141 | : stripe_unit(su), | |
142 | stripe_count(sc), | |
143 | object_size(os), | |
144 | pool_id(-1) { | |
145 | } | |
146 | ||
147 | static file_layout_t get_default() { | |
148 | return file_layout_t(1<<22, 1, 1<<22); | |
149 | } | |
150 | ||
151 | uint64_t get_period() const { | |
152 | return static_cast<uint64_t>(stripe_count) * object_size; | |
153 | } | |
154 | ||
155 | void from_legacy(const ceph_file_layout& fl); | |
156 | void to_legacy(ceph_file_layout *fl) const; | |
157 | ||
158 | bool is_valid() const; | |
159 | ||
9f95a23c TL |
160 | void encode(ceph::buffer::list& bl, uint64_t features) const; |
161 | void decode(ceph::buffer::list::const_iterator& p); | |
162 | void dump(ceph::Formatter *f) const; | |
f67539c2 | 163 | void decode_json(JSONObj *obj); |
9f95a23c | 164 | static void generate_test_instances(std::list<file_layout_t*>& o); |
7c673cae FG |
165 | }; |
166 | WRITE_CLASS_ENCODER_FEATURES(file_layout_t) | |
167 | ||
168 | WRITE_EQ_OPERATORS_5(file_layout_t, stripe_unit, stripe_count, object_size, pool_id, pool_ns); | |
169 | ||
9f95a23c | 170 | std::ostream& operator<<(std::ostream& out, const file_layout_t &layout); |
7c673cae FG |
171 | |
172 | #endif |