From f7d8812e6cdaf265ebb20a0f2e25536d431264ab Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 2 Sep 2015 17:53:48 +0300 Subject: [PATCH] lmdb: n-entries info from b-tree traversal in mdb_chk. Change-Id: Ic9343dcdba976ac51c8f5776d2f7c9fed59da8e0 --- lmdb.h | 2 +- mdb.c | 12 ++++++------ mdb_chk.c | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lmdb.h b/lmdb.h index e451f29e..74ab55b2 100644 --- a/lmdb.h +++ b/lmdb.h @@ -1659,7 +1659,7 @@ typedef void MDB_debug_func(int type, const char *function, int line, int mdb_setup_debug(int flags, MDB_debug_func* logger, long edge_txn); typedef int MDB_pgvisitor_func(size_t pgno, unsigned pgnumber, void* ctx, - const char* dbi, const char *type, + const char* dbi, const char *type, int nentries, int payload_bytes, int header_bytes, int unused_bytes); int mdb_env_pgwalk(MDB_txn *txn, MDB_pgvisitor_func* visitor, void* ctx); diff --git a/mdb.c b/mdb.c index c6e7aa06..fa864723 100644 --- a/mdb.c +++ b/mdb.c @@ -9895,8 +9895,8 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee over_unused = omp->mp_pages * ctx->mw_txn->mt_env->me_psize - over_payload - over_header; - rc = ctx->mw_visitor(*opg, omp->mp_pages, ctx->mw_user, dbi, "overflow-data", - over_payload, over_header, over_unused); + rc = ctx->mw_visitor(*opg, omp->mp_pages, ctx->mw_user, dbi, + "overflow-data", 1, over_payload, over_header, over_unused); if (rc) return rc; continue; @@ -9922,8 +9922,8 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee } } - return ctx->mw_visitor(mp->mp_p.p_pgno, 1, ctx->mw_user, dbi, - type, payload_size, header_size, unused_size + align_bytes); + return ctx->mw_visitor(mp->mp_p.p_pgno, 1, ctx->mw_user, dbi, type, + nkeys, payload_size, header_size, unused_size + align_bytes); } int ESECT @@ -9936,14 +9936,14 @@ mdb_env_pgwalk(MDB_txn *txn, MDB_pgvisitor_func* visitor, void* user) ctx.mw_user = user; ctx.mw_visitor = visitor; - rc = visitor(0, 2, user, "lmdb", "meta", sizeof(MDB_meta)*2, PAGEHDRSZ*2, + rc = visitor(0, 2, user, "lmdb", "meta", 2, sizeof(MDB_meta)*2, PAGEHDRSZ*2, (txn->mt_env->me_psize - sizeof(MDB_meta) - PAGEHDRSZ) *2); if (! rc && txn->mt_dbs[FREE_DBI].md_root != P_INVALID) rc = mdb_env_walk(&ctx, "free", txn->mt_dbs[FREE_DBI].md_root, 0, 0); if (! rc && txn->mt_dbs[MAIN_DBI].md_root != P_INVALID) rc = mdb_env_walk(&ctx, "main", txn->mt_dbs[MAIN_DBI].md_root, 0, 0); if (! rc) - rc = visitor(P_INVALID, 0, user, NULL, NULL, -1, 0, 0); + rc = visitor(P_INVALID, 0, user, NULL, NULL, 0, 0, 0, 0); return rc; } diff --git a/mdb_chk.c b/mdb_chk.c index 982178d8..5ef27faa 100644 --- a/mdb_chk.c +++ b/mdb_chk.c @@ -211,7 +211,7 @@ static size_t problems_pop(struct problem* list) { } static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi, - const char* type, int payload_bytes, int header_bytes, int unused_bytes) + const char* type, int nentries, int payload_bytes, int header_bytes, int unused_bytes) { if (type) { size_t page_bytes = payload_bytes + header_bytes + unused_bytes; @@ -236,8 +236,9 @@ static int pgvisitor(size_t pgno, unsigned pgnumber, void* ctx, const char* dbi, if (header_bytes < sizeof(long) || header_bytes >= stat.ms_psize - sizeof(long)) problem_add(pgno, "illegal header-length", "%zu < %i < %zu", sizeof(long), header_bytes, stat.ms_psize - sizeof(long)); - else if (payload_bytes < 1) { - problem_add(pgno, "empty page", "payload %i bytes", payload_bytes); + if (payload_bytes < 1 || nentries < 1) { + problem_add(pgno, "empty page", "payload %i bytes, %i entries", + payload_bytes, nentries); walk.dbi_empty_pages[index] += 1; }