From c71563c2cab48ee0aec360f5d00b1d48cd78f591 Mon Sep 17 00:00:00 2001 From: sageweil Date: Mon, 15 Oct 2007 16:14:58 +0000 Subject: [PATCH] more header, data type cleanup git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1941 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/include/ceph_fs.h | 81 +++++++++++++++++++++++------- trunk/ceph/include/ceph_inttypes.h | 30 ----------- trunk/ceph/include/object.h | 22 -------- trunk/ceph/include/types.h | 16 +----- trunk/ceph/msg/ceph_msg_types.h | 49 ------------------ trunk/ceph/msg/msg_types.h | 10 +--- trunk/ceph/osd/PG.h | 1 - trunk/ceph/osd/osd_types.h | 42 +++++++--------- 8 files changed, 82 insertions(+), 169 deletions(-) delete mode 100644 trunk/ceph/include/ceph_inttypes.h delete mode 100644 trunk/ceph/msg/ceph_msg_types.h diff --git a/trunk/ceph/include/ceph_fs.h b/trunk/ceph/include/ceph_fs.h index 9c1b1faf4eab9..ffd170999233a 100644 --- a/trunk/ceph/include/ceph_fs.h +++ b/trunk/ceph/include/ceph_fs.h @@ -1,7 +1,3 @@ -/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:t -*- - * vim: ts=8 sw=8 smarttab - */ - /* ceph_fs.h * * C data types to share between kernel and userspace @@ -10,15 +6,19 @@ #ifndef _FS_CEPH_CEPH_FS_H #define _FS_CEPH_CEPH_FS_H -typedef u64 ceph_ino_t; +#include + + +typedef __u64 ceph_ino_t; + /** * object id */ struct ceph_object { ceph_ino_t ino; /* inode "file" identifier */ - u32 bno; /* "block" (object) in that "file" */ - u32 rev; /* revision. normally ctime (as epoch). */ + __u32 bno; /* "block" (object) in that "file" */ + __u32 rev; /* revision. normally ctime (as epoch). */ }; typedef struct ceph_object ceph_object_t; @@ -59,7 +59,6 @@ struct ceph_file_layout { /* pg -> disk layout */ __u32 fl_object_stripe_unit; /* for per-object raid */ }; -typedef struct ceph_file_layout ceph_file_layout_t; #define ceph_file_layout_stripe_width(l) (l.fl_stripe_unit * l.fl_stripe_count) @@ -75,12 +74,12 @@ typedef struct ceph_file_layout ceph_file_layout_t; #define CEPH_PG_TYPE_RAID4 2 union ceph_pg { - u64 pg64; + __u64 pg64; struct { - s32 preferred; /* preferred primary osd */ - u16 ps; /* placement seed */ - u8 type; - u8 size; + __s32 preferred; /* preferred primary osd */ + __u16 ps; /* placement seed */ + __u8 type; + __u8 size; } pg; }; typedef union ceph_pg ceph_pg_t; @@ -97,7 +96,6 @@ struct ceph_object_layout { ceph_pg_t ol_pgid; __u32 ol_stripe_unit; }; -typedef struct ceph_object_layout ceph_object_layout_t; @@ -106,14 +104,61 @@ typedef struct ceph_object_layout ceph_object_layout_t; */ struct ceph_object_extent { ceph_object_t oe_oid; - u64 oe_start; - u64 oe_length; - ceph_object_layout_t oe_object_layout; + __u64 oe_start; + __u64 oe_length; + struct ceph_object_layout oe_object_layout; /* buffer extent reverse mapping? */ }; -typedef ceph_object_extent ceph_object_extent_t; + + +/********************************************* + * message types + */ + +/* + * entity_name + */ +struct ceph_entity_name { + __u32 type; + __u32 num; +}; + +#define CEPH_ENTITY_TYPE_MON 1 +#define CEPH_ENTITY_TYPE_MDS 2 +#define CEPH_ENTITY_TYPE_OSD 3 +#define CEPH_ENTITY_TYPE_CLIENT 4 +#define CEPH_ENTITY_TYPE_ADMIN 5 + + +/* + * entity_addr + * ipv4 only for now + */ +struct ceph_entity_addr { + __u64 nonce; + __u32 port; + __u8 ipq[4]; +}; + + +struct ceph_entity_inst { + struct ceph_entity_name name; + struct ceph_entity_addr addr; +}; + + +/* + * message header + */ +struct ceph_message_header { + __u32 type; + struct ceph_entity_inst src, dst; + __u32 source_port, dest_port; + __u32 nchunks; +}; + #endif diff --git a/trunk/ceph/include/ceph_inttypes.h b/trunk/ceph/include/ceph_inttypes.h deleted file mode 100644 index 3c4679e728ad1..0000000000000 --- a/trunk/ceph/include/ceph_inttypes.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __CEPH_INTTYPES_H -#define __CEPH_INTTYPES_H - -/* - * these are int types defined in the kernel. - * this header should be included prior to ceph_fs.h when used from userspace. - * i suspect kernel_compat.h (or whatever) serves a similar purpose? - */ - -typedef uint32_t __u64; -typedef uint32_t __u32; -typedef uint16_t __u16; -typedef uint8_t __u8; - -typedef int32_t __s64; -typedef int32_t __s32; -typedef int16_t __s16; -typedef int8_t __s8; - -typedef uint64_t u64; -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint16_t u8; - -typedef int64_t s64; -typedef int32_t s32; -typedef int16_t s16; -typedef int16_t s8; - -#endif diff --git a/trunk/ceph/include/object.h b/trunk/ceph/include/object.h index a1382626f7cae..3b8ac05a86b38 100644 --- a/trunk/ceph/include/object.h +++ b/trunk/ceph/include/object.h @@ -85,17 +85,6 @@ inline ostream& operator<<(ostream& out, const object_t o) { namespace __gnu_cxx { -#ifndef __LP64__ - template<> struct hash { - size_t operator()(uint64_t __x) const { - static hash H; - return H((__x >> 32) ^ (__x & 0xffffffff)); - //static rjhash H; - //return H(__x); - } - }; -#endif - template<> struct hash { size_t operator()(const object_t &r) const { static rjhash H; @@ -107,15 +96,4 @@ namespace __gnu_cxx { }; } - -/* - template<> struct rjhash { - size_t operator()(const object_t &r) const { - static rjhash H; - static rjhash I; - return H(r.ino) ^ I(r.bno) ^ I(r.rev); - } - }; -*/ - #endif diff --git a/trunk/ceph/include/types.h b/trunk/ceph/include/types.h index 39a94c4dfb809..bf84575ad31d6 100644 --- a/trunk/ceph/include/types.h +++ b/trunk/ceph/include/types.h @@ -36,8 +36,6 @@ using namespace std; #include using namespace __gnu_cxx; - -#include "ceph_inttypes.h" #include "ceph_fs.h" @@ -64,16 +62,6 @@ namespace __gnu_cxx { return H(x.c_str()); } }; - -#ifndef __LP64__ - template<> struct hash { - size_t operator()(int64_t __x) const { - static hash H; - return H((__x >> 32) ^ (__x & 0xffffffff)); - } - }; -#endif - } @@ -109,8 +97,6 @@ typedef uint64_t version_t; typedef uint32_t epoch_t; // map epoch (32bits -> 13 epochs/second for 10 years) -// object and pg layout -// specified in g_conf.osd_* #define O_LAZY 01000000 @@ -122,7 +108,7 @@ typedef ceph_file_layout FileLayout; // -------------------------------------- // inode -typedef ceph_ino_t _inodeno_t; +typedef __uint64_t _inodeno_t; struct inodeno_t { _inodeno_t val; diff --git a/trunk/ceph/msg/ceph_msg_types.h b/trunk/ceph/msg/ceph_msg_types.h deleted file mode 100644 index 35e046d00aa9e..0000000000000 --- a/trunk/ceph/msg/ceph_msg_types.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- mode:C++; tab-width:8; c-basic-offset:8; indent-tabs-mode:t -*- - * vim: ts=8 sw=8 smarttab - */ -#ifndef __CEPH_MSG_TYPES_H -#define __CEPH_MSG_TYPES_H - -/* - * entity_name - */ -struct ceph_entity_name { - __u32 type; - __u32 num; -}; - -#define CEPH_ENTITY_TYPE_MON 1 -#define CEPH_ENTITY_TYPE_MDS 2 -#define CEPH_ENTITY_TYPE_OSD 3 -#define CEPH_ENTITY_TYPE_CLIENT 4 -#define CEPH_ENTITY_TYPE_ADMIN 5 - - -/* - * entity_addr - * ipv4 only for now - */ -struct ceph_entity_addr { - __u64 nonce; - __u32 port; - __u8 ipq[4]; -}; - - -struct ceph_entity_inst { - struct ceph_entity_name name; - struct ceph_entity_addr addr; -}; - - -/* - * message header - */ -struct ceph_message_header { - __u32 type; - struct ceph_entity_inst src, dst; - __u32 source_port, dest_port; - __u32 nchunks; -}; - -#endif diff --git a/trunk/ceph/msg/msg_types.h b/trunk/ceph/msg/msg_types.h index 440f7964288fb..52b1e69c8886c 100644 --- a/trunk/ceph/msg/msg_types.h +++ b/trunk/ceph/msg/msg_types.h @@ -15,10 +15,6 @@ #ifndef __MSG_TYPES_H #define __MSG_TYPES_H -// raw C structs -#include "include/ceph_inttypes.h" -#include "ceph_msg_types.h" - #include "include/types.h" #include "include/blobhash.h" #include "tcp.h" @@ -97,11 +93,7 @@ namespace __gnu_cxx { }; } -// get rid of these -//#define MSG_ADDR_MDS(x) entity_name_t(entity_name_t::TYPE_MDS,x) -//#define MSG_ADDR_OSD(x) entity_name_t(entity_name_t::TYPE_OSD,x) -//#define MSG_ADDR_MON(x) entity_name_t(entity_name_t::TYPE_MON,x) -//#define MSG_ADDR_CLIENT(x) entity_name_t(entity_name_t::TYPE_CLIENT,x) + /* * an entity's network address. diff --git a/trunk/ceph/osd/PG.h b/trunk/ceph/osd/PG.h index 21de9e8f00b0d..7c68ecec2b6e4 100644 --- a/trunk/ceph/osd/PG.h +++ b/trunk/ceph/osd/PG.h @@ -214,7 +214,6 @@ public: int op; // write, zero, trunc, remove object_t oid; eversion_t version; - objectrev_t rev; osdreqid_t reqid; // caller+tid to uniquely identify request diff --git a/trunk/ceph/osd/osd_types.h b/trunk/ceph/osd/osd_types.h index c46797d950f10..24dd9eca74234 100644 --- a/trunk/ceph/osd/osd_types.h +++ b/trunk/ceph/osd/osd_types.h @@ -86,37 +86,29 @@ public: static const int TYPE_RAID4 = CEPH_PG_TYPE_RAID4; private: - union { - struct { - int32_t preferred; - uint8_t type; - uint8_t size; - uint16_t ps; - } fields; - uint64_t val; // 64 - } u; + union ceph_pg u; public: - pg_t() { u.val = 0; } - pg_t(const pg_t& o) { u.val = o.u.val; } + pg_t() { u.pg64 = 0; } + pg_t(const pg_t& o) { u.pg64 = o.u.pg64; } pg_t(int type, int size, ps_t seed, int pref) {//, pruleset_t r=0) { - u.fields.type = type; - u.fields.size = size; - u.fields.ps = seed; - u.fields.preferred = pref; // hack: avoid negative. - //u.fields.ruleset = r; - assert(sizeof(u.fields) == sizeof(u.val)); + u.pg.type = type; + u.pg.size = size; + u.pg.ps = seed; + u.pg.preferred = pref; // hack: avoid negative. + //u.pg.ruleset = r; + assert(sizeof(u.pg) == sizeof(u.pg64)); } - pg_t(uint64_t v) { u.val = v; } + pg_t(uint64_t v) { u.pg64 = v; } - int type() { return u.fields.type; } + int type() { return u.pg.type; } bool is_rep() { return type() == TYPE_REP; } bool is_raid4() { return type() == TYPE_RAID4; } - int size() { return u.fields.size; } - ps_t ps() { return u.fields.ps; } - //pruleset_t ruleset() { return u.fields.ruleset; } - int preferred() { return u.fields.preferred; } // hack: avoid negative. + int size() { return u.pg.size; } + ps_t ps() { return u.pg.ps; } + //pruleset_t ruleset() { return u.pg.ruleset; } + int preferred() { return u.pg.preferred; } // hack: avoid negative. /* pg_t operator=(uint64_t v) { u.val = v; return *this; } @@ -125,9 +117,9 @@ public: pg_t operator-=(pg_t o) { u.val -= o.val; return *this; } pg_t operator++() { ++u.val; return *this; } */ - operator uint64_t() const { return u.val; } + operator uint64_t() const { return u.pg64; } - object_t to_object() const { return object_t(PG_INO, u.val >> 32, u.val & 0xffffffff); } + object_t to_object() const { return object_t(PG_INO, u.pg64 >> 32, u.pg64 & 0xffffffff); } }; inline ostream& operator<<(ostream& out, pg_t pg) -- 2.39.5