]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/fs_types.h
update sources to v12.1.3
[ceph.git] / ceph / src / include / fs_types.h
CommitLineData
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"
7c673cae
FG
7
8// --------------------------------------
9// ino
10
11typedef uint64_t _inodeno_t;
12
13struct inodeno_t {
14 _inodeno_t val;
15 inodeno_t() : val(0) {}
16 // cppcheck-suppress noExplicitConstructor
17 inodeno_t(_inodeno_t v) : val(v) {}
18 inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; }
19 operator _inodeno_t() const { return val; }
20
21 void encode(bufferlist& bl) const {
22 ::encode(val, bl);
23 }
24 void decode(bufferlist::iterator& p) {
25 ::decode(val, p);
26 }
27} __attribute__ ((__may_alias__));
28WRITE_CLASS_ENCODER(inodeno_t)
29
30template<>
31struct denc_traits<inodeno_t> {
32 static constexpr bool supported = true;
33 static constexpr bool featured = false;
34 static constexpr bool bounded = true;
31f18b77 35 static constexpr bool need_contiguous = true;
7c673cae
FG
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
31f18b77 47inline ostream& operator<<(ostream& out, const inodeno_t& ino) {
d2e6a577 48 return out << hex << "0x" << ino.val << dec;
7c673cae
FG
49}
50
51namespace 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
65static 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// --
74namespace ceph {
75 class Formatter;
76}
77void dump(const ceph_file_layout& l, ceph::Formatter *f);
78void dump(const ceph_dir_layout& l, ceph::Formatter *f);
79
80
81
82// file_layout_t
83
84struct 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};
118WRITE_CLASS_ENCODER_FEATURES(file_layout_t)
119
120WRITE_EQ_OPERATORS_5(file_layout_t, stripe_unit, stripe_count, object_size, pool_id, pool_ns);
121
122ostream& operator<<(ostream& out, const file_layout_t &layout);
123
124#endif