Create macros to update the statistics counters and use these macros
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 29 Sep 2010 00:38:41 +0000 (10:38 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 29 Sep 2010 02:14:24 +0000 (12:14 +1000)
everywhere instead of manipulating the coutenrs directly.

common/ctdb_util.c
include/ctdb_private.h
server/ctdb_call.c
server/ctdb_control.c
server/ctdb_daemon.c
server/ctdb_lockwait.c
server/ctdb_persistent.c
server/ctdb_recover.c
server/ctdb_server.c
server/ctdb_traverse.c
server/ctdbd.c

index 46c737af1fefce9ef8b4c6b81b692afb74fc4e30..4acfa3f33e1badaa0b1108e07d6377f62436717a 100644 (file)
@@ -123,40 +123,6 @@ 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)
 {
        int id = idr_get_new_above(ctdb->idr, state, ctdb->lastid+1, INT_MAX);
index cd6aeec1c44d73cb0b26e73cd49886fc242741db..1f2477054fef4ecefbf92ae1865fa857e3479166 100644 (file)
@@ -276,8 +276,58 @@ struct ctdb_daemon_data {
        struct ctdb_queue *queue;
 };
 
+
+#define CTDB_UPDATE_STAT(ctdb, counter, value) \
+       {                                                                               \
+               if (value > ctdb->statistics.counter) {                                 \
+                       ctdb->statistics.counter = c->hopcount;                         \
+               }                                                                       \
+       }
+
+#define CTDB_INCREMENT_STAT(ctdb, counter) \
+       {                                                                               \
+               ctdb->statistics.counter++;                                             \
+       }
+
+#define CTDB_DECREMENT_STAT(ctdb, counter) \
+       {                                                                               \
+               if (ctdb->statistics.counter > 0)                                       \
+                       ctdb->statistics.counter--;                                     \
+       }
+
+#define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
+       {                                                                               \
+               if (value > ctdb->statistics.counter) {                                 \
+                       ctdb->statistics.counter = value;                               \
+               }                                                                       \
+                                                                                       \
+               if (ctdb->tunable.reclock_latency_ms != 0) {                            \
+                       if (value*1000 > ctdb->tunable.reclock_latency_ms) {            \
+                               DEBUG(DEBUG_ERR, ("High RECLOCK latency %fs for operation %s\n", value, name)); \
+                       }                                                               \
+               }                                                                       \
+       }
+
+
+#define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
+       {                                                                               \
+               double l = timeval_elapsed(&t);                                         \
+               if (l > ctdb->statistics.counter) {                                     \
+                       ctdb->statistics.counter = l;                                   \
+               }                                                                       \
+                                                                                       \
+               if (ctdb->tunable.log_latency_ms !=0) {                                 \
+                       if (l*1000 > ctdb->tunable.log_latency_ms) {                    \
+                               DEBUG(DEBUG_WARNING, ("High latency %.6fs for operation %s on database %s\n", l, operation, db->db_name));\
+                       }                                                               \
+               }                                                                       \
+       }
+
+
+
+
 /*
-  ctdb status information
+  ctdb statistics information
  */
 struct ctdb_statistics {
        uint32_t num_clients;
@@ -748,9 +798,6 @@ void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
 
 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);
@@ -1339,4 +1386,6 @@ int update_ip_assignment_tree(struct ctdb_context *ctdb,
 
 int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
 
+int ctdb_update_stat_counter(struct ctdb_context *ctdb, uint32_t *counter, uint32_t value);
+
 #endif
index 84a8c78e64b761d513f7caeddaceda2e4d1185b8..0bb7902dc3f54c01792b6d61cb109eebae1a01de 100644 (file)
@@ -463,9 +463,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                return;
        }
 
-       if (c->hopcount > ctdb->statistics.max_hop_count) {
-               ctdb->statistics.max_hop_count = c->hopcount;
-       }
+       CTDB_UPDATE_STAT(ctdb, max_hop_count, c->hopcount);
 
        /* if this nodes has done enough consecutive calls on the same record
           then give them the record
@@ -827,7 +825,7 @@ void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode)
        r->hdr.destnode  = destnode;
        r->hdr.reqid     = 0;
        
-       ctdb->statistics.keepalive_packets_sent++;
+       CTDB_INCREMENT_STAT(ctdb, keepalive_packets_sent);
 
        ctdb_queue_packet(ctdb, &r->hdr);
 
index bfb7bd1c29e6c7620b7b8b096d203b8f93256d97..6dd69f35fbb1144e49a988ff37026491cee38483 100644 (file)
@@ -461,7 +461,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 
        case CTDB_CONTROL_RECD_RECLOCK_LATENCY:
                CHECK_CONTROL_DATA_SIZE(sizeof(double));
-               ctdb_reclock_latency(ctdb, "recd reclock", &ctdb->statistics.reclock.recd, *((double *)indata.dptr));
+               CTDB_UPDATE_RECLOCK_LATENCY(ctdb, "recd reclock", reclock.recd, *((double *)indata.dptr));
                return 0;
        case CTDB_CONTROL_GET_RECLOCK_FILE:
                CHECK_CONTROL_DATA_SIZE(0);
@@ -720,7 +720,7 @@ static void ctdb_control_timeout(struct event_context *ev, struct timed_event *t
        struct ctdb_control_state *state = talloc_get_type(private_data, struct ctdb_control_state);
        TALLOC_CTX *tmp_ctx = talloc_new(ev);
 
-       state->ctdb->statistics.timeouts.control++;
+       CTDB_INCREMENT_STAT(state->ctdb, timeouts.control);
 
        talloc_steal(tmp_ctx, state);
 
index 418d91ed70efee7dc5fd42da14cd3bb97d23ee20..93d6b3acbb4dc281765d441176e8c6c960ab25cb 100644 (file)
@@ -97,7 +97,7 @@ static void block_signal(int signum)
  */
 static int daemon_queue_send(struct ctdb_client *client, struct ctdb_req_header *hdr)
 {
-       client->ctdb->statistics.client_packets_sent++;
+       CTDB_INCREMENT_STAT(client->ctdb, client_packets_sent);
        if (hdr->operation == CTDB_REQ_MESSAGE) {
                if (ctdb_queue_length(client->queue) > client->ctdb->tunable.max_queue_depth_drop_msg) {
                        DEBUG(DEBUG_ERR,("CTDB_REQ_MESSAGE queue full - killing client connection.\n"));
@@ -184,9 +184,7 @@ static int ctdb_client_destructor(struct ctdb_client *client)
 
        ctdb_takeover_client_destructor_hook(client);
        ctdb_reqid_remove(client->ctdb, client->client_id);
-       if (client->ctdb->statistics.num_clients) {
-               client->ctdb->statistics.num_clients--;
-       }
+       CTDB_DECREMENT_STAT(client->ctdb, num_clients);
 
        if (client->num_persistent_updates != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Client disconnecting with %u persistent updates in flight. Starting recovery\n", client->num_persistent_updates));
@@ -258,10 +256,9 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
        res = ctdb_daemon_call_recv(state, dstate->call);
        if (res != 0) {
                DEBUG(DEBUG_ERR, (__location__ " ctdbd_call_recv() returned error\n"));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       client->ctdb->statistics.pending_calls--;
-               }
-               ctdb_latency(ctdb_db, "call_from_client_cb 1", &client->ctdb->statistics.max_call_latency, dstate->start_time);
+               CTDB_DECREMENT_STAT(client->ctdb, pending_calls);
+
+               CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 1", max_call_latency, dstate->start_time);
                return;
        }
 
@@ -270,10 +267,8 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
                               length, struct ctdb_reply_call);
        if (r == NULL) {
                DEBUG(DEBUG_ERR, (__location__ " Failed to allocate reply_call in ctdb daemon\n"));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       client->ctdb->statistics.pending_calls--;
-               }
-               ctdb_latency(ctdb_db, "call_from_client_cb 2", &client->ctdb->statistics.max_call_latency, dstate->start_time);
+               CTDB_DECREMENT_STAT(client->ctdb, pending_calls);
+               CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 2", max_call_latency, dstate->start_time);
                return;
        }
        r->hdr.reqid        = dstate->reqid;
@@ -288,11 +283,9 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
        if (res != 0) {
                DEBUG(DEBUG_ERR, (__location__ " Failed to queue packet from daemon to client\n"));
        }
-       ctdb_latency(ctdb_db, "call_from_client_cb 3", &client->ctdb->statistics.max_call_latency, dstate->start_time);
+       CTDB_UPDATE_LATENCY(client->ctdb, ctdb_db, "call_from_client_cb 3", max_call_latency, dstate->start_time);
+       CTDB_DECREMENT_STAT(client->ctdb, pending_calls);
        talloc_free(dstate);
-       if (client->ctdb->statistics.pending_calls > 0) {
-               client->ctdb->statistics.pending_calls--;
-       }
 }
 
 struct ctdb_daemon_packet_wrap {
@@ -344,18 +337,14 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
        struct ctdb_context *ctdb = client->ctdb;
        struct ctdb_daemon_packet_wrap *w;
 
-       ctdb->statistics.total_calls++;
-       if (client->ctdb->statistics.pending_calls > 0) {
-               ctdb->statistics.pending_calls++;
-       }
+       CTDB_INCREMENT_STAT(ctdb, total_calls);
+       CTDB_DECREMENT_STAT(ctdb, pending_calls);
 
        ctdb_db = find_ctdb_db(client->ctdb, c->db_id);
        if (!ctdb_db) {
                DEBUG(DEBUG_ERR, (__location__ " Unknown database in request. db_id==0x%08x",
                          c->db_id));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       ctdb->statistics.pending_calls--;
-               }
+               CTDB_DECREMENT_STAT(ctdb, pending_calls);
                return;
        }
 
@@ -383,9 +372,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
                                           daemon_incoming_packet_wrap, w, True);
        if (ret == -2) {
                /* will retry later */
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       ctdb->statistics.pending_calls--;
-               }
+               CTDB_DECREMENT_STAT(ctdb, pending_calls);
                return;
        }
 
