Revert "change the hash function to use the much better Jenkins hash"
[metze/ctdb/wip.git] / common / ctdb_util.c
index 433a2ad8578b29421449984c6af44814f6666af7..4acfa3f33e1badaa0b1108e07d6377f62436717a 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -123,46 +123,14 @@ static void *_idr_find_type(struct idr_context *idp, int id, const char *type, c
        return p;
 }
 
-
-/*
-  update a max latency number
- */
-void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t)
-{
-       double l = timeval_elapsed(&t);
-       if (l > *latency) {
-               *latency = l;
-       }
-
-       if (ctdb_db->ctdb->tunable.log_latency_ms !=0) {
-               if (l*1000 > ctdb_db->ctdb->tunable.log_latency_ms) {
-                       DEBUG(DEBUG_WARNING, ("High latency %.6fs for operation %s on database %s\n", l, name, ctdb_db->db_name));
-               }
-       }
-}
-
-/*
-  update a reclock latency number
- */
-void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l)
-{
-       if (l > *latency) {
-               *latency = l;
-       }
-
-       if (ctdb->tunable.reclock_latency_ms !=0) {
-               if (l*1000 > ctdb->tunable.reclock_latency_ms) {
-                       DEBUG(DEBUG_ERR, ("High RECLOCK latency %fs for operation %s\n", l, name));
-               }
-       }
-}
-
 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
 {
-       uint32_t id;
-
-       id  = ctdb->idr_cnt++ & 0xFFFF;
-       id |= (idr_get_new(ctdb->idr, state, 0xFFFF)<<16);
+       int id = idr_get_new_above(ctdb->idr, state, ctdb->lastid+1, INT_MAX);
+       if (id < 0) {
+               DEBUG(DEBUG_NOTICE, ("Reqid wrap!\n"));
+               id = idr_get_new(ctdb->idr, state, INT_MAX);
+       }
+       ctdb->lastid = id;
        return id;
 }
 
@@ -170,7 +138,7 @@ void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *ty
 {
        void *p;
 
-       p = _idr_find_type(ctdb->idr, (reqid>>16)&0xFFFF, type, location);
+       p = _idr_find_type(ctdb->idr, reqid, type, location);
        if (p == NULL) {
                DEBUG(DEBUG_WARNING, ("Could not find idr:%u\n",reqid));
        }
@@ -183,7 +151,7 @@ void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid)
 {
        int ret;
 
-       ret = idr_remove(ctdb->idr, (reqid>>16)&0xFFFF);
+       ret = idr_remove(ctdb->idr, reqid);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Removing idr that does not exist\n"));
        }
@@ -683,5 +651,6 @@ const char *ctdb_eventscript_call_names[] = {
        "status",
        "shutdown",
        "reload",
-       "updateip"
+       "updateip",
+       "ipreallocated"
 };