diff options
author | Amitay Isaacs <amitay@gmail.com> | 2013-07-15 14:52:07 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-07-29 16:00:46 +1000 |
commit | 854216236b398ba85cdd7b555f5ecd1b9cfdf87f (patch) | |
tree | 34c00beaf49158d566e4b77a1bf4dbd8bf7007eb /ctdb/server | |
parent | e14fa509416a5ea86d2309b1b64315c483ecf17a (diff) | |
download | samba-854216236b398ba85cdd7b555f5ecd1b9cfdf87f.tar.gz samba-854216236b398ba85cdd7b555f5ecd1b9cfdf87f.tar.xz samba-854216236b398ba85cdd7b555f5ecd1b9cfdf87f.zip |
Revert "ctdbd: Remove incomplete ctdb_db_statistics_wire structure"
The structure cannot be removed without adding support for marshalling keys
for hot records.
This reverts commit 26a4653df594d351ca0dc1bd5f5b2f5b0eb0a9a5.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 023ca2e84f5ed064a288526b9c2bc7e06674dd81)
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/ctdb_control.c | 15 | ||||
-rw-r--r-- | ctdb/server/ctdb_ltdb_server.c | 52 |
2 files changed, 55 insertions, 12 deletions
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 690608eef6..a8771f3176 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -651,18 +651,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, CHECK_CONTROL_DATA_SIZE(size); return ctdb_control_schedule_for_deletion(ctdb, indata); } - case CTDB_CONTROL_GET_DB_STATISTICS: { - uint32_t db_id; - struct ctdb_db_context *ctdb_db; - - CHECK_CONTROL_DATA_SIZE(sizeof(db_id)); - db_id = *(uint32_t *)indata.dptr; - ctdb_db = find_ctdb_db(ctdb, db_id); - if (ctdb_db == NULL) return -1; - outdata->dptr = (uint8_t *)&ctdb_db->statistics; - outdata->dsize = sizeof(ctdb_db->statistics); - return 0; - } + case CTDB_CONTROL_GET_DB_STATISTICS: + CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); + return ctdb_control_get_db_statistics(ctdb, *(uint32_t *)indata.dptr, outdata); case CTDB_CONTROL_RELOAD_PUBLIC_IPS: CHECK_CONTROL_DATA_SIZE(0); diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c index 57e0d68b71..6ad1ff5de1 100644 --- a/ctdb/server/ctdb_ltdb_server.c +++ b/ctdb/server/ctdb_ltdb_server.c @@ -1502,3 +1502,55 @@ int ctdb_set_db_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_d return 0; } + +int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb, + uint32_t db_id, + TDB_DATA *outdata) +{ + struct ctdb_db_context *ctdb_db; + struct ctdb_db_statistics_wire *stats; + int i; + int len; + char *ptr; + + ctdb_db = find_ctdb_db(ctdb, db_id); + if (!ctdb_db) { + DEBUG(DEBUG_ERR,("Unknown db_id 0x%x in get_db_statistics\n", db_id)); + return -1; + } + + len = offsetof(struct ctdb_db_statistics_wire, hot_keys); + for (i = 0; i < MAX_HOT_KEYS; i++) { + len += 8 + ctdb_db->statistics.hot_keys[i].key.dsize; + } + + stats = talloc_size(outdata, len); + if (stats == NULL) { + DEBUG(DEBUG_ERR,("Failed to allocate db statistics wire structure\n")); + return -1; + } + + stats->db_ro_delegations = ctdb_db->statistics.db_ro_delegations; + stats->db_ro_revokes = ctdb_db->statistics.db_ro_revokes; + for (i = 0; i < MAX_COUNT_BUCKETS; i++) { + stats->hop_count_bucket[i] = ctdb_db->statistics.hop_count_bucket[i]; + } + stats->num_hot_keys = MAX_HOT_KEYS; + + ptr = &stats->hot_keys[0]; + for (i = 0; i < MAX_HOT_KEYS; i++) { + *(uint32_t *)ptr = ctdb_db->statistics.hot_keys[i].count; + ptr += 4; + + *(uint32_t *)ptr = ctdb_db->statistics.hot_keys[i].key.dsize; + ptr += 4; + + memcpy(ptr, ctdb_db->statistics.hot_keys[i].key.dptr, ctdb_db->statistics.hot_keys[i].key.dsize); + ptr += ctdb_db->statistics.hot_keys[i].key.dsize; + } + + outdata->dptr = (uint8_t *)stats; + outdata->dsize = len; + + return 0; +} |