]>
git.proxmox.com Git - ceph.git/blob - ceph/src/include/fs_types.h
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
8 // --------------------------------------
11 typedef uint64_t _inodeno_t
;
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
; }
21 void encode(bufferlist
& bl
) const {
24 void decode(bufferlist::iterator
& p
) {
27 } __attribute__ ((__may_alias__
));
28 WRITE_CLASS_ENCODER(inodeno_t
)
31 struct denc_traits
<inodeno_t
> {
32 static constexpr bool supported
= true;
33 static constexpr bool featured
= false;
34 static constexpr bool bounded
= true;
35 static constexpr bool need_contiguous
= true;
36 static void bound_encode(const inodeno_t
&o
, size_t& p
) {
39 static void encode(const inodeno_t
&o
, buffer::list::contiguous_appender
& p
) {
42 static void decode(inodeno_t
& o
, buffer::ptr::iterator
&p
) {
47 inline ostream
& operator<<(ostream
& out
, const inodeno_t
& ino
) {
48 return out
<< hex
<< ino
.val
<< dec
;
52 template<> struct hash
< inodeno_t
>
54 size_t operator()( const inodeno_t
& x
) const
56 static rjhash
<uint64_t> H
;
65 static inline bool file_mode_is_readonly(int mode
) {
66 return (mode
& CEPH_FILE_MODE_WR
) == 0;
71 #define MAX_DENTRY_LEN 255
77 void dump(const ceph_file_layout
& l
, ceph::Formatter
*f
);
78 void dump(const ceph_dir_layout
& l
, ceph::Formatter
*f
);
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
90 int64_t pool_id
; ///< rados pool id
91 string pool_ns
; ///< rados pool namespace
93 file_layout_t(uint32_t su
=0, uint32_t sc
=0, uint32_t os
=0)
100 static file_layout_t
get_default() {
101 return file_layout_t(1<<22, 1, 1<<22);
104 uint64_t get_period() const {
105 return static_cast<uint64_t>(stripe_count
) * object_size
;
108 void from_legacy(const ceph_file_layout
& fl
);
109 void to_legacy(ceph_file_layout
*fl
) const;
111 bool is_valid() const;
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
);
118 WRITE_CLASS_ENCODER_FEATURES(file_layout_t
)
120 WRITE_EQ_OPERATORS_5(file_layout_t
, stripe_unit
, stripe_count
, object_size
, pool_id
, pool_ns
);
122 ostream
& operator<<(ostream
& out
, const file_layout_t
&layout
);