mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:34:14 +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_GC ((const char *)((ptrdiff_t)-1))
|
||||||
#define MDBX_PGWALK_META ((const char *)((ptrdiff_t)-2))
|
#define MDBX_PGWALK_META ((const char *)((ptrdiff_t)-2))
|
||||||
|
|
||||||
typedef int MDBX_pgvisitor_func(uint64_t pgno, unsigned number, void *ctx,
|
typedef int
|
||||||
int deep, const char *dbi, size_t page_size,
|
MDBX_pgvisitor_func(const uint64_t pgno, const unsigned number, void *const ctx,
|
||||||
MDBX_page_type_t type, size_t nentries,
|
const int deep, const char *const dbi,
|
||||||
size_t payload_bytes, size_t header_bytes,
|
const size_t page_size, const MDBX_page_type_t type,
|
||||||
size_t unused_bytes);
|
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,
|
LIBMDBX_API int mdbx_env_pgwalk(MDBX_txn *txn, MDBX_pgvisitor_func *visitor,
|
||||||
void *ctx);
|
void *ctx);
|
||||||
|
|
||||||
|
@ -252,11 +252,12 @@ static size_t problems_pop(struct problem *list) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pgvisitor(uint64_t pgno, unsigned pgnumber, void *ctx, int deep,
|
static int pgvisitor(const uint64_t pgno, const unsigned pgnumber,
|
||||||
const char *dbi_name_or_tag, size_t page_size,
|
void *const ctx, const int deep,
|
||||||
MDBX_page_type_t pagetype, size_t nentries,
|
const char *const dbi_name_or_tag, const size_t page_size,
|
||||||
size_t payload_bytes, size_t header_bytes,
|
const MDBX_page_type_t pagetype, const size_t nentries,
|
||||||
size_t unused_bytes) {
|
const size_t payload_bytes, const size_t header_bytes,
|
||||||
|
const size_t unused_bytes) {
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
if (deep > 42) {
|
if (deep > 42) {
|
||||||
problem_add("deep", deep, "too large", nullptr);
|
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;
|
bool already_used = false;
|
||||||
do {
|
for (unsigned n = 0; n < pgnumber; ++n) {
|
||||||
if (pgno >= lastpgno)
|
uint64_t spanpgno = pgno + n;
|
||||||
problem_add("page", pgno, "wrong page-no",
|
if (spanpgno >= lastpgno)
|
||||||
|
problem_add("page", spanpgno, "wrong page-no",
|
||||||
"%s-page: %" PRIu64 " > %" PRIu64 ", deep %i",
|
"%s-page: %" PRIu64 " > %" PRIu64 ", deep %i",
|
||||||
pagetype_caption, pgno, lastpgno, deep);
|
pagetype_caption, spanpgno, lastpgno, deep);
|
||||||
else if (walk.pagemap[pgno]) {
|
else if (walk.pagemap[spanpgno]) {
|
||||||
walk_dbi_t *coll_dbi = &walk.dbi[walk.pagemap[pgno] - 1];
|
walk_dbi_t *coll_dbi = &walk.dbi[walk.pagemap[spanpgno] - 1];
|
||||||
problem_add(
|
problem_add("page", spanpgno,
|
||||||
"page", pgno, (branch && coll_dbi == dbi) ? "loop" : "already used",
|
(branch && coll_dbi == dbi) ? "loop" : "already used",
|
||||||
"%s-page: by %s, deep %i", pagetype_caption, coll_dbi->name, deep);
|
"%s-page: by %s, deep %i", pagetype_caption, coll_dbi->name,
|
||||||
|
deep);
|
||||||
already_used = true;
|
already_used = true;
|
||||||
} else {
|
} else {
|
||||||
walk.pagemap[pgno] = (short)(dbi - walk.dbi + 1);
|
walk.pagemap[spanpgno] = (short)(dbi - walk.dbi + 1);
|
||||||
dbi->pages.total += 1;
|
dbi->pages.total += 1;
|
||||||
}
|
}
|
||||||
++pgno;
|
}
|
||||||
} while (--pgnumber);
|
|
||||||
|
|
||||||
if (already_used)
|
if (already_used)
|
||||||
return branch ? MDBX_RESULT_TRUE /* avoid infinite loop/recursion */
|
return branch ? MDBX_RESULT_TRUE /* avoid infinite loop/recursion */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user