@@ -393,9 +380,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
 
        if (ret != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Unable to fetch record\n"));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       ctdb->statistics.pending_calls--;
-               }
+               CTDB_DECREMENT_STAT(ctdb, pending_calls);
                return;
        }
 
@@ -407,9 +392,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
                }
 
                DEBUG(DEBUG_ERR,(__location__ " Unable to allocate dstate\n"));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       ctdb->statistics.pending_calls--;
-               }
+               CTDB_DECREMENT_STAT(ctdb, pending_calls);
                return;
        }
        dstate->start_time = timeval_current();
@@ -425,10 +408,8 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
                }
 
                DEBUG(DEBUG_ERR,(__location__ " Unable to allocate call\n"));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       ctdb->statistics.pending_calls--;
-               }
-               ctdb_latency(ctdb_db, "call_from_client 1", &ctdb->statistics.max_call_latency, dstate->start_time);
+               CTDB_DECREMENT_STAT(ctdb, pending_calls);
+               CTDB_UPDATE_LATENCY(ctdb, ctdb_db, "call_from_client 1", max_call_latency, dstate->start_time);
                return;
        }
 
@@ -451,10 +432,8 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
 
        if (state == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " Unable to setup call send\n"));
-               if (client->ctdb->statistics.pending_calls > 0) {
-                       ctdb->statistics.pending_calls--;
-               }
-               ctdb_latency(ctdb_db, "call_from_client 2", &ctdb->statistics.max_call_latency, dstate->start_time);
+               CTDB_DECREMENT_STAT(ctdb, pending_calls);
+               CTDB_UPDATE_LATENCY(ctdb, ctdb_db, "call_from_client 2", max_call_latency, dstate->start_time);
                return;
        }
        talloc_steal(state, dstate);
