1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

tdb2: add stats to tdb1 backend.

It's actually quite a good fit; we use compare_wrong_bucket for dead
records, which is kind of correct (they should be in the free list).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit a3e4ebff2eb9dc2e386160b8acf77d70236f4def)
This commit is contained in:
Rusty Russell 2011-09-14 08:10:13 +09:30
parent b30bb0ed90
commit 26f3587d4b
4 changed files with 26 additions and 5 deletions

View File

@ -83,6 +83,7 @@ int tdb1_free(struct tdb_context *tdb, tdb1_off_t offset, struct tdb1_record *re
goto fail;
}
tdb->stats.alloc_coalesce_tried++;
/* Look left */
if (offset - sizeof(tdb1_off_t) > TDB1_DATA_START(tdb->tdb1.header.hash_size)) {
tdb1_off_t left = offset - sizeof(tdb1_off_t);
@ -131,6 +132,9 @@ int tdb1_free(struct tdb_context *tdb, tdb1_off_t offset, struct tdb1_record *re
"tdb1_free: update_tailer failed at %u", offset);
goto fail;
}
tdb->stats.alloc_coalesce_succeeded++;
tdb->stats.alloc_coalesce_num_merged++;
tdb->stats.frees++;
tdb1_unlock(tdb, -1, F_WRLCK);
return 0;
}
@ -151,6 +155,7 @@ update:
}
/* And we're done. */
tdb->stats.frees++;
tdb1_unlock(tdb, -1, F_WRLCK);
return 0;
@ -188,6 +193,7 @@ static tdb1_off_t tdb1_allocate_ofs(struct tdb_context *tdb,
if (tdb1_rec_write(tdb, rec_ptr, rec) == -1) {
return 0;
}
tdb->stats.allocs++;
return rec_ptr;
}
@ -215,6 +221,8 @@ static tdb1_off_t tdb1_allocate_ofs(struct tdb_context *tdb,
return 0;
}
tdb->stats.allocs++;
tdb->stats.alloc_leftover++;
return rec_ptr;
}

View File

@ -307,6 +307,7 @@ static int tdb1_expand_file(struct tdb_context *tdb, tdb1_off_t size, tdb1_off_t
addition -= written;
size += written;
}
tdb->stats.expands++;
return 0;
}

View File

@ -89,11 +89,18 @@ static tdb1_off_t tdb1_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash
if (tdb1_rec_read(tdb, rec_ptr, r) == -1)
return 0;
if (!TDB1_DEAD(r) && hash==r->full_hash
&& key.dsize==r->key_len
&& tdb1_parse_data(tdb, key, rec_ptr + sizeof(*r),
r->key_len, tdb1_key_compare,
NULL) == 0) {
tdb->stats.compares++;
if (TDB1_DEAD(r)) {
tdb->stats.compare_wrong_bucket++;
} else if (key.dsize != r->key_len) {
tdb->stats.compare_wrong_keylen++;
} else if (hash != r->full_hash) {
tdb->stats.compare_wrong_rechash++;
} else if (tdb1_parse_data(tdb, key, rec_ptr + sizeof(*r),
r->key_len, tdb1_key_compare,
NULL) != 0) {
tdb->stats.compare_wrong_keycmp++;
} else {
return rec_ptr;
}
/* detect tight infinite loop */

View File

@ -432,6 +432,7 @@ static int _tdb1_transaction_start(struct tdb_context *tdb)
tdb->last_error = TDB_ERR_EINVAL;
return -1;
}
tdb->stats.transaction_nest++;
tdb->tdb1.transaction->nesting++;
return 0;
}
@ -511,6 +512,7 @@ static int _tdb1_transaction_start(struct tdb_context *tdb)
tdb->tdb1.transaction->io_methods = tdb->tdb1.io;
tdb->tdb1.io = &transaction1_methods;
tdb->stats.transactions++;
return 0;
fail:
@ -621,6 +623,7 @@ static int _tdb1_transaction_cancel(struct tdb_context *tdb)
*/
int tdb1_transaction_cancel(struct tdb_context *tdb)
{
tdb->stats.transaction_cancel++;
return _tdb1_transaction_cancel(tdb);
}
@ -739,6 +742,7 @@ static int tdb1_recovery_allocate(struct tdb_context *tdb,
" failed to create recovery area");
return -1;
}
tdb->stats.transaction_expand_file++;
/* remap the file (if using mmap) */
methods->tdb1_oob(tdb, tdb->file->map_size + 1, 1);
@ -1000,6 +1004,7 @@ static int _tdb1_transaction_prepare_commit(struct tdb_context *tdb)
" expansion failed");
return -1;
}
tdb->stats.transaction_expand_file++;
tdb->file->map_size = tdb->tdb1.transaction->old_map_size;
methods->tdb1_oob(tdb, tdb->file->map_size + 1, 1);
}