]>
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 | |
1e59de90 TL |
48 | #define CEPHFS_EFAULT 14 |
49 | #define CEPHFS_EISCONN 106 | |
50 | #define CEPHFS_EMULTIHOP 72 | |
f67539c2 | 51 | |
b3b6e05e TL |
52 | // taken from linux kernel: include/uapi/linux/fcntl.h |
53 | #define CEPHFS_AT_FDCWD -100 /* Special value used to indicate | |
54 | openat should use the current | |
55 | working directory. */ | |
7c673cae FG |
56 | |
57 | // -------------------------------------- | |
58 | // ino | |
59 | ||
60 | typedef uint64_t _inodeno_t; | |
61 | ||
62 | struct inodeno_t { | |
63 | _inodeno_t val; | |
64 | inodeno_t() : val(0) {} | |
65 | // cppcheck-suppress noExplicitConstructor | |
66 | inodeno_t(_inodeno_t v) : val(v) {} | |
67 | inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; } | |
68 | operator _inodeno_t() const { return val; } | |
69 | ||
9f95a23c | 70 | void encode(ceph::buffer::list& bl) const { |
11fdf7f2 TL |
71 | using ceph::encode; |
72 | encode(val, bl); | |
7c673cae | 73 | } |
9f95a23c | 74 | void decode(ceph::buffer::list::const_iterator& p) { |
11fdf7f2 TL |
75 | using ceph::decode; |
76 | decode(val, p); | |
7c673cae FG |
77 | } |
78 | } __attribute__ ((__may_alias__)); | |
79 | WRITE_CLASS_ENCODER(inodeno_t) | |
80 | ||
81 | template<> | |
82 | struct denc_traits<inodeno_t> { | |
83 | static constexpr bool supported = true; | |
84 | static constexpr bool featured = false; | |
85 | static constexpr bool bounded = true; | |
31f18b77 | 86 | static constexpr bool need_contiguous = true; |
7c673cae FG |
87 | static void bound_encode(const inodeno_t &o, size_t& p) { |
88 | denc(o.val, p); | |
89 | } | |
9f95a23c | 90 | static void encode(const inodeno_t &o, ceph::buffer::list::contiguous_appender& p) { |
7c673cae FG |
91 | denc(o.val, p); |
92 | } | |
9f95a23c | 93 | static void decode(inodeno_t& o, ceph::buffer::ptr::const_iterator &p) { |
7c673cae FG |
94 | denc(o.val, p); |
95 | } | |
96 | }; | |
97 | ||
9f95a23c TL |
98 | inline std::ostream& operator<<(std::ostream& out, const inodeno_t& ino) { |
99 | return out << std::hex << "0x" << ino.val << std::dec; | |
7c673cae FG |
100 | } |
101 | ||
102 | namespace std { | |
9f95a23c TL |
103 | template<> |
104 | struct hash<inodeno_t> { | |
105 | size_t operator()( const inodeno_t& x ) const { | |
106 | static rjhash<uint64_t> H; | |
107 | return H(x.val); | |
108 | } | |
109 | }; | |
7c673cae FG |
110 | } // namespace std |
111 | ||
112 | ||
113 | // file modes | |
114 | ||
11fdf7f2 | 115 | inline bool file_mode_is_readonly(int mode) { |
7c673cae FG |
116 | return (mode & CEPH_FILE_MODE_WR) == 0; |
117 | } | |
118 | ||
119 | ||
120 | // dentries | |
121 | #define MAX_DENTRY_LEN 255 | |
122 | ||
123 | // -- | |
124 | namespace ceph { | |
125 | class Formatter; | |
126 | } | |
127 | void dump(const ceph_file_layout& l, ceph::Formatter *f); | |
128 | void dump(const ceph_dir_layout& l, ceph::Formatter *f); | |
129 | ||
130 | ||
131 | ||
132 | // file_layout_t | |
133 | ||
134 | struct file_layout_t { | |
135 | // file -> object mapping | |
136 | uint32_t stripe_unit; ///< stripe unit, in bytes, | |
137 | uint32_t stripe_count; ///< over this many objects | |
138 | uint32_t object_size; ///< until objects are this big | |
139 | ||
140 | int64_t pool_id; ///< rados pool id | |
9f95a23c | 141 | std::string pool_ns; ///< rados pool namespace |
7c673cae FG |
142 | |
143 | file_layout_t(uint32_t su=0, uint32_t sc=0, uint32_t os=0) | |
144 | : stripe_unit(su), | |
145 | stripe_count(sc), | |
146 | object_size(os), | |
147 | pool_id(-1) { | |
148 | } | |
149 | ||
1e59de90 TL |
150 | bool operator==(const file_layout_t&) const = default; |
151 | ||
7c673cae FG |
152 | static file_layout_t get_default() { |
153 | return file_layout_t(1<<22, 1, 1<<22); | |
154 | } | |
155 | ||
156 | uint64_t get_period() const { | |
157 | return static_cast<uint64_t>(stripe_count) * object_size; | |
158 | } | |
159 | ||
160 | void from_legacy(const ceph_file_layout& fl); | |
161 | void to_legacy(ceph_file_layout *fl) const; | |
162 | ||
163 | bool is_valid() const; | |
164 | ||
9f95a23c TL |
165 | void encode(ceph::buffer::list& bl, uint64_t features) const; |
166 | void decode(ceph::buffer::list::const_iterator& p); | |
167 | void dump(ceph::Formatter *f) const; | |
f67539c2 | 168 | void decode_json(JSONObj *obj); |
9f95a23c | 169 | static void generate_test_instances(std::list<file_layout_t*>& o); |
7c673cae FG |
170 | }; |
171 | WRITE_CLASS_ENCODER_FEATURES(file_layout_t) | |
172 | ||
9f95a23c | 173 | std::ostream& operator<<(std::ostream& out, const file_layout_t &layout); |
7c673cae FG |
174 | |
175 | #endif |