#include "include/Context.h"
#include "include/buffer.h"
+#include "include/hash.h"
#include "types.h"
#include "Onode.h"
void write_onode(Onode *on);
// ** cnodes **
- hash_map<coll_t, Cnode*> cnode_map;
+ hash_map<coll_t, Cnode*, rjhash<coll_t> > cnode_map;
LRU cnode_lru;
set<Cnode*> dirty_cnodes;
map<coll_t, list<Cond*> > waitfor_cnode;
class NodePool {
protected:
- hash_map<nodeid_t, Node*> node_map; // open node map
+ hash_map<nodeid_t, Node*, rjhash<uint64_t> > node_map; // open node map
public:
vector<Extent> region_loc; // region locations
void release_all() {
while (!node_map.empty()) {
- hash_map<nodeid_t,Node*>::iterator i = node_map.begin();
+ hash_map<nodeid_t,Node*,rjhash<uint64_t> >::iterator i = node_map.begin();
debofs(2) << "ebofs.nodepool.release_all leftover " << i->first << " " << i->second << std::endl;
release( i->second );
}
#ifndef __BLOBHASH_H
#define __BLOBHASH_H
+#include "hash.h"
+
/*
- this is to make some of the STL types work with 64 bit values, string hash keys, etc.
- added when i was using an old STL.. maybe try taking these out and see if things
class blobhash {
public:
size_t operator()(const char *p, unsigned len) {
- static hash<long> H;
+ static rjhash<unsigned long> H;
long acc = 0;
while (len >= sizeof(long)) {
acc ^= *(long*)p;
--- /dev/null
+#ifndef __CEPHHASH_H
+#define __CEPHHASH_H
+
+// Robert Jenkins' function for mixing 32-bit values
+// http://burtleburtle.net/bob/hash/evahash.html
+// a, b = random bits, c = input and output
+
+#define hashmix(a,b,c) \
+ a=a-b; a=a-c; a=a^(c>>13); \
+ b=b-c; b=b-a; b=b^(a<<8); \
+ c=c-a; c=c-b; c=c^(b>>13); \
+ a=a-b; a=a-c; a=a^(c>>12); \
+ b=b-c; b=b-a; b=b^(a<<16); \
+ c=c-a; c=c-b; c=c^(b>>5); \
+ a=a-b; a=a-c; a=a^(c>>3); \
+ b=b-c; b=b-a; b=b^(a<<10); \
+ c=c-a; c=c-b; c=c^(b>>15);
+
+
+//namespace ceph {
+
+template <class _Key> struct rjhash { };
+
+inline uint64_t rjhash64(uint64_t key) {
+ key = (~key) + (key << 21); // key = (key << 21) - key - 1;
+ key = key ^ (key >> 24);
+ key = (key + (key << 3)) + (key << 8); // key * 265
+ key = key ^ (key >> 14);
+ key = (key + (key << 2)) + (key << 4); // key * 21
+ key = key ^ (key >> 28);
+ key = key + (key << 31);
+ return key;
+}
+
+inline uint32_t rjhash32(uint32_t a) {
+ a = (a+0x7ed55d16) + (a<<12);
+ a = (a^0xc761c23c) ^ (a>>19);
+ a = (a+0x165667b1) + (a<<5);
+ a = (a+0xd3a2646c) ^ (a<<9);
+ a = (a+0xfd7046c5) + (a<<3);
+ a = (a^0xb55a4f09) ^ (a>>16);
+ return a;
+}
+
+
+template<> struct rjhash<uint32_t> {
+ inline size_t operator()(const uint32_t x) const {
+#ifdef __LP64__
+ return rjhash64(x);
+#else
+ return rjhash32(x);
+#endif
+ }
+};
+
+template<> struct rjhash<uint64_t> {
+ inline size_t operator()(const uint64_t x) const {
+#ifdef __LP64__
+ return rjhash64(x);
+#else
+ return rjhash32(x) ^ rjhash32(x >> 32);
+#endif
+ }
+};
+
+//}
+
+
+
+#endif
#include <ext/hash_map>
using namespace __gnu_cxx;
+#include "hash.h"
typedef uint32_t objectrev_t;
}
+
+
+
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 hash<uint64_t> H;
- static hash<uint32_t> I;
- return H(r.ino) ^ I(r.bno);
+ static rjhash<uint64_t> H;
+ static rjhash<uint32_t> I;
+ //static hash<uint64_t> H;
+ //static hash<uint32_t> I;
+ return H(r.ino) ^ I(r.bno) ^ I(r.rev);
}
};
+
}
+/*
+ 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
{
size_t operator()( const inodeno_t& x ) const
{
- static hash<uint64_t> H;
+ static rjhash<uint64_t> H;
return H(x.val);
}
};
<< " writing " << donow
<< dendl;
- if (msg.msg_iovlen == IOV_MAX-1) {
+ if (msg.msg_iovlen >= IOV_MAX-1) {
// send what we have so far...
int r = sendmsg(sd, &msg, 0);
if (r < 0) {
#include "include/buffer.h"
#include <map>
-#include <ext/hash_map>
-using namespace __gnu_cxx;
+
// crap-a-crap hash
//#define HASH_DIRS 0x80
struct stat st;
int r = ::stat(basedir.c_str(), &st);
if (r != 0) {
- derr(0) << "unable to stat basedir " << basedir << ", r = " << r << dendl;
+ derr(0) << "unable to stat basedir " << basedir << ", " << strerror(errno) << dendl;
return r;
}
Mutex peer_stat_lock;
osd_peer_stat_t my_stat;
- hash_map<int, osd_peer_stat_t> peer_stat;
- hash_map<int, osd_peer_stat_t> my_stat_on_peer; // what the peer thinks of me
+ hash_map<int, osd_peer_stat_t, rjhash<uint32_t> > peer_stat;
+ hash_map<int, osd_peer_stat_t, rjhash<uint32_t> > my_stat_on_peer; // what the peer thinks of me
void _refresh_my_stat(utime_t now);
osd_peer_stat_t get_my_stat_for(utime_t now, int peer);
break;
case OBJECT_LAYOUT_HASHINO:
+ //ps = stable_mod(oid.bno + H(oid.bno+oid.ino)^H(oid.ino>>32), num, num_mask);
ps = stable_mod(oid.bno + H(oid.ino)^H(oid.ino>>32), num, num_mask);
break;
case OBJECT_LAYOUT_HASH:
//ps = stable_mod(H( (oid.bno & oid.ino) ^ ((oid.bno^oid.ino) >> 32) ), num, num_mask);
- ps = stable_mod(H(oid.bno) ^ H(oid.ino)^H(oid.ino>>32), num, num_mask);
+ //ps = stable_mod(H(oid.bno) + H(oid.ino)^H(oid.ino>>32), num, num_mask);
+ //ps = stable_mod(oid.bno + H(oid.bno+oid.ino)^H(oid.bno+oid.ino>>32), num, num_mask);
+ ps = stable_mod(oid.bno + H(oid.ino)^H(oid.ino>>32), num, num_mask);
break;
default:
{
size_t operator()( const pg_t& x ) const
{
- static hash<uint64_t> H;
+ static rjhash<uint64_t> H;
return H(x);
}
};