ctdb: use full range of IDR
authorRusty Russell <rusty@rustcorp.com.au>
Sat, 8 May 2010 12:54:11 +0000 (22:24 +0930)
committerRonnie sahlberg <ronniesahlberg@gmail.com>
Mon, 10 May 2010 23:07:55 +0000 (09:07 +1000)
This resolves a problem with huge numbers of requests which could overflow
16 bits.  Fortunately, the IDR should scale reasonably well, so we can simply
hold all the requests.

Although noone checks for failure, I added a constant for that.

BZ: 60540
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
common/ctdb_util.c
include/ctdb_private.h

index acc57c986c6a9fcd99ef6871a3f28a60c066166f..87f61e78afb4b78abe93c9d56deba240173df8d9 100644 (file)
@@ -159,18 +159,14 @@ void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *l
 
 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);
-       return id;
+       return idr_get_new(ctdb->idr, state, INT_MAX);
 }
 
 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location)
 {
        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 +179,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"));
        }
index 6c70623263d8b3897ca4f05156de187a88621b04..cf3cdcd2ac4907ff0ab18bebb985ac3f839d7d4a 100644 (file)
@@ -1032,6 +1032,7 @@ int ctdb_socket_connect(struct ctdb_context *ctdb);
 void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
 void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l);
 
+#define CTDB_BAD_REQID ((uint32_t)-1)
 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);