-/* -*- 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
#ifndef _FS_CEPH_CEPH_FS_H
#define _FS_CEPH_CEPH_FS_H
-typedef u64 ceph_ino_t;
+#include <linux/types.h>
+
+
+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;
/* 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)
#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;
ceph_pg_t ol_pgid;
__u32 ol_stripe_unit;
};
-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
+++ /dev/null
-#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
namespace __gnu_cxx {
-#ifndef __LP64__
- template<> struct hash<uint64_t> {
- size_t operator()(uint64_t __x) const {
- static hash<uint32_t> H;
- return H((__x >> 32) ^ (__x & 0xffffffff));
- //static rjhash<uint64_t> H;
- //return H(__x);
- }
- };
-#endif
-
template<> struct hash<object_t> {
size_t operator()(const object_t &r) const {
static rjhash<uint64_t> H;
};
}
-
-/*
- template<> struct rjhash<object_t> {
- size_t operator()(const object_t &r) const {
- static rjhash<uint64_t> H;
- static rjhash<uint32_t> I;
- return H(r.ino) ^ I(r.bno) ^ I(r.rev);
- }
- };
-*/
-
#endif
#include <ext/hash_map>
using namespace __gnu_cxx;
-
-#include "ceph_inttypes.h"
#include "ceph_fs.h"
return H(x.c_str());
}
};
-
-#ifndef __LP64__
- template<> struct hash<int64_t> {
- size_t operator()(int64_t __x) const {
- static hash<int32_t> H;
- return H((__x >> 32) ^ (__x & 0xffffffff));
- }
- };
-#endif
-
}
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
// --------------------------------------
// inode
-typedef ceph_ino_t _inodeno_t;
+typedef __uint64_t _inodeno_t;
struct inodeno_t {
_inodeno_t val;
+++ /dev/null
-/* -*- 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
#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"
};
}
-// 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.
int op; // write, zero, trunc, remove
object_t oid;
eversion_t version;
- objectrev_t rev;
osdreqid_t reqid; // caller+tid to uniquely identify request
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; }
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)