Commit 4861c59c authored by marko's avatar marko

branches/zip: Fix two bugs in the relocation of block descriptors.

Improve diagnostics.

buf_buddy_relocate(): Do not assume all small blocks to contain only one
buf_page_t object.  Require an exact size match, as in the case of
compressed pages.

buf_relocate(): Relocate buf_pool->LRU_old if needed.
Validate the LRU list in debug builds.

buf_LRU_block_remove_hashed_page(): Do not overwrite FIL_PAGE_OFFSET
or FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID.  The memory will be invalidated
in debug builds of buf_buddy_free().

buf0buddy.c: Add assertions for not holding buf_pool->zip_mutex.
The calling thread should not be holding any block->mutex, but it might
be too time-consuming to assert against that, even #ifdef UNIV_SYNC_DEBUG.
parent 903ecf37
...@@ -102,6 +102,7 @@ buf_buddy_block_free( ...@@ -102,6 +102,7 @@ buf_buddy_block_free(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(buf == ut_align_down(buf, UNIV_PAGE_SIZE)); ut_a(buf == ut_align_down(buf, UNIV_PAGE_SIZE));
...@@ -130,6 +131,7 @@ buf_buddy_block_register( ...@@ -130,6 +131,7 @@ buf_buddy_block_register(
ulint fold; ulint fold;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
buf_block_set_state(block, BUF_BLOCK_MEMORY); buf_block_set_state(block, BUF_BLOCK_MEMORY);
...@@ -187,6 +189,7 @@ buf_buddy_alloc_clean( ...@@ -187,6 +189,7 @@ buf_buddy_alloc_clean(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
if (BUF_BUDDY_LOW << i >= PAGE_ZIP_MIN_SIZE if (BUF_BUDDY_LOW << i >= PAGE_ZIP_MIN_SIZE
...@@ -294,6 +297,7 @@ buf_buddy_alloc_low( ...@@ -294,6 +297,7 @@ buf_buddy_alloc_low(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
if (i < BUF_BUDDY_SIZES) { if (i < BUF_BUDDY_SIZES) {
...@@ -355,6 +359,7 @@ buf_buddy_relocate( ...@@ -355,6 +359,7 @@ buf_buddy_relocate(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(!ut_align_offset(src, size)); ut_ad(!ut_align_offset(src, size));
ut_ad(!ut_align_offset(dst, size)); ut_ad(!ut_align_offset(dst, size));
...@@ -418,7 +423,7 @@ buf_buddy_relocate( ...@@ -418,7 +423,7 @@ buf_buddy_relocate(
} }
mutex_exit(mutex); mutex_exit(mutex);
} else { } else if (i == buf_buddy_get_slot(sizeof(buf_page_t))) {
/* This must be a buf_page_t object. */ /* This must be a buf_page_t object. */
bpage = (buf_page_t*) src; bpage = (buf_page_t*) src;
...@@ -484,6 +489,7 @@ buf_buddy_free_low( ...@@ -484,6 +489,7 @@ buf_buddy_free_low(
buf_page_t* buddy; buf_page_t* buddy;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
recombine: recombine:
if (i == BUF_BUDDY_SIZES) { if (i == BUF_BUDDY_SIZES) {
......
...@@ -990,6 +990,12 @@ buf_relocate( ...@@ -990,6 +990,12 @@ buf_relocate(
UT_LIST_ADD_FIRST(LRU, buf_pool->LRU, dpage); UT_LIST_ADD_FIRST(LRU, buf_pool->LRU, dpage);
} }
if (UNIV_UNLIKELY(buf_pool->LRU_old == bpage)) {
buf_pool->LRU_old = dpage;
}
ut_d(UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU));
/* relocate buf_pool->page_hash */ /* relocate buf_pool->page_hash */
fold = buf_page_address_fold(bpage->space, bpage->offset); fold = buf_page_address_fold(bpage->space, bpage->offset);
......
...@@ -1094,9 +1094,6 @@ buf_LRU_block_remove_hashed_page( ...@@ -1094,9 +1094,6 @@ buf_LRU_block_remove_hashed_page(
ut_ad(!bpage->in_LRU_list); ut_ad(!bpage->in_LRU_list);
ut_a(bpage->zip.data); ut_a(bpage->zip.data);
ut_a(buf_page_get_zip_size(bpage)); ut_a(buf_page_get_zip_size(bpage));
memset(bpage->zip.data + FIL_PAGE_OFFSET, 0xff, 4);
memset(bpage->zip.data + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
0xff, 4);
UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); UT_LIST_REMOVE(list, buf_pool->zip_clean, 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