@@ -494,17 +473,17 @@ static void daemon_incoming_packet(void *p, struct ctdb_req_header *hdr)
 
        switch (hdr->operation) {
        case CTDB_REQ_CALL:
-               ctdb->statistics.client.req_call++;
+               CTDB_INCREMENT_STAT(ctdb, client.req_call);
                daemon_request_call_from_client(client, (struct ctdb_req_call *)hdr);
                break;
 
        case CTDB_REQ_MESSAGE:
-               ctdb->statistics.client.req_message++;
+               CTDB_INCREMENT_STAT(ctdb, client.req_message);
                daemon_request_message_from_client(client, (struct ctdb_req_message *)hdr);
                break;
 
        case CTDB_REQ_CONTROL:
-               ctdb->statistics.client.req_control++;
+               CTDB_INCREMENT_STAT(ctdb, client.req_control);
                daemon_request_control_from_client(client, (struct ctdb_req_control *)hdr);
                break;
 
@@ -530,7 +509,7 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args)
                return;
        }
 
-       client->ctdb->statistics.client_packets_recv++;
+       CTDB_INCREMENT_STAT(client->ctdb, client_packets_recv);
 
        if (cnt < sizeof(*hdr)) {
                ctdb_set_error(client->ctdb, "Bad packet length %u in daemon\n", 
@@ -635,7 +614,7 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
 
        talloc_set_destructor(client, ctdb_client_destructor);
        talloc_set_destructor(client_pid, ctdb_clientpid_destructor);
-       ctdb->statistics.num_clients++;
+       CTDB_INCREMENT_STAT(ctdb, num_clients);
 }
 
 
index 9c96bfb4743f66a3ddb2479c79e7c58083eac2b6..9bbc25f9378b1d105bfadcdf0a4c18a934b58711 100644 (file)
@@ -53,8 +53,8 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
        key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize);
 
        talloc_set_destructor(h, NULL);
