common/MemoryModel.cc \
common/armor.c \
common/fd.cc \
+ common/fs_types.cc \
common/safe_io.c \
common/snap_types.cc \
common/str_list.cc \
--- /dev/null
+
+#include "include/fs_types.h"
+#include "common/Formatter.h"
+#include "include/ceph_features.h"
+
+void dump(const ceph_file_layout& l, Formatter *f)
+{
+ f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
+ f->dump_unsigned("stripe_count", l.fl_stripe_count);
+ f->dump_unsigned("object_size", l.fl_object_size);
+ if (l.fl_cas_hash)
+ f->dump_unsigned("cas_hash", l.fl_cas_hash);
+ if (l.fl_object_stripe_unit)
+ f->dump_unsigned("object_stripe_unit", l.fl_object_stripe_unit);
+ if (l.fl_pg_pool)
+ f->dump_unsigned("pg_pool", l.fl_pg_pool);
+}
+
+void dump(const ceph_dir_layout& l, Formatter *f)
+{
+ f->dump_unsigned("dir_hash", l.dl_dir_hash);
+}
+
+
+// file_layout_t
+
+bool file_layout_t::is_valid() const
+{
+ /* stripe unit, object size must be non-zero, 64k increment */
+ if (!stripe_unit || (stripe_unit & (CEPH_MIN_STRIPE_UNIT-1)))
+ return false;
+ if (!object_size || (object_size & (CEPH_MIN_STRIPE_UNIT-1)))
+ return false;
+ /* object size must be a multiple of stripe unit */
+ if (object_size < stripe_unit || object_size % stripe_unit)
+ return false;
+ /* stripe count must be non-zero */
+ if (!stripe_count)
+ return false;
+ return true;
+}
+
+void file_layout_t::from_legacy(const ceph_file_layout& fl)
+{
+ stripe_unit = fl.fl_stripe_unit;
+ stripe_count = fl.fl_stripe_count;
+ object_size = fl.fl_object_size;
+ pool_id = (int32_t)fl.fl_pg_pool;
+ pool_ns.clear();
+}
+
+void file_layout_t::to_legacy(ceph_file_layout *fl) const
+{
+ fl->fl_stripe_unit = stripe_unit;
+ fl->fl_stripe_count = stripe_count;
+ fl->fl_object_size = object_size;
+ fl->fl_cas_hash = 0;
+ fl->fl_object_stripe_unit = 0;
+ fl->fl_unused = 0;
+ fl->fl_pg_pool = pool_id;
+}
+
+void file_layout_t::encode(bufferlist& bl, uint64_t features) const
+{
+ if ((features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) == 0) {
+ ceph_file_layout fl;
+ assert((stripe_unit & 0xff) == 0); // first byte must be 0
+ to_legacy(&fl);
+ ::encode(fl, bl);
+ return;
+ }
+
+ ENCODE_START(2, 2, bl);
+ ::encode(stripe_unit, bl);
+ ::encode(stripe_count, bl);
+ ::encode(object_size, bl);
+ ::encode(pool_id, bl);
+ ::encode(pool_ns, bl);
+ ENCODE_FINISH(bl);
+}
+
+void file_layout_t::decode(bufferlist::iterator& p)
+{
+ if (*p == 0) {
+ ceph_file_layout fl;
+ ::decode(fl, p);
+ from_legacy(fl);
+ return;
+ }
+ DECODE_START(2, p);
+ ::decode(stripe_unit, p);
+ ::decode(stripe_count, p);
+ ::decode(object_size, p);
+ ::decode(pool_id, p);
+ ::decode(pool_ns, p);
+ DECODE_FINISH(p);
+}
+
+void file_layout_t::dump(Formatter *f) const
+{
+ f->dump_unsigned("stripe_unit", stripe_unit);
+ f->dump_unsigned("stripe_count", stripe_count);
+ f->dump_unsigned("object_size", object_size);
+ f->dump_unsigned("pool_id", pool_id);
+ f->dump_string("pool_ns", pool_ns);
+}
+
+void file_layout_t::generate_test_instances(list<file_layout_t*>& o)
+{
+ o.push_back(new file_layout_t);
+ o.push_back(new file_layout_t);
+ o.back()->stripe_unit = 4096;
+ o.back()->stripe_count = 16;
+ o.back()->object_size = 1048576;
+ o.back()->pool_id = 3;
+ o.back()->pool_ns = "myns";
+}
#define __CEPH_SNAP_TYPES_H
#include "include/types.h"
+#include "include/fs_types.h"
namespace ceph {
include/error.h \
include/filepath.h \
include/frag.h \
+ include/fs_types.h \
include/hash.h \
include/inline_memory.h \
include/intarith.h \
#define CEPH_FEATURE_SERVER_JEWEL (1ULL<<57) /* overlap, features introduced in jewel */
#define CEPH_FEATURE_CRUSH_TUNABLES5 (1ULL<<58) /* chooseleaf stable mode */
// duplicated since it was introduced at the same time as CEPH_FEATURE_CRUSH_TUNABLES5
-#define CEPH_FEATURE_NEW_OSDOPREPLY_ENCODING (1ULL<<58) /* New, v7 encoding */
+#define CEPH_FEATURE_NEW_OSDOPREPLY_ENCODING (1ULL<<58) /* New, v7 encoding */
+#define CEPH_FEATURE_FS_FILE_LAYOUT_V2 (1ULL<<58) /* file_layout_t */
#define CEPH_FEATURE_RESERVED2 (1ULL<<61) /* slow down, we are almost out... */
#define CEPH_FEATURE_RESERVED (1ULL<<62) /* DO NOT USE THIS ... last bit! */
#include "buffer.h"
#include "encoding.h"
#include "include/types.h"
+#include "include/fs_types.h"
#include "common/Formatter.h"
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#ifndef CEPH_INCLUDE_FS_TYPES_H
+#define CEPH_INCLUDE_FS_TYPES_H
+
+#include "types.h"
+#include "utime.h"
+
+// --------------------------------------
+// ino
+
+typedef uint64_t _inodeno_t;
+
+struct inodeno_t {
+ _inodeno_t val;
+ inodeno_t() : val(0) {}
+ // cppcheck-suppress noExplicitConstructor
+ inodeno_t(_inodeno_t v) : val(v) {}
+ inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; }
+ operator _inodeno_t() const { return val; }
+
+ void encode(bufferlist& bl) const {
+ ::encode(val, bl);
+ }
+ void decode(bufferlist::iterator& p) {
+ ::decode(val, p);
+ }
+} __attribute__ ((__may_alias__));
+WRITE_CLASS_ENCODER(inodeno_t)
+
+inline ostream& operator<<(ostream& out, inodeno_t ino) {
+ return out << hex << ino.val << dec;
+}
+
+namespace std {
+ template<> struct hash< inodeno_t >
+ {
+ size_t operator()( const inodeno_t& x ) const
+ {
+ static rjhash<uint64_t> H;
+ return H(x.val);
+ }
+ };
+} // namespace std
+
+
+// file modes
+
+static inline bool file_mode_is_readonly(int mode) {
+ return (mode & CEPH_FILE_MODE_WR) == 0;
+}
+
+
+// dentries
+#define MAX_DENTRY_LEN 255
+
+// --
+namespace ceph {
+ class Formatter;
+}
+void dump(const ceph_file_layout& l, ceph::Formatter *f);
+void dump(const ceph_dir_layout& l, ceph::Formatter *f);
+
+
+
+// file_layout_t
+
+struct file_layout_t {
+ // file -> object mapping
+ uint32_t stripe_unit; ///< stripe unit, in bytes,
+ uint32_t stripe_count; ///< over this many objects
+ uint32_t object_size; ///< until objects are this big
+
+ int64_t pool_id; ///< rados pool id
+ string pool_ns; ///< rados pool namespace
+
+ file_layout_t(uint32_t su=0, uint32_t sc=0, uint32_t os=0)
+ : stripe_unit(su),
+ stripe_count(sc),
+ object_size(os),
+ pool_id(-1) {
+ }
+
+ static file_layout_t get_default() {
+ return file_layout_t(1<<22, 1, 1<<22);
+ }
+
+ uint64_t get_period() const {
+ return stripe_count * object_size;
+ }
+
+ void from_legacy(const ceph_file_layout& fl);
+ void to_legacy(ceph_file_layout *fl) const;
+
+ bool is_valid() const;
+
+ void encode(bufferlist& bl, uint64_t features) const;
+ void decode(bufferlist::iterator& p);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<file_layout_t*>& o);
+};
+WRITE_CLASS_ENCODER_FEATURES(file_layout_t)
+
+#endif
-// --------------------------------------
-// ino
-
-typedef uint64_t _inodeno_t;
-
-struct inodeno_t {
- _inodeno_t val;
- inodeno_t() : val(0) {}
- // cppcheck-suppress noExplicitConstructor
- inodeno_t(_inodeno_t v) : val(v) {}
- inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; }
- operator _inodeno_t() const { return val; }
-
- void encode(bufferlist& bl) const {
- ::encode(val, bl);
- }
- void decode(bufferlist::iterator& p) {
- ::decode(val, p);
- }
-} __attribute__ ((__may_alias__));
-WRITE_CLASS_ENCODER(inodeno_t)
-
-inline ostream& operator<<(ostream& out, inodeno_t ino) {
- return out << hex << ino.val << dec;
-}
-
-namespace std {
- template<> struct hash< inodeno_t >
- {
- size_t operator()( const inodeno_t& x ) const
- {
- static rjhash<uint64_t> H;
- return H(x.val);
- }
- };
-} // namespace std
-
-
-// file modes
-
-static inline bool file_mode_is_readonly(int mode) {
- return (mode & CEPH_FILE_MODE_WR) == 0;
-}
-
-
-// dentries
-#define MAX_DENTRY_LEN 255
-
-// --
-namespace ceph {
- class Formatter;
-}
-void dump(const ceph_file_layout& l, ceph::Formatter *f);
-void dump(const ceph_dir_layout& l, ceph::Formatter *f);
-
-
// --
struct prettybyte_t {
const mds_gid_t MDS_GID_NONE = mds_gid_t(0);
const mds_rank_t MDS_RANK_NONE = mds_rank_t(-1);
-void dump(const ceph_file_layout& l, Formatter *f)
-{
- f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
- f->dump_unsigned("stripe_count", l.fl_stripe_count);
- f->dump_unsigned("object_size", l.fl_object_size);
- if (l.fl_cas_hash)
- f->dump_unsigned("cas_hash", l.fl_cas_hash);
- if (l.fl_object_stripe_unit)
- f->dump_unsigned("object_stripe_unit", l.fl_object_stripe_unit);
- if (l.fl_pg_pool)
- f->dump_unsigned("pg_pool", l.fl_pg_pool);
-}
-
-void dump(const ceph_dir_layout& l, Formatter *f)
-{
- f->dump_unsigned("dir_hash", l.dl_dir_hash);
-}
-
/*
* frag_info_t
#include "include/interval_set.h"
#include "include/compact_map.h"
#include "include/compact_set.h"
+#include "include/fs_types.h"
#include "inode_backtrace.h"
#define CEPH_MCLIENTREPLY_H
#include "include/types.h"
+#include "include/fs_types.h"
#include "MClientRequest.h"
#include "msg/Message.h"
TYPE(inode_backtrace_t)
TYPE(inode_backpointer_t)
TYPE(quota_info_t)
+
+#include "include/fs_types.h"
+TYPE_FEATUREFUL(file_layout_t)
TYPE(ceph_file_layout_wrapper)
#include "mds/CInode.h"
#endif
#include "include/compat.h"
+#include "include/fs_types.h"
#include "common/entity_name.h"
#include "common/errno.h"
#include "common/safe_io.h"