]>
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" | |
7 | #include "utime.h" | |
8 | ||
9 | // -------------------------------------- | |
10 | // ino | |
11 | ||
12 | typedef uint64_t _inodeno_t; | |
13 | ||
14 | struct inodeno_t { | |
15 | _inodeno_t val; | |
16 | inodeno_t() : val(0) {} | |
17 | // cppcheck-suppress noExplicitConstructor | |
18 | inodeno_t(_inodeno_t v) : val(v) {} | |
19 | inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; } | |
20 | operator _inodeno_t() const { return val; } | |
21 | ||
22 | void encode(bufferlist& bl) const { | |
23 | ::encode(val, bl); | |
24 | } | |
25 | void decode(bufferlist::iterator& p) { | |
26 | ::decode(val, p); | |
27 | } | |
28 | } __attribute__ ((__may_alias__)); | |
29 | WRITE_CLASS_ENCODER(inodeno_t) | |
30 | ||
31 | template<> | |
32 | struct denc_traits<inodeno_t> { | |
33 | static constexpr bool supported = true; | |
34 | static constexpr bool featured = false; | |
35 | static constexpr bool bounded = true; | |
36 | static void bound_encode(const inodeno_t &o, size_t& p) { | |
37 | denc(o.val, p); | |
38 | } | |
39 | static void encode(const inodeno_t &o, buffer::list::contiguous_appender& p) { | |
40 | denc(o.val, p); | |
41 | } | |
42 | static void decode(inodeno_t& o, buffer::ptr::iterator &p) { | |
43 | denc(o.val, p); | |
44 | } | |
45 | }; | |
46 | ||
47 | inline ostream& operator<<(ostream& out, inodeno_t ino) { | |
48 | return out << hex << ino.val << dec; | |
49 | } | |
50 | ||
51 | namespace std { | |
52 | template<> struct hash< inodeno_t > | |
53 | { | |
54 | size_t operator()( const inodeno_t& x ) const | |
55 | { | |
56 | static rjhash<uint64_t> H; | |
57 | return H(x.val); | |
58 | } | |
59 | }; | |
60 | } // namespace std | |
61 | ||
62 | ||
63 | // file modes | |
64 | ||
65 | static inline bool file_mode_is_readonly(int mode) { | |
66 | return (mode & CEPH_FILE_MODE_WR) == 0; | |
67 | } | |
68 | ||
69 | ||
70 | // dentries | |
71 | #define MAX_DENTRY_LEN 255 | |
72 | ||
73 | // -- | |
74 | namespace ceph { | |
75 | class Formatter; | |
76 | } | |
77 | void dump(const ceph_file_layout& l, ceph::Formatter *f); | |
78 | void dump(const ceph_dir_layout& l, ceph::Formatter *f); | |
79 | ||
80 | ||
81 | ||
82 | // file_layout_t | |
83 | ||
84 | struct file_layout_t { | |
85 | // file -> object mapping | |
86 | uint32_t stripe_unit; ///< stripe unit, in bytes, | |
87 | uint32_t stripe_count; ///< over this many objects | |
88 | uint32_t object_size; ///< until objects are this big | |
89 | ||
90 | int64_t pool_id; ///< rados pool id | |
91 | string pool_ns; ///< rados pool namespace | |
92 | ||
93 | file_layout_t(uint32_t su=0, uint32_t sc=0, uint32_t os=0) | |
94 | : stripe_unit(su), | |
95 | stripe_count(sc), | |
96 | object_size(os), | |
97 | pool_id(-1) { | |
98 | } | |
99 | ||
100 | static file_layout_t get_default() { | |
101 | return file_layout_t(1<<22, 1, 1<<22); | |
102 | } | |
103 | ||
104 | uint64_t get_period() const { | |
105 | return static_cast<uint64_t>(stripe_count) * object_size; | |
106 | } | |
107 | ||
108 | void from_legacy(const ceph_file_layout& fl); | |
109 | void to_legacy(ceph_file_layout *fl) const; | |
110 | ||
111 | bool is_valid() const; | |
112 | ||
113 | void encode(bufferlist& bl, uint64_t features) const; | |
114 | void decode(bufferlist::iterator& p); | |
115 | void dump(Formatter *f) const; | |
116 | static void generate_test_instances(list<file_layout_t*>& o); | |
117 | }; | |
118 | WRITE_CLASS_ENCODER_FEATURES(file_layout_t) | |
119 | ||
120 | WRITE_EQ_OPERATORS_5(file_layout_t, stripe_unit, stripe_count, object_size, pool_id, pool_ns); | |
121 | ||
122 | ostream& operator<<(ostream& out, const file_layout_t &layout); | |
123 | ||
124 | #endif |