mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:04:12 +08:00
mdbx-chk: fix space-usage statistics info.
Change-Id: I0cbbbc481f2e6dc37b29f6603ec1ead43b5d1864
This commit is contained in:
parent
05cf301774
commit
bbf8ef0a4b
11
mdbx.h
11
mdbx.h
@ -1670,11 +1670,12 @@ typedef enum {
|
||||
#define MDBX_PGWALK_GC ((const char *)((ptrdiff_t)-1))
|
||||
#define MDBX_PGWALK_META ((const char *)((ptrdiff_t)-2))
|
||||
|
||||
typedef int MDBX_pgvisitor_func(uint64_t pgno, unsigned number, void *ctx,
|
||||
int deep, const char *dbi, size_t page_size,
|
||||
MDBX_page_type_t type, size_t nentries,
|
||||
size_t payload_bytes, size_t header_bytes,
|
||||
size_t unused_bytes);
|
||||
typedef int
|
||||
MDBX_pgvisitor_func(const uint64_t pgno, const unsigned number, void *const ctx,
|
||||
const int deep, const char *const dbi,
|
||||
const size_t page_size, const MDBX_page_type_t type,
|
||||
const size_t nentries, const size_t payload_bytes,
|
||||
const size_t header_bytes, const size_t unused_bytes);
|
||||
LIBMDBX_API int mdbx_env_pgwalk(MDBX_txn *txn, MDBX_pgvisitor_func *visitor,
|
||||
void *ctx);
|
||||
|
||||
|
@ -252,11 +252,12 @@ static size_t problems_pop(struct problem *list) {
|
||||
return count;
|
||||
}
|
||||
|
||||
static int pgvisitor(uint64_t pgno, unsigned pgnumber, void *ctx, int deep,
|
||||
const char *dbi_name_or_tag, size_t page_size,
|
||||
MDBX_page_type_t pagetype, size_t nentries,
|
||||
size_t payload_bytes, size_t header_bytes,
|
||||
size_t unused_bytes) {
|
||||
static int pgvisitor(const uint64_t pgno, const unsigned pgnumber,
|
||||
void *const ctx, const int deep,
|
||||
const char *const dbi_name_or_tag, const size_t page_size,
|
||||
const MDBX_page_type_t pagetype, const size_t nentries,
|
||||
const size_t payload_bytes, const size_t header_bytes,
|
||||
const size_t unused_bytes) {
|
||||
(void)ctx;
|
||||
if (deep > 42) {
|
||||
problem_add("deep", deep, "too large", nullptr);
|
||||
@ -326,23 +327,24 @@ static int pgvisitor(uint64_t pgno, unsigned pgnumber, void *ctx, int deep,
|
||||
}
|
||||
|
||||
bool already_used = false;
|
||||
do {
|
||||
if (pgno >= lastpgno)
|
||||
problem_add("page", pgno, "wrong page-no",
|
||||
for (unsigned n = 0; n < pgnumber; ++n) {
|
||||
uint64_t spanpgno = pgno + n;
|
||||
if (spanpgno >= lastpgno)
|
||||
problem_add("page", spanpgno, "wrong page-no",
|
||||
"%s-page: %" PRIu64 " > %" PRIu64 ", deep %i",
|
||||
pagetype_caption, pgno, lastpgno, deep);
|
||||
else if (walk.pagemap[pgno]) {
|
||||
walk_dbi_t *coll_dbi = &walk.dbi[walk.pagemap[pgno] - 1];
|
||||
problem_add(
|
||||
"page", pgno, (branch && coll_dbi == dbi) ? "loop" : "already used",
|
||||
"%s-page: by %s, deep %i", pagetype_caption, coll_dbi->name, deep);
|
||||
pagetype_caption, spanpgno, lastpgno, deep);
|
||||
else if (walk.pagemap[spanpgno]) {
|
||||
walk_dbi_t *coll_dbi = &walk.dbi[walk.pagemap[spanpgno] - 1];
|
||||
problem_add("page", spanpgno,
|
||||
(branch && coll_dbi == dbi) ? "loop" : "already used",
|
||||
"%s-page: by %s, deep %i", pagetype_caption, coll_dbi->name,
|
||||
deep);
|
||||
already_used = true;
|
||||
} else {
|
||||
walk.pagemap[pgno] = (short)(dbi - walk.dbi + 1);
|
||||
walk.pagemap[spanpgno] = (short)(dbi - walk.dbi + 1);
|
||||
dbi->pages.total += 1;
|
||||
}
|
||||
++pgno;
|
||||
} while (--pgnumber);
|
||||
}
|
||||
|
||||
if (already_used)
|
||||
return branch ? MDBX_RESULT_TRUE /* avoid infinite loop/recursion */
|
||||
|
Loading…
x
Reference in New Issue
Block a user