From: Amitay Isaacs Date: Thu, 2 Apr 2015 02:53:09 +0000 (+1100) Subject: ctdb-daemon: Reset database statistics when resetting statistics X-Git-Tag: talloc-2.1.4~432 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7949ce103f2062aa703a24f72e11be96dc497a7a;p=thirdparty%2Fsamba.git ctdb-daemon: Reset database statistics when resetting statistics When the ctdb statistics is reset, reset per database statistics to keep it consistent with ctdb statistics. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index c172909ac15..1d919236630 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1446,6 +1446,8 @@ int ctdb_fetch_func(struct ctdb_call_info *call); int ctdb_fetch_with_header_func(struct ctdb_call_info *call); +void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db); + int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb, uint32_t db_id, TDB_DATA *outdata); diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index fda4c29134a..59b7d098671 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -151,8 +151,15 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, } case CTDB_CONTROL_STATISTICS_RESET: { + struct ctdb_db_context *ctdb_db; + CHECK_CONTROL_DATA_SIZE(0); ZERO_STRUCT(ctdb->statistics); + for (ctdb_db = ctdb->db_list; + ctdb_db != NULL; + ctdb_db = ctdb_db->next) { + ctdb_db_statistics_reset(ctdb_db); + } ctdb->statistics.statistics_start_time = timeval_current(); return 0; } diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c index 5357c6c7f16..ad61f1437d1 100644 --- a/ctdb/server/ctdb_ltdb_server.c +++ b/ctdb/server/ctdb_ltdb_server.c @@ -1600,6 +1600,20 @@ int ctdb_set_db_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_d return 0; } +void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db) +{ + struct ctdb_db_statistics *s = &ctdb_db->statistics; + int i; + + for (i=0; ihot_keys[i].key.dsize > 0) { + talloc_free(s->hot_keys[i].key.dptr); + } + } + + ZERO_STRUCT(ctdb_db->statistics); +} + int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb, uint32_t db_id, TDB_DATA *outdata)