Commit 8e99a4d7 authored by Yoni Fogel's avatar Yoni Fogel

Refs Tokutek/ft-index#46 Finish verify (find purpose). Restore old verify_in_mempool functionality

parent 3b923630
...@@ -530,9 +530,32 @@ uint64_t bn_data::get_disk_size() { ...@@ -530,9 +530,32 @@ uint64_t bn_data::get_disk_size() {
toku_mempool_get_used_space(&m_buffer_mempool); toku_mempool_get_used_space(&m_buffer_mempool);
} }
struct verify_le_in_mempool_state {
size_t offset_limit;
class bn_data *bd;
};
static int verify_le_in_mempool (const uint32_t, klpair_struct *klpair, const uint32_t idx UU(), struct verify_le_in_mempool_state * const state) {
invariant(klpair->le_offset < state->offset_limit);
LEAFENTRY le = state->bd->get_le_from_klpair(klpair);
uint32_t size = leafentry_memsize(le);
size_t end_offset = klpair->le_offset+size;
invariant(end_offset <= state->offset_limit);
return 0;
}
//This is a debug-only (paranoid) verification.
//Verifies the omt is valid, and all leafentries are entirely in the mempool's memory.
void bn_data::verify_mempool(void) { void bn_data::verify_mempool(void) {
// TODO: implement something //Verify the omt itself <- paranoid and slow
// TODO: check 7.0 code and see if there was anything there? m_buffer.verify();
verify_le_in_mempool_state state = { .offset_limit = toku_mempool_get_offset_limit(&m_buffer_mempool), .bd = this };
//Verify every leafentry pointed to by the keys in the dmt are fully inside the mempool
m_buffer.iterate_ptr< decltype(state), verify_le_in_mempool >(&state);
} }
uint32_t bn_data::omt_size(void) const { uint32_t bn_data::omt_size(void) const {
......
...@@ -430,7 +430,6 @@ int dmt<dmtdata_t, dmtdataout_t>::iterate_on_range(const uint32_t left, const ui ...@@ -430,7 +430,6 @@ int dmt<dmtdata_t, dmtdataout_t>::iterate_on_range(const uint32_t left, const ui
return this->iterate_internal<iterate_extra_t, f>(left, right, this->d.t.root, 0, iterate_extra); return this->iterate_internal<iterate_extra_t, f>(left, right, this->d.t.root, 0, iterate_extra);
} }
//TODO(yoni) determine where this is used and if it should crash or return an error on bad verify
template<typename dmtdata_t, typename dmtdataout_t> template<typename dmtdata_t, typename dmtdataout_t>
void dmt<dmtdata_t, dmtdataout_t>::verify(void) const { void dmt<dmtdata_t, dmtdataout_t>::verify(void) const {
uint32_t num_values = this->size(); uint32_t num_values = this->size();
......
...@@ -194,6 +194,10 @@ void* toku_mempool_get_next_free_ptr(const struct mempool *mp) { ...@@ -194,6 +194,10 @@ void* toku_mempool_get_next_free_ptr(const struct mempool *mp) {
return toku_mempool_get_pointer_from_base_and_offset(mp, mp->free_offset); return toku_mempool_get_pointer_from_base_and_offset(mp, mp->free_offset);
} }
size_t toku_mempool_get_offset_limit(const struct mempool *mp) {
return mp->free_offset;
}
size_t toku_mempool_get_free_space(const struct mempool *mp) { size_t toku_mempool_get_free_space(const struct mempool *mp) {
return mp->size - mp->free_offset; return mp->size - mp->free_offset;
} }
......
...@@ -146,6 +146,9 @@ size_t toku_mempool_get_offset_from_pointer_and_base(const struct mempool *mp, c ...@@ -146,6 +146,9 @@ size_t toku_mempool_get_offset_from_pointer_and_base(const struct mempool *mp, c
/* get the a pointer of the first free byte (if any) */ /* get the a pointer of the first free byte (if any) */
void* toku_mempool_get_next_free_ptr(const struct mempool *mp); void* toku_mempool_get_next_free_ptr(const struct mempool *mp);
/* get the limit of valid offsets. (anything later was not allocated) */
size_t toku_mempool_get_offset_limit(const struct mempool *mp);
/* get the size of the memory pool */ /* get the size of the memory pool */
size_t toku_mempool_get_size(const struct mempool *mp); size_t toku_mempool_get_size(const struct mempool *mp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment