Commit ae0ecb11 authored by marko's avatar marko

branches/zip: buf_page_t: Add the in_page_hash and in_zip_hash

for extra validation in UNIV_DEBUG builds.
parent 87defea2
......@@ -164,6 +164,9 @@ buf_buddy_block_free(
((buf_block_t*) bpage)->frame == buf);
ut_a(bpage);
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY);
ut_ad(!bpage->in_page_hash);
ut_ad(bpage->in_zip_hash);
ut_d(bpage->in_zip_hash = FALSE);
HASH_DELETE(buf_page_t, hash, buf_pool->zip_hash, fold, bpage);
ut_d(memset(buf, 0, UNIV_PAGE_SIZE));
......@@ -192,6 +195,9 @@ buf_buddy_block_register(
ut_a(block->frame);
ut_a(!ut_align_offset(block->frame, UNIV_PAGE_SIZE));
ut_ad(!block->page.in_page_hash);
ut_ad(!block->page.in_zip_hash);
ut_d(block->page.in_zip_hash = TRUE);
HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page);
}
......
......@@ -614,6 +614,8 @@ buf_block_init(
block->index = NULL;
#ifdef UNIV_DEBUG
block->page.in_page_hash = FALSE;
block->page.in_zip_hash = FALSE;
block->page.in_flush_list = FALSE;
block->page.in_free_list = FALSE;
block->page.in_LRU_list = FALSE;
......@@ -973,10 +975,16 @@ buf_relocate(
ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE);
ut_a(bpage->buf_fix_count == 0);
ut_a(buf_page_in_file(bpage));
ut_ad(bpage->in_LRU_list);
ut_ad(!bpage->in_zip_hash);
ut_ad(bpage->in_page_hash);
ut_ad(bpage == buf_page_hash_get(bpage->space, bpage->offset));
memcpy(dpage, bpage, sizeof *dpage);
ut_d(bpage->in_LRU_list = FALSE);
ut_d(bpage->in_page_hash = FALSE);
/* relocate buf_pool->LRU */
b = UT_LIST_GET_PREV(LRU, bpage);
UT_LIST_REMOVE(LRU, buf_pool->LRU, bpage);
......@@ -1192,6 +1200,9 @@ buf_pool_page_hash_rebuild(void)
for (j = 0; j < chunk->size; j++, block++) {
if (buf_block_get_state(block)
== BUF_BLOCK_FILE_PAGE) {
ut_ad(!block->page.in_zip_hash);
ut_ad(block->page.in_page_hash);
HASH_INSERT(buf_page_t, hash, page_hash,
buf_page_address_fold(
block->page.space,
......@@ -1209,6 +1220,9 @@ buf_pool_page_hash_rebuild(void)
b = UT_LIST_GET_NEXT(list, b)) {
ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE);
ut_ad(!b->in_flush_list);
ut_ad(b->in_LRU_list);
ut_ad(b->in_page_hash);
ut_ad(!b->in_zip_hash);
HASH_INSERT(buf_page_t, hash, page_hash,
buf_page_address_fold(b->space, b->offset), b);
......@@ -1217,6 +1231,9 @@ buf_pool_page_hash_rebuild(void)
for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
b = UT_LIST_GET_NEXT(list, b)) {
ut_ad(b->in_flush_list);
ut_ad(b->in_LRU_list);
ut_ad(b->in_page_hash);
ut_ad(!b->in_zip_hash);
switch (buf_page_get_state(b)) {
case BUF_BLOCK_ZIP_DIRTY:
......@@ -2107,6 +2124,9 @@ buf_page_init(
ut_error;
}
ut_ad(!block->page.in_zip_hash);
ut_ad(!block->page.in_page_hash);
ut_d(block->page.in_page_hash = TRUE);
HASH_INSERT(buf_page_t, hash, buf_pool->page_hash,
buf_page_address_fold(space, offset), &block->page);
......
......@@ -65,6 +65,9 @@ buf_flush_insert_into_flush_list(
/* fall through */
case BUF_BLOCK_ZIP_DIRTY:
case BUF_BLOCK_FILE_PAGE:
ut_ad(bpage->in_LRU_list);
ut_ad(bpage->in_page_hash);
ut_ad(!bpage->in_zip_hash);
ut_ad(!bpage->in_flush_list);
ut_d(bpage->in_flush_list = TRUE);
UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage);
......@@ -107,6 +110,11 @@ buf_flush_insert_sorted_into_flush_list(
/* fall through */
case BUF_BLOCK_ZIP_DIRTY:
case BUF_BLOCK_FILE_PAGE:
ut_ad(bpage->in_LRU_list);
ut_ad(bpage->in_page_hash);
ut_ad(!bpage->in_zip_hash);
ut_ad(!bpage->in_flush_list);
ut_d(bpage->in_flush_list = TRUE);
break;
case BUF_BLOCK_ZIP_FREE:
case BUF_BLOCK_NOT_USED:
......@@ -126,9 +134,6 @@ buf_flush_insert_sorted_into_flush_list(
b = UT_LIST_GET_NEXT(list, b);
}
ut_ad(!bpage->in_flush_list);
ut_d(bpage->in_flush_list = TRUE);
if (prev_b == NULL) {
UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage);
} else {
......
......@@ -956,6 +956,9 @@ buf_LRU_free_block(
UNIV_MEM_DESC(b->zip.data,
page_zip_get_size(&b->zip), b);
ut_ad(!b->in_zip_hash);
ut_ad(!b->in_page_hash);
ut_d(b->in_page_hash = TRUE);
HASH_INSERT(buf_page_t, hash,
buf_pool->page_hash, fold, b);
......@@ -1214,6 +1217,9 @@ buf_LRU_block_remove_hashed_page(
ut_error;
}
ut_ad(!bpage->in_zip_hash);
ut_ad(bpage->in_page_hash);
ut_d(bpage->in_page_hash = FALSE);
HASH_DELETE(buf_page_t, hash, buf_pool->page_hash,
buf_page_address_fold(bpage->space, bpage->offset),
bpage);
......
......@@ -968,6 +968,10 @@ struct buf_page_struct{
buf_page_t* hash; /* node used in chaining to
buf_pool->page_hash or
buf_pool->zip_hash */
#ifdef UNIV_DEBUG
ibool in_page_hash; /* TRUE if in buf_pool->page_hash */
ibool in_zip_hash; /* TRUE if in buf_pool->zip_hash */
#endif /* UNIV_DEBUG */
/* 2. Page flushing fields; protected by buf_pool->mutex */
......
......@@ -878,6 +878,8 @@ buf_page_hash_get(
HASH_SEARCH(hash, buf_pool->page_hash, fold, bpage,
bpage->space == space && bpage->offset == offset);
ut_a(!bpage || buf_page_in_file(bpage));
ut_ad(!bpage || bpage->in_page_hash);
ut_ad(!bpage || !bpage->in_zip_hash);
return(bpage);
}
......
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