From: Andrew Tridgell Date: Sat, 28 Apr 2007 16:18:33 +0000 (+0200) Subject: much simpler redirect logic X-Git-Tag: tevent-0.9.20~348^2~2813 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e09bfdaf947ca69ae0ed6194d7296c1d50d1799;p=thirdparty%2Fsamba.git much simpler redirect logic (This used to be ctdb commit 95db9afa7dd039e1700e2f3078782f6ac66e9f51) --- diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index 65b678fbcae..5c46cd2f65b 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -267,11 +267,6 @@ void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t length) ctdb_reply_error(ctdb, hdr); break; - case CTDB_REPLY_REDIRECT: - ctdb->status.count.reply_redirect++; - ctdb_reply_redirect(ctdb, hdr); - break; - case CTDB_REQ_DMASTER: ctdb->status.count.req_dmaster++; ctdb_request_dmaster(ctdb, hdr); diff --git a/ctdb/common/ctdb_call.c b/ctdb/common/ctdb_call.c index cfbea14863d..a7fb253a377 100644 --- a/ctdb/common/ctdb_call.c +++ b/ctdb/common/ctdb_call.c @@ -162,22 +162,18 @@ static void ctdb_send_error(struct ctdb_context *ctdb, send a redirect reply */ static void ctdb_call_send_redirect(struct ctdb_context *ctdb, + TDB_DATA key, struct ctdb_req_call *c, struct ctdb_ltdb_header *header) { - struct ctdb_reply_redirect *r; - - r = ctdb_transport_allocate(ctdb, ctdb, CTDB_REPLY_REDIRECT, sizeof(*r), - struct ctdb_reply_redirect); - CTDB_NO_MEMORY_FATAL(ctdb, r); - - r->hdr.destnode = c->hdr.srcnode; - r->hdr.reqid = c->hdr.reqid; - r->dmaster = header->dmaster; - - ctdb_queue_packet(ctdb, &r->hdr); - - talloc_free(r); + + uint32_t lmaster = ctdb_lmaster(ctdb, &key); + if (ctdb->vnn == lmaster) { + c->hdr.destnode = header->dmaster; + } else { + c->hdr.destnode = lmaster; + } + ctdb_queue_packet(ctdb, &c->hdr); } @@ -438,7 +434,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) /* if we are not the dmaster, then send a redirect to the requesting node */ if (header.dmaster != ctdb->vnn) { - ctdb_call_send_redirect(ctdb, c, &header); + ctdb_call_send_redirect(ctdb, call.key, c, &header); talloc_free(data.dptr); ctdb_ltdb_unlock(ctdb_db, call.key); return; @@ -594,44 +590,6 @@ void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) } -/* - called when a CTDB_REPLY_REDIRECT packet comes in - - This packet arrives when we have sent a CTDB_REQ_CALL request and - the node that received it is not the dmaster for the given key. We - are given a hint as to what node to try next. -*/ -void ctdb_reply_redirect(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) -{ - struct ctdb_reply_redirect *c = (struct ctdb_reply_redirect *)hdr; - struct ctdb_call_state *state; - - state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state); - if (state == NULL) { - return; - } - - if (hdr->reqid != state->reqid) { - /* we found a record but it was the wrong one */ - DEBUG(0, ("Dropped orphaned dmaster reply with reqid:%d\n",hdr->reqid)); - return; - } - - /* don't allow for too many redirects */ - if ((++state->redirect_count) % CTDB_MAX_REDIRECT == 0) { - c->dmaster = ctdb_lmaster(ctdb, &state->call.key); - if (state->redirect_count > ctdb->status.max_redirect_count) { - ctdb->status.max_redirect_count = state->redirect_count; - } - } - - /* send it off again */ - state->node = ctdb->nodes[c->dmaster]; - state->c->hdr.destnode = c->dmaster; - - ctdb_queue_packet(ctdb, &state->c->hdr); -} - /* destroy a ctdb_call */ diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index a75f1d970b4..170e28d3621 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -135,7 +135,6 @@ struct ctdb_status { struct { uint32_t req_call; uint32_t reply_call; - uint32_t reply_redirect; uint32_t req_dmaster; uint32_t reply_dmaster; uint32_t reply_error; @@ -158,7 +157,6 @@ struct ctdb_status { uint32_t lockwait_calls; uint32_t pending_lockwait_calls; uint32_t __last_counter; /* hack for control_status_all */ - uint32_t max_redirect_count; double max_call_latency; double max_lockwait_latency; }; @@ -229,9 +227,6 @@ struct ctdb_db_context { /* arbitrary maximum timeout for ctdb operations */ #define CTDB_REQ_TIMEOUT 0 -/* max number of redirects before we ask the lmaster */ -#define CTDB_MAX_REDIRECT 2 - /* number of consecutive calls from the same node before we give them the record */ #define CTDB_DEFAULT_MAX_LACOUNT 7 @@ -271,7 +266,6 @@ struct ctdb_call_state { struct ctdb_node *node; const char *errmsg; struct ctdb_call call; - int redirect_count; struct ctdb_ltdb_header header; struct { void (*fn)(struct ctdb_call_state *); @@ -293,21 +287,20 @@ struct ctdb_fetch_handle { */ enum ctdb_operation { CTDB_REQ_CALL = 0, - CTDB_REPLY_CALL = 1, - CTDB_REPLY_REDIRECT = 2, - CTDB_REQ_DMASTER = 3, - CTDB_REPLY_DMASTER = 4, - CTDB_REPLY_ERROR = 5, - CTDB_REQ_MESSAGE = 6, - CTDB_REQ_FINISHED = 7, - CTDB_REQ_CONTROL = 8, - CTDB_REPLY_CONTROL = 9, + CTDB_REPLY_CALL, + CTDB_REQ_DMASTER, + CTDB_REPLY_DMASTER, + CTDB_REPLY_ERROR, + CTDB_REQ_MESSAGE, + CTDB_REQ_FINISHED, + CTDB_REQ_CONTROL, + CTDB_REPLY_CONTROL, /* only used on the domain socket */ CTDB_REQ_REGISTER = 1000, - CTDB_REQ_CONNECT_WAIT = 1001, - CTDB_REPLY_CONNECT_WAIT = 1002, - CTDB_REQ_SHUTDOWN = 1003 + CTDB_REQ_CONNECT_WAIT, + CTDB_REPLY_CONNECT_WAIT, + CTDB_REQ_SHUTDOWN }; #define CTDB_MAGIC 0x43544442 /* CTDB */ @@ -351,11 +344,6 @@ struct ctdb_reply_error { uint8_t msg[1]; }; -struct ctdb_reply_redirect { - struct ctdb_req_header hdr; - uint32_t dmaster; -}; - struct ctdb_req_dmaster { struct ctdb_req_header hdr; uint32_t db_id; @@ -442,7 +430,6 @@ void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr); void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr); void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr); -void ctdb_reply_redirect(struct ctdb_context *ctdb, struct ctdb_req_header *hdr); uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key); int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db, diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index 983afa0adb7..e628bad8003 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -1,7 +1,7 @@ #!/bin/sh -tests/fetch.sh || exit 1 -tests/bench.sh || exit 1 +tests/fetch.sh 4 || exit 1 +tests/bench.sh 4 || exit 1 tests/test.sh || exit 1 echo "All OK" diff --git a/ctdb/tools/ctdb_control.c b/ctdb/tools/ctdb_control.c index 45743b36c6a..100215e5e5c 100644 --- a/ctdb/tools/ctdb_control.c +++ b/ctdb/tools/ctdb_control.c @@ -89,18 +89,15 @@ static void show_status(struct ctdb_status *s) printf(" node_packets_recv %u\n", s->node_packets_recv); printf(" req_call %u\n", s->count.req_call); printf(" reply_call %u\n", s->count.reply_call); - printf(" reply_redirect %u\n", s->count.reply_redirect); printf(" req_dmaster %u\n", s->count.req_dmaster); printf(" reply_dmaster %u\n", s->count.reply_dmaster); printf(" reply_error %u\n", s->count.reply_error); - printf(" reply_redirect %u\n", s->count.reply_redirect); printf(" req_message %u\n", s->count.req_message); printf(" req_finished %u\n", s->count.req_finished); printf(" total_calls %u\n", s->total_calls); printf(" pending_calls %u\n", s->pending_calls); printf(" lockwait_calls %u\n", s->lockwait_calls); printf(" pending_lockwait_calls %u\n", s->pending_lockwait_calls); - printf(" max_redirect_count %u\n", s->max_redirect_count); printf(" max_call_latency %.6f sec\n", s->max_call_latency); printf(" max_lockwait_latency %.6f sec\n", s->max_lockwait_latency); } @@ -135,8 +132,6 @@ static int control_status_all(struct ctdb_context *ctdb) for (j=0;j