-       ctdb_latency(h->ctdb_db, "lockwait", &h->ctdb->statistics.max_lockwait_latency, h->start_time);
-       h->ctdb->statistics.pending_lockwait_calls--;
+       CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "lockwait", max_lockwait_latency, h->start_time);
+       CTDB_DECREMENT_STAT(h->ctdb, pending_lockwait_calls);
 
        /* the handle needs to go away when the context is gone - when
           the handle goes away this implicitly closes the pipe, which
@@ -77,7 +77,7 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
 
 static int lockwait_destructor(struct lockwait_handle *h)
 {
-       h->ctdb->statistics.pending_lockwait_calls--;
+       CTDB_DECREMENT_STAT(h->ctdb, pending_lockwait_calls);
        kill(h->child, SIGKILL);
        return 0;
 }
@@ -101,11 +101,11 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
        int ret;
        pid_t parent = getpid();
 
-       ctdb_db->ctdb->statistics.lockwait_calls++;
-       ctdb_db->ctdb->statistics.pending_lockwait_calls++;
+       CTDB_INCREMENT_STAT(ctdb_db->ctdb, lockwait_calls);
+       CTDB_INCREMENT_STAT(ctdb_db->ctdb, pending_lockwait_calls);
 
        if (!(result = talloc_zero(private_data, struct lockwait_handle))) {
-               ctdb_db->ctdb->statistics.pending_lockwait_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_lockwait_calls);
                return NULL;
        }
 
@@ -113,7 +113,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
 
        if (ret != 0) {
                talloc_free(result);
-               ctdb_db->ctdb->statistics.pending_lockwait_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_lockwait_calls);
                return NULL;
        }
 
@@ -123,7 +123,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
                close(result->fd[0]);
                close(result->fd[1]);
                talloc_free(result);
-               ctdb_db->ctdb->statistics.pending_lockwait_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_lockwait_calls);
                return NULL;
        }
 
@@ -158,7 +158,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
                                   (void *)result);
        if (result->fde == NULL) {
                talloc_free(result);
-               ctdb_db->ctdb->statistics.pending_lockwait_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_lockwait_calls);
                return NULL;
        }
        tevent_fd_set_auto_close(result->fde);
index dc05cbfa90b0c91e005d4cfe0a6f6528e40daf80..8672c5b3094b27d533166a4339b11875a92b3355 100644 (file)
@@ -455,7 +455,7 @@ struct childwrite_handle {
 
 static int childwrite_destructor(struct childwrite_handle *h)
 {
-       h->ctdb->statistics.pending_childwrite_calls--;
+       CTDB_DECREMENT_STAT(h->ctdb, pending_childwrite_calls);
        kill(h->child, SIGKILL);
        return 0;
 }
@@ -475,8 +475,8 @@ static void childwrite_handler(struct event_context *ev, struct fd_event *fde,
        int ret;
        char c;
 
-       ctdb_latency(h->ctdb_db, "persistent", &h->ctdb->statistics.max_childwrite_latency, h->start_time);
-       h->ctdb->statistics.pending_childwrite_calls--;
+       CTDB_UPDATE_LATENCY(h->ctdb, h->ctdb_db, "persistent", max_childwrite_latency, h->start_time);
+       CTDB_DECREMENT_STAT(h->ctdb, pending_childwrite_calls);
 
        /* the handle needs to go away when the context is gone - when
           the handle goes away this implicitly closes the pipe, which
@@ -508,11 +508,11 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
        int ret;
        pid_t parent = getpid();
 
-       ctdb_db->ctdb->statistics.childwrite_calls++;
-       ctdb_db->ctdb->statistics.pending_childwrite_calls++;
+       CTDB_INCREMENT_STAT(ctdb_db->ctdb, childwrite_calls);
+       CTDB_INCREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
 
        if (!(result = talloc_zero(state, struct childwrite_handle))) {
-               ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
                return NULL;
        }
 
@@ -520,7 +520,7 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
 
        if (ret != 0) {
                talloc_free(result);
-               ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
                return NULL;
        }
 
@@ -530,7 +530,7 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
                close(result->fd[0]);
                close(result->fd[1]);
                talloc_free(result);
-               ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
                return NULL;
        }
 
@@ -571,7 +571,7 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
                                   (void *)result);
        if (result->fde == NULL) {
                talloc_free(result);
-               ctdb_db->ctdb->statistics.pending_childwrite_calls--;
+               CTDB_DECREMENT_STAT(ctdb_db->ctdb, pending_childwrite_calls);
                return NULL;
        }
        tevent_fd_set_auto_close(result->fde);
index 81e2d4b2eb4d7b1a1e97d8b29d4139459613b1c4..111d7a98327f623700ab41f1b8d9610750e53ff9 100644 (file)
@@ -575,7 +575,7 @@ static int set_recmode_destructor(struct ctdb_set_recmode_state *state)
 {
        double l = timeval_elapsed(&state->start_time);
 
-       ctdb_reclock_latency(state->ctdb, "daemon reclock", &state->ctdb->statistics.reclock.ctdbd, l);
+       CTDB_UPDATE_RECLOCK_LATENCY(state->ctdb, "daemon reclock", reclock.ctdbd, l);
 
        if (state->fd[0] != -1) {
                state->fd[0] = -1;
@@ -938,7 +938,7 @@ static void ctdb_end_recovery_callback(struct ctdb_context *ctdb, int status, vo
        struct recovery_callback_state *state = talloc_get_type(p, struct recovery_callback_state);
 
        ctdb_enable_monitoring(ctdb);
-       ctdb->statistics.num_recoveries++;
+       CTDB_INCREMENT_STAT(ctdb, num_recoveries);
 
        if (status != 0) {
                DEBUG(DEBUG_ERR,(__location__ " recovered event script failed (status %d)\n", status));
index e4708eb41d26c1e97e0822e6c64c17e49724acf8..3aae28e33ed25b2702c403a35c64dd6100ff21fa 100644 (file)
@@ -367,47 +367,47 @@ void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 
        switch (hdr->operation) {
        case CTDB_REQ_CALL:
-               ctdb->statistics.node.req_call++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_call);
                ctdb_request_call(ctdb, hdr);
                break;
 
        case CTDB_REPLY_CALL:
-               ctdb->statistics.node.reply_call++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_call);
                ctdb_reply_call(ctdb, hdr);
                break;
 
        case CTDB_REPLY_ERROR:
-               ctdb->statistics.node.reply_error++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_error);
                ctdb_reply_error(ctdb, hdr);
                break;
 
        case CTDB_REQ_DMASTER:
-               ctdb->statistics.node.req_dmaster++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_dmaster);
                ctdb_request_dmaster(ctdb, hdr);
                break;
 
        case CTDB_REPLY_DMASTER:
-               ctdb->statistics.node.reply_dmaster++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_dmaster);
                ctdb_reply_dmaster(ctdb, hdr);
                break;
 
        case CTDB_REQ_MESSAGE:
-               ctdb->statistics.node.req_message++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_message);
                ctdb_request_message(ctdb, hdr);
                break;
 
        case CTDB_REQ_CONTROL:
-               ctdb->statistics.node.req_control++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_control);
                ctdb_request_control(ctdb, hdr);
                break;
 
        case CTDB_REPLY_CONTROL:
-               ctdb->statistics.node.reply_control++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_control);
                ctdb_reply_control(ctdb, hdr);
                break;
 
        case CTDB_REQ_KEEPALIVE:
-               ctdb->statistics.keepalive_packets_recv++;
+               CTDB_INCREMENT_STAT(ctdb, keepalive_packets_recv);
                break;
 
        default:
@@ -578,7 +578,7 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                return;
        }
 
-       ctdb->statistics.node_packets_sent++;
+       CTDB_INCREMENT_STAT(ctdb, node_packets_sent);
 
        if (!ctdb_validate_pnn(ctdb, hdr->destnode)) {
                DEBUG(DEBUG_CRIT,(__location__ " cant send to node %u that does not exist\n", 
index b30af7e2745d6a07e634349ce5baae9a3c5ee8eb..dcb16b227b2056301b012f571f09a8e1b5cec201 100644 (file)
@@ -236,7 +236,7 @@ static void ctdb_traverse_all_timeout(struct event_context *ev, struct timed_eve
        struct ctdb_traverse_all_handle *state = talloc_get_type(private_data, struct ctdb_traverse_all_handle);
 
        DEBUG(DEBUG_ERR,(__location__ " Traverse all timeout on database:%s\n", state->ctdb_db->db_name));
-       state->ctdb->statistics.timeouts.traverse++;
+       CTDB_INCREMENT_STAT(state->ctdb, timeouts.traverse);
 
        state->callback(state->private_data, tdb_null, tdb_null);
 }
index 674ebab6978a00712d7fefdf53828c31b854862b..f8647f0900d3ae08837836e5a0c2323e7844955d 100644 (file)
@@ -73,7 +73,7 @@ static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t len
 {
        struct ctdb_req_header *hdr = (struct ctdb_req_header *)data;
 
-       ctdb->statistics.node_packets_recv++;
+       CTDB_INCREMENT_STAT(ctdb, node_packets_recv);
 
        /* up the counter for this source node, so we know its alive */
        if (ctdb_validate_pnn(ctdb, hdr->srcnode)) {