]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
added a hopcount in ctdb_call
authorAndrew Tridgell <tridge@samba.org>
Tue, 1 May 2007 03:25:02 +0000 (13:25 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 1 May 2007 03:25:02 +0000 (13:25 +1000)
(This used to be ctdb commit 36d838801a2a2008c50322cdbfff65a308b1cd1a)

ctdb/common/ctdb_call.c
ctdb/common/ctdb_client.c
ctdb/common/ctdb_ltdb.c
ctdb/include/ctdb_private.h
ctdb/tcp/tcp_connect.c
ctdb/tools/ctdb_control.c

index 476d86f911241a95822a8adc8d2497be645c5d87..0d34b01f9de6caacf2029f240b13ee3da4e943b9 100644 (file)
@@ -170,9 +170,12 @@ static void ctdb_call_send_redirect(struct ctdb_context *ctdb,
        uint32_t lmaster = ctdb_lmaster(ctdb, &key);
        if (ctdb->vnn == lmaster) {
                c->hdr.destnode = header->dmaster;
-       } else {
+       } else if ((c->hopcount % CTDB_MAX_REDIRECT_COUNT) == 0) {
                c->hdr.destnode = lmaster;
+       } else {
+               c->hdr.destnode = header->dmaster;
        }
+       c->hopcount++;
        ctdb_queue_packet(ctdb, &c->hdr);
 }
 
@@ -449,6 +452,10 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                return;
        }
 
+       if (c->hopcount > ctdb->status.max_hop_count) {
+               ctdb->status.max_hop_count = c->hopcount;
+       }
+
        /* if this nodes has done enough consecutive calls on the same record
           then give them the record
           or if the node requested an immediate migration
@@ -704,6 +711,7 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
        state->c->flags         = call->flags;
        state->c->db_id         = ctdb_db->db_id;
        state->c->callid        = call->call_id;
+       state->c->hopcount      = 0;
        state->c->keylen        = call->key.dsize;
        state->c->calldatalen   = call->call_data.dsize;
        memcpy(&state->c->data[0], call->key.dptr, call->key.dsize);
index 53302c3bfdb94180029fff05151894e88efb390d..87960d344e3f5b6d8bc22f19c185c59ab05895c5 100644 (file)
@@ -333,6 +333,7 @@ struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db,
        c->flags         = call->flags;
        c->db_id         = ctdb_db->db_id;
        c->callid        = call->call_id;
+       c->hopcount      = 0;
        c->keylen        = call->key.dsize;
        c->calldatalen   = call->call_data.dsize;
        memcpy(&c->data[0], call->key.dptr, call->key.dsize);
index e071a20590aa25655e5effaf22baf7db60362cd2..979d506b0b3e41cc743c18e647c23947e1cece03 100644 (file)
@@ -372,7 +372,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
                                 CTDB_CONTROL_DB_ATTACH, CTDB_CTRL_FLAG_NOREPLY,
                                 indata, NULL, NULL);
 
-       DEBUG(0,("Attached to database '%s'\n", ctdb_db->db_path));
+       DEBUG(1,("Attached to database '%s'\n", ctdb_db->db_path));
 
        /* success */
        return 0;
index 1f56776c9a59aa9ca0cd77cb6391714b543c0549..8b75ec4c04a3049d649a3b1fa24d7d1ee22a7ccb 100644 (file)
@@ -35,6 +35,7 @@
 #define CTDB_CURRENT_NODE  0xF0000001
 #define CTDB_BROADCAST_VNN 0xF0000002
 
+#define CTDB_MAX_REDIRECT_COUNT 3
 
 /*
   an installed ctdb remote call
@@ -157,6 +158,7 @@ struct ctdb_status {
        uint32_t lockwait_calls;
        uint32_t pending_lockwait_calls;
        uint32_t __last_counter; /* hack for control_status_all */
+       uint32_t max_hop_count;
        double max_call_latency;
        double max_lockwait_latency;
 };
@@ -338,6 +340,7 @@ struct ctdb_req_call {
        uint32_t flags;
        uint32_t db_id;
        uint32_t callid;
+       uint32_t hopcount;
        uint32_t keylen;
        uint32_t calldatalen;
        uint8_t data[1]; /* key[] followed by calldata[] */
index 30d87001afea75eb11c5c19bdc705c70ebe508e3..d5c943bc42fa9f0e88dc4e61895e89679aa91c66 100644 (file)
@@ -262,7 +262,7 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                                     ctdb->address.port);
        ctdb->vnn = ctdb->nodes[i]->vnn;
        ctdb->nodes[i]->flags |= NODE_FLAGS_CONNECTED;
-       DEBUG(0,("ctdb chose network address %s:%u vnn %u\n", 
+       DEBUG(1,("ctdb chose network address %s:%u vnn %u\n", 
                 ctdb->address.address, 
                 ctdb->address.port, 
                 ctdb->vnn));
index fefa806472f5d664ff3f99ef148bd87263235c0b..37a068a15bec4a88d7886de94ac428741e6a3371 100644 (file)
@@ -99,6 +99,7 @@ static void show_status(struct ctdb_status *s)
        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_hop_count           %u\n", s->max_hop_count);
        printf(" max_call_latency        %.6f sec\n", s->max_call_latency);
        printf(" max_lockwait_latency    %.6f sec\n", s->max_lockwait_latency);
 }
@@ -133,6 +134,8 @@ static int control_status_all(struct ctdb_context *ctdb)
                for (j=0;j<num_ints;j++) {
                        v2[j] += v1[j];
                }
+               status.max_hop_count = 
+                       MAX(status.max_hop_count, s1.max_hop_count);
                status.max_call_latency = 
                        MAX(status.max_call_latency, s1.max_call_latency);
                status.max_lockwait_latency =