Commit 54b69cac authored by Vadim Tkachenko's avatar Vadim Tkachenko

disable split_buffer_pool_mutex

parent 8bda156a
...@@ -3733,8 +3733,7 @@ btr_blob_free( ...@@ -3733,8 +3733,7 @@ btr_blob_free(
mtr_commit(mtr); mtr_commit(mtr);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
/* Only free the block if it is still allocated to /* Only free the block if it is still allocated to
...@@ -3745,22 +3744,17 @@ btr_blob_free( ...@@ -3745,22 +3744,17 @@ btr_blob_free(
&& buf_block_get_space(block) == space && buf_block_get_space(block) == space
&& buf_block_get_page_no(block) == page_no) { && buf_block_get_page_no(block) == page_no) {
if (buf_LRU_free_block(&block->page, all, NULL, TRUE) if (buf_LRU_free_block(&block->page, all, NULL)
!= BUF_LRU_FREED != BUF_LRU_FREED
&& all && block->page.zip.data && all && block->page.zip.data) {
/* Now, buf_LRU_free_block() may release mutex temporarily */
&& buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE
&& buf_block_get_space(block) == space
&& buf_block_get_page_no(block) == page_no) {
/* Attempt to deallocate the uncompressed page /* Attempt to deallocate the uncompressed page
if the whole block cannot be deallocted. */ if the whole block cannot be deallocted. */
buf_LRU_free_block(&block->page, FALSE, NULL, TRUE); buf_LRU_free_block(&block->page, FALSE, NULL);
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
} }
......
...@@ -1731,8 +1731,7 @@ btr_search_validate(void) ...@@ -1731,8 +1731,7 @@ btr_search_validate(void)
rec_offs_init(offsets_); rec_offs_init(offsets_);
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_x_lock(&page_hash_latch);
cell_count = hash_get_n_cells(btr_search_sys->hash_index); cell_count = hash_get_n_cells(btr_search_sys->hash_index);
...@@ -1740,13 +1739,11 @@ btr_search_validate(void) ...@@ -1740,13 +1739,11 @@ btr_search_validate(void)
/* We release btr_search_latch every once in a while to /* We release btr_search_latch every once in a while to
give other queries a chance to run. */ give other queries a chance to run. */
if ((i != 0) && ((i % chunk_size) == 0)) { if ((i != 0) && ((i % chunk_size) == 0)) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
os_thread_yield(); os_thread_yield();
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_x_lock(&page_hash_latch);
} }
node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node; node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node;
...@@ -1853,13 +1850,11 @@ btr_search_validate(void) ...@@ -1853,13 +1850,11 @@ btr_search_validate(void)
/* We release btr_search_latch every once in a while to /* We release btr_search_latch every once in a while to
give other queries a chance to run. */ give other queries a chance to run. */
if (i != 0) { if (i != 0) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
os_thread_yield(); os_thread_yield();
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_x_lock(&page_hash_latch);
} }
if (!ha_validate(btr_search_sys->hash_index, i, end_index)) { if (!ha_validate(btr_search_sys->hash_index, i, end_index)) {
...@@ -1867,8 +1862,7 @@ btr_search_validate(void) ...@@ -1867,8 +1862,7 @@ btr_search_validate(void)
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
......
...@@ -131,15 +131,14 @@ buf_buddy_alloc_zip( ...@@ -131,15 +131,14 @@ buf_buddy_alloc_zip(
{ {
buf_page_t* bpage; buf_page_t* bpage;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
ut_a(i < BUF_BUDDY_SIZES); ut_a(i < BUF_BUDDY_SIZES);
#if defined UNIV_DEBUG && !defined UNIV_DEBUG_VALGRIND #if defined UNIV_DEBUG && !defined UNIV_DEBUG_VALGRIND
/* Valgrind would complain about accessing free memory. */ /* Valgrind would complain about accessing free memory. */
UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i]); UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i]);
#endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */ #endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */
bpage = UT_LIST_GET_LAST(buf_pool->zip_free[i]); bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]);
if (bpage) { if (bpage) {
UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i);
...@@ -178,19 +177,16 @@ static ...@@ -178,19 +177,16 @@ static
void void
buf_buddy_block_free( buf_buddy_block_free(
/*=================*/ /*=================*/
void* buf, /* in: buffer frame to deallocate */ void* buf) /* in: buffer frame to deallocate */
ibool have_page_hash_mutex)
{ {
const ulint fold = BUF_POOL_ZIP_FOLD_PTR(buf); const ulint fold = BUF_POOL_ZIP_FOLD_PTR(buf);
buf_page_t* bpage; buf_page_t* bpage;
buf_block_t* block; buf_block_t* block;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(!mutex_own(&buf_pool_zip_mutex));
ut_a(!ut_align_offset(buf, UNIV_PAGE_SIZE)); ut_a(!ut_align_offset(buf, UNIV_PAGE_SIZE));
mutex_enter(&zip_hash_mutex);
HASH_SEARCH(hash, buf_pool->zip_hash, fold, buf_page_t*, bpage, HASH_SEARCH(hash, buf_pool->zip_hash, fold, buf_page_t*, bpage,
ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY
&& bpage->in_zip_hash && !bpage->in_page_hash), && bpage->in_zip_hash && !bpage->in_page_hash),
...@@ -202,14 +198,12 @@ buf_buddy_block_free( ...@@ -202,14 +198,12 @@ buf_buddy_block_free(
ut_d(bpage->in_zip_hash = FALSE); ut_d(bpage->in_zip_hash = FALSE);
HASH_DELETE(buf_page_t, hash, buf_pool->zip_hash, fold, bpage); HASH_DELETE(buf_page_t, hash, buf_pool->zip_hash, fold, bpage);
mutex_exit(&zip_hash_mutex);
ut_d(memset(buf, 0, UNIV_PAGE_SIZE)); ut_d(memset(buf, 0, UNIV_PAGE_SIZE));
UNIV_MEM_INVALID(buf, UNIV_PAGE_SIZE); UNIV_MEM_INVALID(buf, UNIV_PAGE_SIZE);
block = (buf_block_t*) bpage; block = (buf_block_t*) bpage;
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
buf_LRU_block_free_non_file_page(block, have_page_hash_mutex); buf_LRU_block_free_non_file_page(block);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
ut_ad(buf_buddy_n_frames > 0); ut_ad(buf_buddy_n_frames > 0);
...@@ -225,7 +219,7 @@ buf_buddy_block_register( ...@@ -225,7 +219,7 @@ buf_buddy_block_register(
buf_block_t* block) /* in: buffer frame to allocate */ buf_block_t* block) /* in: buffer frame to allocate */
{ {
const ulint fold = BUF_POOL_ZIP_FOLD(block); const ulint fold = BUF_POOL_ZIP_FOLD(block);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(!mutex_own(&buf_pool_zip_mutex));
buf_block_set_state(block, BUF_BLOCK_MEMORY); buf_block_set_state(block, BUF_BLOCK_MEMORY);
...@@ -236,10 +230,7 @@ buf_buddy_block_register( ...@@ -236,10 +230,7 @@ buf_buddy_block_register(
ut_ad(!block->page.in_page_hash); ut_ad(!block->page.in_page_hash);
ut_ad(!block->page.in_zip_hash); ut_ad(!block->page.in_zip_hash);
ut_d(block->page.in_zip_hash = TRUE); ut_d(block->page.in_zip_hash = TRUE);
mutex_enter(&zip_hash_mutex);
HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page); HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page);
mutex_exit(&zip_hash_mutex);
ut_d(buf_buddy_n_frames++); ut_d(buf_buddy_n_frames++);
} }
...@@ -293,28 +284,24 @@ buf_buddy_alloc_low( ...@@ -293,28 +284,24 @@ buf_buddy_alloc_low(
possibly NULL if lru==NULL */ possibly NULL if lru==NULL */
ulint i, /* in: index of buf_pool->zip_free[], ulint i, /* in: index of buf_pool->zip_free[],
or BUF_BUDDY_SIZES */ or BUF_BUDDY_SIZES */
ibool* lru, /* in: pointer to a variable that will be assigned ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released, and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */ or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
{ {
buf_block_t* block; buf_block_t* block;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(!mutex_own(&buf_pool_zip_mutex));
if (i < BUF_BUDDY_SIZES) { if (i < BUF_BUDDY_SIZES) {
/* Try to allocate from the buddy system. */ /* Try to allocate from the buddy system. */
mutex_enter(&zip_free_mutex);
block = buf_buddy_alloc_zip(i); block = buf_buddy_alloc_zip(i);
if (block) { if (block) {
goto func_exit; goto func_exit;
} }
mutex_exit(&zip_free_mutex);
} }
/* Try allocating from the buf_pool->free list. */ /* Try allocating from the buf_pool->free list. */
...@@ -331,31 +318,18 @@ buf_buddy_alloc_low( ...@@ -331,31 +318,18 @@ buf_buddy_alloc_low(
} }
/* Try replacing an uncompressed page in the buffer pool. */ /* Try replacing an uncompressed page in the buffer pool. */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
if (have_page_hash_mutex) {
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
block = buf_LRU_get_free_block(0); block = buf_LRU_get_free_block(0);
*lru = TRUE; *lru = TRUE;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
if (have_page_hash_mutex) {
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
alloc_big: alloc_big:
buf_buddy_block_register(block); buf_buddy_block_register(block);
mutex_enter(&zip_free_mutex);
block = buf_buddy_alloc_from(block->frame, i, BUF_BUDDY_SIZES); block = buf_buddy_alloc_from(block->frame, i, BUF_BUDDY_SIZES);
func_exit: func_exit:
buf_buddy_stat[i].used++; buf_buddy_stat[i].used++;
mutex_exit(&zip_free_mutex);
return(block); return(block);
} }
...@@ -371,8 +345,7 @@ buf_buddy_relocate_block( ...@@ -371,8 +345,7 @@ buf_buddy_relocate_block(
{ {
buf_page_t* b; buf_page_t* b;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
switch (buf_page_get_state(bpage)) { switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_FREE: case BUF_BLOCK_ZIP_FREE:
...@@ -381,7 +354,7 @@ buf_buddy_relocate_block( ...@@ -381,7 +354,7 @@ buf_buddy_relocate_block(
case BUF_BLOCK_FILE_PAGE: case BUF_BLOCK_FILE_PAGE:
case BUF_BLOCK_MEMORY: case BUF_BLOCK_MEMORY:
case BUF_BLOCK_REMOVE_HASH: case BUF_BLOCK_REMOVE_HASH:
/* ut_error; */ /* optimistic */ ut_error;
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
/* Cannot relocate dirty pages. */ /* Cannot relocate dirty pages. */
return(FALSE); return(FALSE);
...@@ -391,17 +364,9 @@ buf_buddy_relocate_block( ...@@ -391,17 +364,9 @@ buf_buddy_relocate_block(
} }
mutex_enter(&buf_pool_zip_mutex); mutex_enter(&buf_pool_zip_mutex);
mutex_enter(&zip_free_mutex);
if (!buf_page_can_relocate(bpage)) { if (!buf_page_can_relocate(bpage)) {
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
mutex_exit(&zip_free_mutex);
return(FALSE);
}
if (bpage != buf_page_hash_get(bpage->space, bpage->offset)) {
mutex_exit(&buf_pool_zip_mutex);
mutex_exit(&zip_free_mutex);
return(FALSE); return(FALSE);
} }
...@@ -419,7 +384,6 @@ buf_buddy_relocate_block( ...@@ -419,7 +384,6 @@ buf_buddy_relocate_block(
} }
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
mutex_exit(&zip_free_mutex);
return(TRUE); return(TRUE);
} }
...@@ -432,15 +396,13 @@ buf_buddy_relocate( ...@@ -432,15 +396,13 @@ buf_buddy_relocate(
/* out: TRUE if relocated */ /* out: TRUE if relocated */
void* src, /* in: block to relocate */ void* src, /* in: block to relocate */
void* dst, /* in: free block to relocate to */ void* dst, /* in: free block to relocate to */
ulint i, /* in: index of buf_pool->zip_free[] */ ulint i) /* in: index of buf_pool->zip_free[] */
ibool have_page_hash_mutex)
{ {
buf_page_t* bpage; buf_page_t* bpage;
const ulint size = BUF_BUDDY_LOW << i; const ulint size = BUF_BUDDY_LOW << i;
ullint usec = ut_time_us(NULL); ullint usec = ut_time_us(NULL);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(!mutex_own(&buf_pool_zip_mutex));
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));
...@@ -459,17 +421,9 @@ buf_buddy_relocate( ...@@ -459,17 +421,9 @@ buf_buddy_relocate(
actually is a properly initialized buf_page_t object. */ actually is a properly initialized buf_page_t object. */
if (size >= PAGE_ZIP_MIN_SIZE) { if (size >= PAGE_ZIP_MIN_SIZE) {
if (!have_page_hash_mutex)
mutex_exit(&zip_free_mutex);
/* This is a compressed page. */ /* This is a compressed page. */
mutex_t* mutex; mutex_t* mutex;
if (!have_page_hash_mutex) {
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
/* The src block may be split into smaller blocks, /* The src block may be split into smaller blocks,
some of which may be free. Thus, the some of which may be free. Thus, the
mach_read_from_4() calls below may attempt to read mach_read_from_4() calls below may attempt to read
...@@ -490,12 +444,6 @@ buf_buddy_relocate( ...@@ -490,12 +444,6 @@ buf_buddy_relocate(
added to buf_pool->page_hash yet. Obviously, added to buf_pool->page_hash yet. Obviously,
it cannot be relocated. */ it cannot be relocated. */
if (!have_page_hash_mutex) {
mutex_enter(&zip_free_mutex);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
return(FALSE); return(FALSE);
} }
...@@ -505,19 +453,9 @@ buf_buddy_relocate( ...@@ -505,19 +453,9 @@ buf_buddy_relocate(
For the sake of simplicity, give up. */ For the sake of simplicity, give up. */
ut_ad(page_zip_get_size(&bpage->zip) < size); ut_ad(page_zip_get_size(&bpage->zip) < size);
if (!have_page_hash_mutex) {
mutex_enter(&zip_free_mutex);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
return(FALSE); return(FALSE);
} }
/* To keep latch order */
if (have_page_hash_mutex)
mutex_exit(&zip_free_mutex);
/* The block must have been allocated, but it may /* The block must have been allocated, but it may
contain uninitialized data. */ contain uninitialized data. */
UNIV_MEM_ASSERT_W(src, size); UNIV_MEM_ASSERT_W(src, size);
...@@ -525,7 +463,6 @@ buf_buddy_relocate( ...@@ -525,7 +463,6 @@ buf_buddy_relocate(
mutex = buf_page_get_mutex(bpage); mutex = buf_page_get_mutex(bpage);
mutex_enter(mutex); mutex_enter(mutex);
mutex_enter(&zip_free_mutex);
if (buf_page_can_relocate(bpage)) { if (buf_page_can_relocate(bpage)) {
/* Relocate the compressed page. */ /* Relocate the compressed page. */
...@@ -542,53 +479,17 @@ success: ...@@ -542,53 +479,17 @@ success:
buddy_stat->relocated_usec buddy_stat->relocated_usec
+= ut_time_us(NULL) - usec; += ut_time_us(NULL) - usec;
} }
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
return(TRUE); return(TRUE);
} }
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
mutex_exit(mutex); mutex_exit(mutex);
} else if (i == buf_buddy_get_slot(sizeof(buf_page_t))) { } 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. */
UNIV_MEM_ASSERT_RW(src, size); UNIV_MEM_ASSERT_RW(src, size);
mutex_exit(&zip_free_mutex);
if (!have_page_hash_mutex) {
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
if (buf_buddy_relocate_block(src, dst)) { if (buf_buddy_relocate_block(src, dst)) {
mutex_enter(&zip_free_mutex);
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
goto success; goto success;
} }
mutex_enter(&zip_free_mutex);
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
} }
return(FALSE); return(FALSE);
...@@ -602,14 +503,12 @@ buf_buddy_free_low( ...@@ -602,14 +503,12 @@ buf_buddy_free_low(
/*===============*/ /*===============*/
void* buf, /* in: block to be freed, must not be void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */ pointed to by the buffer pool */
ulint i, /* in: index of buf_pool->zip_free[] */ ulint i) /* in: index of buf_pool->zip_free[] */
ibool have_page_hash_mutex)
{ {
buf_page_t* bpage; buf_page_t* bpage;
buf_page_t* buddy; buf_page_t* buddy;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(!mutex_own(&buf_pool_zip_mutex));
ut_ad(i <= BUF_BUDDY_SIZES); ut_ad(i <= BUF_BUDDY_SIZES);
ut_ad(buf_buddy_stat[i].used > 0); ut_ad(buf_buddy_stat[i].used > 0);
...@@ -620,7 +519,7 @@ recombine: ...@@ -620,7 +519,7 @@ recombine:
ut_d(((buf_page_t*) buf)->state = BUF_BLOCK_ZIP_FREE); ut_d(((buf_page_t*) buf)->state = BUF_BLOCK_ZIP_FREE);
if (i == BUF_BUDDY_SIZES) { if (i == BUF_BUDDY_SIZES) {
buf_buddy_block_free(buf, have_page_hash_mutex); buf_buddy_block_free(buf);
return; return;
} }
...@@ -678,7 +577,7 @@ buddy_nonfree: ...@@ -678,7 +577,7 @@ buddy_nonfree:
#endif /* UNIV_DEBUG_VALGRIND */ #endif /* UNIV_DEBUG_VALGRIND */
/* The buddy is not free. Is there a free block of this size? */ /* The buddy is not free. Is there a free block of this size? */
bpage = UT_LIST_GET_LAST(buf_pool->zip_free[i]); bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]);
if (bpage) { if (bpage) {
/* Remove the block from the free list, because a successful /* Remove the block from the free list, because a successful
...@@ -688,7 +587,7 @@ buddy_nonfree: ...@@ -688,7 +587,7 @@ buddy_nonfree:
buf_buddy_remove_from_free(bpage, i); buf_buddy_remove_from_free(bpage, i);
/* Try to relocate the buddy of buf to the free block. */ /* Try to relocate the buddy of buf to the free block. */
if (buf_buddy_relocate(buddy, bpage, i, have_page_hash_mutex)) { if (buf_buddy_relocate(buddy, bpage, i)) {
ut_d(buddy->state = BUF_BLOCK_ZIP_FREE); ut_d(buddy->state = BUF_BLOCK_ZIP_FREE);
goto buddy_free2; goto buddy_free2;
...@@ -716,7 +615,7 @@ buddy_nonfree: ...@@ -716,7 +615,7 @@ buddy_nonfree:
} }
#endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */ #endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */
if (buf_buddy_relocate(buddy, buf, i, have_page_hash_mutex)) { if (buf_buddy_relocate(buddy, buf, i)) {
buf = bpage; buf = bpage;
UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i);
......
...@@ -244,12 +244,6 @@ UNIV_INTERN buf_pool_t* buf_pool = NULL; ...@@ -244,12 +244,6 @@ UNIV_INTERN buf_pool_t* buf_pool = NULL;
/* mutex protecting the buffer pool struct and control blocks, except the /* mutex protecting the buffer pool struct and control blocks, except the
read-write lock in them */ read-write lock in them */
UNIV_INTERN mutex_t buf_pool_mutex; UNIV_INTERN mutex_t buf_pool_mutex;
UNIV_INTERN mutex_t LRU_list_mutex;
UNIV_INTERN mutex_t flush_list_mutex;
UNIV_INTERN rw_lock_t page_hash_latch;
UNIV_INTERN mutex_t free_list_mutex;
UNIV_INTERN mutex_t zip_free_mutex;
UNIV_INTERN mutex_t zip_hash_mutex;
/* mutex protecting the control blocks of compressed-only pages /* mutex protecting the control blocks of compressed-only pages
(of type buf_page_t, not buf_block_t) */ (of type buf_page_t, not buf_block_t) */
UNIV_INTERN mutex_t buf_pool_zip_mutex; UNIV_INTERN mutex_t buf_pool_zip_mutex;
...@@ -670,9 +664,9 @@ buf_block_init( ...@@ -670,9 +664,9 @@ buf_block_init(
block->page.in_zip_hash = FALSE; block->page.in_zip_hash = FALSE;
block->page.in_flush_list = FALSE; block->page.in_flush_list = FALSE;
block->page.in_free_list = FALSE; block->page.in_free_list = FALSE;
#endif /* UNIV_DEBUG */
block->page.in_LRU_list = FALSE; block->page.in_LRU_list = FALSE;
block->in_unzip_LRU_list = FALSE; block->in_unzip_LRU_list = FALSE;
#endif /* UNIV_DEBUG */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
block->n_pointers = 0; block->n_pointers = 0;
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
...@@ -757,10 +751,8 @@ buf_chunk_init( ...@@ -757,10 +751,8 @@ buf_chunk_init(
memset(block->frame, '\0', UNIV_PAGE_SIZE); memset(block->frame, '\0', UNIV_PAGE_SIZE);
#endif #endif
/* Add the block to the free list */ /* Add the block to the free list */
mutex_enter(&free_list_mutex);
UT_LIST_ADD_LAST(list, buf_pool->free, (&block->page)); UT_LIST_ADD_LAST(list, buf_pool->free, (&block->page));
ut_d(block->page.in_free_list = TRUE); ut_d(block->page.in_free_list = TRUE);
mutex_exit(&free_list_mutex);
block++; block++;
frame += UNIV_PAGE_SIZE; frame += UNIV_PAGE_SIZE;
...@@ -786,7 +778,7 @@ buf_chunk_contains_zip( ...@@ -786,7 +778,7 @@ buf_chunk_contains_zip(
ulint i; ulint i;
ut_ad(buf_pool); ut_ad(buf_pool);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
block = chunk->blocks; block = chunk->blocks;
...@@ -840,7 +832,7 @@ buf_chunk_not_freed( ...@@ -840,7 +832,7 @@ buf_chunk_not_freed(
ulint i; ulint i;
ut_ad(buf_pool); ut_ad(buf_pool);
//ut_ad(buf_pool_mutex_own()); /*optimistic...*/ ut_ad(buf_pool_mutex_own());
block = chunk->blocks; block = chunk->blocks;
...@@ -873,7 +865,7 @@ buf_chunk_all_free( ...@@ -873,7 +865,7 @@ buf_chunk_all_free(
ulint i; ulint i;
ut_ad(buf_pool); ut_ad(buf_pool);
ut_ad(buf_pool_mutex_own()); /* but we need all mutex here */ ut_ad(buf_pool_mutex_own());
block = chunk->blocks; block = chunk->blocks;
...@@ -899,7 +891,7 @@ buf_chunk_free( ...@@ -899,7 +891,7 @@ buf_chunk_free(
buf_block_t* block; buf_block_t* block;
const buf_block_t* block_end; const buf_block_t* block_end;
ut_ad(buf_pool_mutex_own()); /* but we need all mutex here */ ut_ad(buf_pool_mutex_own());
block_end = chunk->blocks + chunk->size; block_end = chunk->blocks + chunk->size;
...@@ -911,10 +903,8 @@ buf_chunk_free( ...@@ -911,10 +903,8 @@ buf_chunk_free(
ut_ad(!block->in_unzip_LRU_list); ut_ad(!block->in_unzip_LRU_list);
ut_ad(!block->page.in_flush_list); ut_ad(!block->page.in_flush_list);
/* Remove the block from the free list. */ /* Remove the block from the free list. */
mutex_enter(&free_list_mutex);
ut_ad(block->page.in_free_list); ut_ad(block->page.in_free_list);
UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); UT_LIST_REMOVE(list, buf_pool->free, (&block->page));
mutex_exit(&free_list_mutex);
/* Free the latches. */ /* Free the latches. */
mutex_free(&block->mutex); mutex_free(&block->mutex);
...@@ -945,18 +935,8 @@ buf_pool_init(void) ...@@ -945,18 +935,8 @@ buf_pool_init(void)
/* 1. Initialize general fields /* 1. Initialize general fields
------------------------------- */ ------------------------------- */
mutex_create(&buf_pool_mutex, SYNC_BUF_POOL); mutex_create(&buf_pool_mutex, SYNC_BUF_POOL);
mutex_create(&LRU_list_mutex, SYNC_NO_ORDER_CHECK);
mutex_create(&flush_list_mutex, SYNC_NO_ORDER_CHECK);
rw_lock_create(&page_hash_latch, SYNC_NO_ORDER_CHECK);
mutex_create(&free_list_mutex, SYNC_NO_ORDER_CHECK);
mutex_create(&zip_free_mutex, SYNC_NO_ORDER_CHECK);
mutex_create(&zip_hash_mutex, SYNC_NO_ORDER_CHECK);
mutex_create(&buf_pool_zip_mutex, SYNC_BUF_BLOCK); mutex_create(&buf_pool_zip_mutex, SYNC_BUF_BLOCK);
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
buf_pool_mutex_enter(); buf_pool_mutex_enter();
buf_pool->n_chunks = 1; buf_pool->n_chunks = 1;
...@@ -993,9 +973,6 @@ buf_pool_init(void) ...@@ -993,9 +973,6 @@ buf_pool_init(void)
--------------------------- */ --------------------------- */
/* All fields are initialized by mem_zalloc(). */ /* All fields are initialized by mem_zalloc(). */
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
buf_pool_mutex_exit(); buf_pool_mutex_exit();
btr_search_sys_create(buf_pool->curr_size btr_search_sys_create(buf_pool->curr_size
...@@ -1128,11 +1105,7 @@ buf_relocate( ...@@ -1128,11 +1105,7 @@ buf_relocate(
buf_page_t* b; buf_page_t* b;
ulint fold; ulint fold;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX));
#endif
ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE); ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE);
ut_a(bpage->buf_fix_count == 0); ut_a(bpage->buf_fix_count == 0);
...@@ -1157,7 +1130,7 @@ buf_relocate( ...@@ -1157,7 +1130,7 @@ buf_relocate(
memcpy(dpage, bpage, sizeof *dpage); memcpy(dpage, bpage, sizeof *dpage);
bpage->in_LRU_list = FALSE; ut_d(bpage->in_LRU_list = FALSE);
ut_d(bpage->in_page_hash = FALSE); ut_d(bpage->in_page_hash = FALSE);
/* relocate buf_pool->LRU */ /* relocate buf_pool->LRU */
...@@ -1213,8 +1186,7 @@ buf_pool_shrink( ...@@ -1213,8 +1186,7 @@ buf_pool_shrink(
try_again: try_again:
btr_search_disable(); /* Empty the adaptive hash index again */ btr_search_disable(); /* Empty the adaptive hash index again */
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
shrink_again: shrink_again:
if (buf_pool->n_chunks <= 1) { if (buf_pool->n_chunks <= 1) {
...@@ -1285,7 +1257,7 @@ shrink_again: ...@@ -1285,7 +1257,7 @@ shrink_again:
buf_LRU_make_block_old(&block->page); buf_LRU_make_block_old(&block->page);
dirty++; dirty++;
} else if (buf_LRU_free_block(&block->page, TRUE, NULL, FALSE) } else if (buf_LRU_free_block(&block->page, TRUE, NULL)
!= BUF_LRU_FREED) { != BUF_LRU_FREED) {
nonfree++; nonfree++;
} }
...@@ -1293,8 +1265,7 @@ shrink_again: ...@@ -1293,8 +1265,7 @@ shrink_again:
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
/* Request for a flush of the chunk if it helps. /* Request for a flush of the chunk if it helps.
Do not flush if there are non-free blocks, since Do not flush if there are non-free blocks, since
...@@ -1343,8 +1314,7 @@ shrink_again: ...@@ -1343,8 +1314,7 @@ shrink_again:
func_done: func_done:
srv_buf_pool_old_size = srv_buf_pool_size; srv_buf_pool_old_size = srv_buf_pool_size;
func_exit: func_exit:
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
btr_search_enable(); btr_search_enable();
} }
...@@ -1362,11 +1332,7 @@ buf_pool_page_hash_rebuild(void) ...@@ -1362,11 +1332,7 @@ buf_pool_page_hash_rebuild(void)
hash_table_t* zip_hash; hash_table_t* zip_hash;
buf_page_t* b; buf_page_t* b;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
/* Free, create, and populate the hash table. */ /* Free, create, and populate the hash table. */
hash_table_free(buf_pool->page_hash); hash_table_free(buf_pool->page_hash);
...@@ -1446,10 +1412,7 @@ buf_pool_page_hash_rebuild(void) ...@@ -1446,10 +1412,7 @@ buf_pool_page_hash_rebuild(void)
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
} }
/************************************************************************ /************************************************************************
...@@ -1459,20 +1422,17 @@ void ...@@ -1459,20 +1422,17 @@ void
buf_pool_resize(void) buf_pool_resize(void)
/*=================*/ /*=================*/
{ {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
if (srv_buf_pool_old_size == srv_buf_pool_size) { if (srv_buf_pool_old_size == srv_buf_pool_size) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
return; return;
} }
if (srv_buf_pool_curr_size + 1048576 > srv_buf_pool_size) { if (srv_buf_pool_curr_size + 1048576 > srv_buf_pool_size) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
/* Disable adaptive hash indexes and empty the index /* Disable adaptive hash indexes and empty the index
in order to free up memory in the buffer pool chunks. */ in order to free up memory in the buffer pool chunks. */
...@@ -1506,8 +1466,7 @@ buf_pool_resize(void) ...@@ -1506,8 +1466,7 @@ buf_pool_resize(void)
} }
srv_buf_pool_old_size = srv_buf_pool_size; srv_buf_pool_old_size = srv_buf_pool_size;
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
} }
buf_pool_page_hash_rebuild(); buf_pool_page_hash_rebuild();
...@@ -1529,14 +1488,12 @@ buf_block_make_young( ...@@ -1529,14 +1488,12 @@ buf_block_make_young(
if (buf_page_peek_if_too_old(bpage)) { if (buf_page_peek_if_too_old(bpage)) {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
/* There has been freeing activity in the LRU list: /* There has been freeing activity in the LRU list:
best to move to the head of the LRU list */ best to move to the head of the LRU list */
buf_LRU_make_block_young(bpage); buf_LRU_make_block_young(bpage);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
} }
} }
...@@ -1550,15 +1507,13 @@ buf_page_make_young( ...@@ -1550,15 +1507,13 @@ buf_page_make_young(
/*================*/ /*================*/
buf_page_t* bpage) /* in: buffer block of a file page */ buf_page_t* bpage) /* in: buffer block of a file page */
{ {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
buf_LRU_make_block_young(bpage); buf_LRU_make_block_young(bpage);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
} }
/************************************************************************ /************************************************************************
...@@ -1573,8 +1528,7 @@ buf_reset_check_index_page_at_flush( ...@@ -1573,8 +1528,7 @@ buf_reset_check_index_page_at_flush(
{ {
buf_block_t* block; buf_block_t* block;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
block = (buf_block_t*) buf_page_hash_get(space, offset); block = (buf_block_t*) buf_page_hash_get(space, offset);
...@@ -1582,8 +1536,7 @@ buf_reset_check_index_page_at_flush( ...@@ -1582,8 +1536,7 @@ buf_reset_check_index_page_at_flush(
block->check_index_page_at_flush = FALSE; block->check_index_page_at_flush = FALSE;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
} }
/************************************************************************ /************************************************************************
...@@ -1602,8 +1555,7 @@ buf_page_peek_if_search_hashed( ...@@ -1602,8 +1555,7 @@ buf_page_peek_if_search_hashed(
buf_block_t* block; buf_block_t* block;
ibool is_hashed; ibool is_hashed;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
block = (buf_block_t*) buf_page_hash_get(space, offset); block = (buf_block_t*) buf_page_hash_get(space, offset);
...@@ -1613,8 +1565,7 @@ buf_page_peek_if_search_hashed( ...@@ -1613,8 +1565,7 @@ buf_page_peek_if_search_hashed(
is_hashed = block->is_hashed; is_hashed = block->is_hashed;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(is_hashed); return(is_hashed);
} }
...@@ -1636,8 +1587,7 @@ buf_page_set_file_page_was_freed( ...@@ -1636,8 +1587,7 @@ buf_page_set_file_page_was_freed(
{ {
buf_page_t* bpage; buf_page_t* bpage;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
bpage = buf_page_hash_get(space, offset); bpage = buf_page_hash_get(space, offset);
...@@ -1645,8 +1595,7 @@ buf_page_set_file_page_was_freed( ...@@ -1645,8 +1595,7 @@ buf_page_set_file_page_was_freed(
bpage->file_page_was_freed = TRUE; bpage->file_page_was_freed = TRUE;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(bpage); return(bpage);
} }
...@@ -1667,8 +1616,7 @@ buf_page_reset_file_page_was_freed( ...@@ -1667,8 +1616,7 @@ buf_page_reset_file_page_was_freed(
{ {
buf_page_t* bpage; buf_page_t* bpage;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
bpage = buf_page_hash_get(space, offset); bpage = buf_page_hash_get(space, offset);
...@@ -1676,8 +1624,7 @@ buf_page_reset_file_page_was_freed( ...@@ -1676,8 +1624,7 @@ buf_page_reset_file_page_was_freed(
bpage->file_page_was_freed = FALSE; bpage->file_page_was_freed = FALSE;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(bpage); return(bpage);
} }
...@@ -1710,9 +1657,8 @@ buf_page_get_zip( ...@@ -1710,9 +1657,8 @@ buf_page_get_zip(
buf_pool->n_page_gets++; buf_pool->n_page_gets++;
for (;;) { for (;;) {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
lookup: lookup:
rw_lock_s_lock(&page_hash_latch);
bpage = buf_page_hash_get(space, offset); bpage = buf_page_hash_get(space, offset);
if (bpage) { if (bpage) {
break; break;
...@@ -1720,8 +1666,7 @@ lookup: ...@@ -1720,8 +1666,7 @@ lookup:
/* Page not in buf_pool: needs to be read from file */ /* Page not in buf_pool: needs to be read from file */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_read_page(space, zip_size, offset); buf_read_page(space, zip_size, offset);
...@@ -1732,16 +1677,13 @@ lookup: ...@@ -1732,16 +1677,13 @@ lookup:
if (UNIV_UNLIKELY(!bpage->zip.data)) { if (UNIV_UNLIKELY(!bpage->zip.data)) {
/* There is no compressed page. */ /* There is no compressed page. */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(NULL); return(NULL);
} }
block_mutex = buf_page_get_mutex(bpage); block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex); mutex_enter(block_mutex);
rw_lock_s_unlock(&page_hash_latch);
switch (buf_page_get_state(bpage)) { switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_NOT_USED: case BUF_BLOCK_NOT_USED:
case BUF_BLOCK_READY_FOR_USE: case BUF_BLOCK_READY_FOR_USE:
...@@ -1756,7 +1698,7 @@ lookup: ...@@ -1756,7 +1698,7 @@ lookup:
break; break;
case BUF_BLOCK_FILE_PAGE: case BUF_BLOCK_FILE_PAGE:
/* Discard the uncompressed page frame if possible. */ /* Discard the uncompressed page frame if possible. */
if (buf_LRU_free_block(bpage, FALSE, NULL, FALSE) if (buf_LRU_free_block(bpage, FALSE, NULL)
== BUF_LRU_FREED) { == BUF_LRU_FREED) {
mutex_exit(block_mutex); mutex_exit(block_mutex);
...@@ -1770,7 +1712,7 @@ lookup: ...@@ -1770,7 +1712,7 @@ lookup:
must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ; must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ;
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
buf_page_set_accessed(bpage, TRUE); buf_page_set_accessed(bpage, TRUE);
...@@ -2001,7 +1943,7 @@ buf_block_is_uncompressed( ...@@ -2001,7 +1943,7 @@ buf_block_is_uncompressed(
const buf_chunk_t* chunk = buf_pool->chunks; const buf_chunk_t* chunk = buf_pool->chunks;
const buf_chunk_t* const echunk = chunk + buf_pool->n_chunks; const buf_chunk_t* const echunk = chunk + buf_pool->n_chunks;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
if (UNIV_UNLIKELY((((ulint) block) % sizeof *block) != 0)) { if (UNIV_UNLIKELY((((ulint) block) % sizeof *block) != 0)) {
/* The pointer should be aligned. */ /* The pointer should be aligned. */
...@@ -2044,7 +1986,6 @@ buf_page_get_gen( ...@@ -2044,7 +1986,6 @@ buf_page_get_gen(
ibool accessed; ibool accessed;
ulint fix_type; ulint fix_type;
ibool must_read; ibool must_read;
mutex_t* block_mutex;
ut_ad(mtr); ut_ad(mtr);
ut_ad((rw_latch == RW_S_LATCH) ut_ad((rw_latch == RW_S_LATCH)
...@@ -2060,12 +2001,9 @@ buf_page_get_gen( ...@@ -2060,12 +2001,9 @@ buf_page_get_gen(
buf_pool->n_page_gets++; buf_pool->n_page_gets++;
loop: loop:
block = guess; block = guess;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
if (block) { if (block) {
block_mutex = buf_page_get_mutex((buf_page_t*)block);
mutex_enter(block_mutex);
/* If the guess is a compressed page descriptor that /* If the guess is a compressed page descriptor that
has been allocated by buf_buddy_alloc(), it may have has been allocated by buf_buddy_alloc(), it may have
been invalidated by buf_buddy_relocate(). In that been invalidated by buf_buddy_relocate(). In that
...@@ -2079,8 +2017,6 @@ loop: ...@@ -2079,8 +2017,6 @@ loop:
|| space != block->page.space || space != block->page.space
|| buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) { || buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) {
mutex_exit(block_mutex);
block = guess = NULL; block = guess = NULL;
} else { } else {
ut_ad(!block->page.in_zip_hash); ut_ad(!block->page.in_zip_hash);
...@@ -2089,20 +2025,14 @@ loop: ...@@ -2089,20 +2025,14 @@ loop:
} }
if (block == NULL) { if (block == NULL) {
rw_lock_s_lock(&page_hash_latch);
block = (buf_block_t*) buf_page_hash_get(space, offset); block = (buf_block_t*) buf_page_hash_get(space, offset);
if (block) {
block_mutex = buf_page_get_mutex((buf_page_t*)block);
mutex_enter(block_mutex);
}
rw_lock_s_unlock(&page_hash_latch);
} }
loop2: loop2:
if (block == NULL) { if (block == NULL) {
/* Page not in buf_pool: needs to be read from file */ /* Page not in buf_pool: needs to be read from file */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
if (mode == BUF_GET_IF_IN_POOL) { if (mode == BUF_GET_IF_IN_POOL) {
...@@ -2123,8 +2053,7 @@ loop2: ...@@ -2123,8 +2053,7 @@ loop2:
if (must_read && mode == BUF_GET_IF_IN_POOL) { if (must_read && mode == BUF_GET_IF_IN_POOL) {
/* The page is only being read to buffer */ /* The page is only being read to buffer */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(block_mutex);
return(NULL); return(NULL);
} }
...@@ -2134,16 +2063,10 @@ loop2: ...@@ -2134,16 +2063,10 @@ loop2:
ibool success; ibool success;
case BUF_BLOCK_FILE_PAGE: case BUF_BLOCK_FILE_PAGE:
if (block_mutex == &buf_pool_zip_mutex) {
/* it is wrong mutex... */
mutex_exit(block_mutex);
goto loop;
}
break; break;
case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
ut_ad(block_mutex == &buf_pool_zip_mutex);
bpage = &block->page; bpage = &block->page;
if (bpage->buf_fix_count if (bpage->buf_fix_count
...@@ -2154,26 +2077,20 @@ loop2: ...@@ -2154,26 +2077,20 @@ loop2:
wait_until_unfixed: wait_until_unfixed:
/* The block is buffer-fixed or I/O-fixed. /* The block is buffer-fixed or I/O-fixed.
Try again later. */ Try again later. */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(block_mutex);
os_thread_sleep(WAIT_FOR_READ); os_thread_sleep(WAIT_FOR_READ);
goto loop; goto loop;
} }
/* Allocate an uncompressed page. */ /* Allocate an uncompressed page. */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(block_mutex);
block = buf_LRU_get_free_block(0); block = buf_LRU_get_free_block(0);
ut_a(block); ut_a(block);
block_mutex = &block->mutex;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex); mutex_enter(&block->mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
mutex_enter(block_mutex);
{ {
buf_page_t* hash_bpage buf_page_t* hash_bpage
...@@ -2184,17 +2101,10 @@ wait_until_unfixed: ...@@ -2184,17 +2101,10 @@ wait_until_unfixed:
while buf_pool_mutex was released. while buf_pool_mutex was released.
Free the block that was allocated. */ Free the block that was allocated. */
buf_LRU_block_free_non_file_page(block, TRUE); buf_LRU_block_free_non_file_page(block);
mutex_exit(block_mutex); mutex_exit(&block->mutex);
block = (buf_block_t*) hash_bpage; block = (buf_block_t*) hash_bpage;
if (block) {
block_mutex = buf_page_get_mutex((buf_page_t*)block);
mutex_enter(block_mutex);
}
rw_lock_x_unlock(&page_hash_latch);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
goto loop2; goto loop2;
} }
} }
...@@ -2208,12 +2118,9 @@ wait_until_unfixed: ...@@ -2208,12 +2118,9 @@ wait_until_unfixed:
Free the block that was allocated and try again. Free the block that was allocated and try again.
This should be extremely unlikely. */ This should be extremely unlikely. */
buf_LRU_block_free_non_file_page(block, TRUE); buf_LRU_block_free_non_file_page(block);
//mutex_exit(&block->mutex); mutex_exit(&block->mutex);
rw_lock_x_unlock(&page_hash_latch);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
goto wait_until_unfixed; goto wait_until_unfixed;
} }
...@@ -2223,9 +2130,6 @@ wait_until_unfixed: ...@@ -2223,9 +2130,6 @@ wait_until_unfixed:
mutex_enter(&buf_pool_zip_mutex); mutex_enter(&buf_pool_zip_mutex);
buf_relocate(bpage, &block->page); buf_relocate(bpage, &block->page);
rw_lock_x_unlock(&page_hash_latch);
buf_block_init_low(block); buf_block_init_low(block);
block->lock_hash_val = lock_rec_hash(space, offset); block->lock_hash_val = lock_rec_hash(space, offset);
...@@ -2257,8 +2161,6 @@ wait_until_unfixed: ...@@ -2257,8 +2161,6 @@ wait_until_unfixed:
} }
} }
mutex_exit(&flush_list_mutex);
/* Buffer-fix, I/O-fix, and X-latch the block /* Buffer-fix, I/O-fix, and X-latch the block
for the duration of the decompression. for the duration of the decompression.
Also add the block to the unzip_LRU list. */ Also add the block to the unzip_LRU list. */
...@@ -2267,22 +2169,16 @@ wait_until_unfixed: ...@@ -2267,22 +2169,16 @@ wait_until_unfixed:
/* Insert at the front of unzip_LRU list */ /* Insert at the front of unzip_LRU list */
buf_unzip_LRU_add_block(block, FALSE); buf_unzip_LRU_add_block(block, FALSE);
mutex_exit(&LRU_list_mutex);
block->page.buf_fix_count = 1; block->page.buf_fix_count = 1;
buf_block_set_io_fix(block, BUF_IO_READ); buf_block_set_io_fix(block, BUF_IO_READ);
mutex_enter(&buf_pool_mutex);
buf_pool->n_pend_unzip++; buf_pool->n_pend_unzip++;
mutex_exit(&buf_pool_mutex);
rw_lock_x_lock(&block->lock); rw_lock_x_lock(&block->lock);
mutex_exit(block_mutex); mutex_exit(&block->mutex);
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
buf_buddy_free(bpage, sizeof *bpage, FALSE); buf_buddy_free(bpage, sizeof *bpage);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
/* Decompress the page and apply buffered operations /* Decompress the page and apply buffered operations
while not holding buf_pool_mutex or block->mutex. */ while not holding buf_pool_mutex or block->mutex. */
...@@ -2294,21 +2190,17 @@ wait_until_unfixed: ...@@ -2294,21 +2190,17 @@ wait_until_unfixed:
} }
/* Unfix and unlatch the block. */ /* Unfix and unlatch the block. */
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
block_mutex = &block->mutex; mutex_enter(&block->mutex);
mutex_enter(block_mutex);
mutex_enter(&buf_pool_mutex);
buf_pool->n_pend_unzip--; buf_pool->n_pend_unzip--;
mutex_exit(&buf_pool_mutex);
block->page.buf_fix_count--; block->page.buf_fix_count--;
buf_block_set_io_fix(block, BUF_IO_NONE); buf_block_set_io_fix(block, BUF_IO_NONE);
//mutex_exit(&block->mutex); mutex_exit(&block->mutex);
rw_lock_x_unlock(&block->lock); rw_lock_x_unlock(&block->lock);
if (UNIV_UNLIKELY(!success)) { if (UNIV_UNLIKELY(!success)) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(block_mutex);
return(NULL); return(NULL);
} }
...@@ -2325,11 +2217,11 @@ wait_until_unfixed: ...@@ -2325,11 +2217,11 @@ wait_until_unfixed:
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
//mutex_enter(&block->mutex); mutex_enter(&block->mutex);
UNIV_MEM_ASSERT_RW(&block->page, sizeof block->page); UNIV_MEM_ASSERT_RW(&block->page, sizeof block->page);
buf_block_buf_fix_inc(block, file, line); buf_block_buf_fix_inc(block, file, line);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
/* Check if this is the first access to the page */ /* Check if this is the first access to the page */
...@@ -2337,7 +2229,7 @@ wait_until_unfixed: ...@@ -2337,7 +2229,7 @@ wait_until_unfixed:
buf_page_set_accessed(&block->page, TRUE); buf_page_set_accessed(&block->page, TRUE);
mutex_exit(block_mutex); mutex_exit(&block->mutex);
buf_block_make_young(&block->page); buf_block_make_young(&block->page);
...@@ -2623,19 +2515,16 @@ buf_page_try_get_func( ...@@ -2623,19 +2515,16 @@ buf_page_try_get_func(
ibool success; ibool success;
ulint fix_type; ulint fix_type;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
block = buf_block_hash_get(space_id, page_no); block = buf_block_hash_get(space_id, page_no);
if (!block) { if (!block) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(NULL); return(NULL);
} }
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
...@@ -2755,10 +2644,7 @@ buf_page_init( ...@@ -2755,10 +2644,7 @@ buf_page_init(
{ {
buf_page_t* hash_page; buf_page_t* hash_page;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX));
#endif
ut_ad(mutex_own(&(block->mutex))); ut_ad(mutex_own(&(block->mutex)));
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
...@@ -2791,8 +2677,7 @@ buf_page_init( ...@@ -2791,8 +2677,7 @@ buf_page_init(
(const void*) hash_page, (const void*) block); (const void*) hash_page, (const void*) block);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
buf_print(); buf_print();
buf_LRU_print(); buf_LRU_print();
buf_validate(); buf_validate();
...@@ -2871,28 +2756,16 @@ buf_page_init_for_read( ...@@ -2871,28 +2756,16 @@ buf_page_init_for_read(
ut_ad(block); ut_ad(block);
} }
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
if(!block) {
mutex_enter(&flush_list_mutex);
}
rw_lock_x_lock(&page_hash_latch);
if (buf_page_hash_get(space, offset)) { if (buf_page_hash_get(space, offset)) {
/* The page is already in the buffer pool. */ /* The page is already in the buffer pool. */
err_exit: err_exit:
if (block) { if (block) {
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
mutex_exit(&LRU_list_mutex); buf_LRU_block_free_non_file_page(block);
rw_lock_x_unlock(&page_hash_latch);
buf_LRU_block_free_non_file_page(block, FALSE);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
} }
else {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
bpage = NULL; bpage = NULL;
goto func_exit; goto func_exit;
...@@ -2912,8 +2785,6 @@ err_exit: ...@@ -2912,8 +2785,6 @@ err_exit:
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
buf_page_init(space, offset, block); buf_page_init(space, offset, block);
rw_lock_x_unlock(&page_hash_latch);
/* The block must be put to the LRU list, to the old blocks */ /* The block must be put to the LRU list, to the old blocks */
buf_LRU_add_block(bpage, TRUE/* to old blocks */); buf_LRU_add_block(bpage, TRUE/* to old blocks */);
...@@ -2941,7 +2812,7 @@ err_exit: ...@@ -2941,7 +2812,7 @@ err_exit:
been added to buf_pool->LRU and been added to buf_pool->LRU and
buf_pool->page_hash. */ buf_pool->page_hash. */
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
data = buf_buddy_alloc(zip_size, &lru, FALSE); data = buf_buddy_alloc(zip_size, &lru);
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
block->page.zip.data = data; block->page.zip.data = data;
...@@ -2954,7 +2825,6 @@ err_exit: ...@@ -2954,7 +2825,6 @@ err_exit:
buf_unzip_LRU_add_block(block, TRUE); buf_unzip_LRU_add_block(block, TRUE);
} }
mutex_exit(&LRU_list_mutex);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
} else { } else {
/* Defer buf_buddy_alloc() until after the block has /* Defer buf_buddy_alloc() until after the block has
...@@ -2966,8 +2836,8 @@ err_exit: ...@@ -2966,8 +2836,8 @@ err_exit:
control block (bpage), in order to avoid the control block (bpage), in order to avoid the
invocation of buf_buddy_relocate_block() on invocation of buf_buddy_relocate_block() on
uninitialized data. */ uninitialized data. */
data = buf_buddy_alloc(zip_size, &lru, TRUE); data = buf_buddy_alloc(zip_size, &lru);
bpage = buf_buddy_alloc(sizeof *bpage, &lru, TRUE); bpage = buf_buddy_alloc(sizeof *bpage, &lru);
/* If buf_buddy_alloc() allocated storage from the LRU list, /* If buf_buddy_alloc() allocated storage from the LRU list,
it released and reacquired buf_pool_mutex. Thus, we must it released and reacquired buf_pool_mutex. Thus, we must
...@@ -2976,12 +2846,8 @@ err_exit: ...@@ -2976,12 +2846,8 @@ err_exit:
&& UNIV_LIKELY_NULL(buf_page_hash_get(space, offset))) { && UNIV_LIKELY_NULL(buf_page_hash_get(space, offset))) {
/* The block was added by some other thread. */ /* The block was added by some other thread. */
buf_buddy_free(bpage, sizeof *bpage, TRUE); buf_buddy_free(bpage, sizeof *bpage);
buf_buddy_free(data, zip_size, TRUE); buf_buddy_free(data, zip_size);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
bpage = NULL; bpage = NULL;
goto func_exit; goto func_exit;
...@@ -3004,32 +2870,25 @@ err_exit: ...@@ -3004,32 +2870,25 @@ err_exit:
bpage->in_zip_hash = FALSE; bpage->in_zip_hash = FALSE;
bpage->in_flush_list = FALSE; bpage->in_flush_list = FALSE;
bpage->in_free_list = FALSE; bpage->in_free_list = FALSE;
#endif /* UNIV_DEBUG */
bpage->in_LRU_list = FALSE; bpage->in_LRU_list = FALSE;
#endif /* UNIV_DEBUG */
ut_d(bpage->in_page_hash = TRUE); ut_d(bpage->in_page_hash = TRUE);
HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, HASH_INSERT(buf_page_t, hash, buf_pool->page_hash,
buf_page_address_fold(space, offset), bpage); buf_page_address_fold(space, offset), bpage);
rw_lock_x_unlock(&page_hash_latch);
/* The block must be put to the LRU list, to the old blocks */ /* The block must be put to the LRU list, to the old blocks */
buf_LRU_add_block(bpage, TRUE/* to old blocks */); buf_LRU_add_block(bpage, TRUE/* to old blocks */);
buf_LRU_insert_zip_clean(bpage); buf_LRU_insert_zip_clean(bpage);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
buf_page_set_io_fix(bpage, BUF_IO_READ); buf_page_set_io_fix(bpage, BUF_IO_READ);
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
} }
mutex_enter(&buf_pool_mutex);
buf_pool->n_pend_reads++; buf_pool->n_pend_reads++;
mutex_exit(&buf_pool_mutex);
func_exit: func_exit:
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
if (mode == BUF_READ_IBUF_PAGES_ONLY) { if (mode == BUF_READ_IBUF_PAGES_ONLY) {
...@@ -3065,9 +2924,7 @@ buf_page_create( ...@@ -3065,9 +2924,7 @@ buf_page_create(
free_block = buf_LRU_get_free_block(0); free_block = buf_LRU_get_free_block(0);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
rw_lock_x_lock(&page_hash_latch);
block = (buf_block_t*) buf_page_hash_get(space, offset); block = (buf_block_t*) buf_page_hash_get(space, offset);
...@@ -3080,9 +2937,7 @@ buf_page_create( ...@@ -3080,9 +2937,7 @@ buf_page_create(
#endif /* UNIV_DEBUG_FILE_ACCESSES */ #endif /* UNIV_DEBUG_FILE_ACCESSES */
/* Page can be found in buf_pool */ /* Page can be found in buf_pool */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
buf_block_free(free_block); buf_block_free(free_block);
...@@ -3104,7 +2959,6 @@ buf_page_create( ...@@ -3104,7 +2959,6 @@ buf_page_create(
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
buf_page_init(space, offset, block); buf_page_init(space, offset, block);
rw_lock_x_unlock(&page_hash_latch);
/* The block must be put to the LRU list */ /* The block must be put to the LRU list */
buf_LRU_add_block(&block->page, FALSE); buf_LRU_add_block(&block->page, FALSE);
...@@ -3131,7 +2985,7 @@ buf_page_create( ...@@ -3131,7 +2985,7 @@ buf_page_create(
the reacquisition of buf_pool_mutex. We also must the reacquisition of buf_pool_mutex. We also must
defer this operation until after the block descriptor defer this operation until after the block descriptor
has been added to buf_pool->LRU and buf_pool->page_hash. */ has been added to buf_pool->LRU and buf_pool->page_hash. */
data = buf_buddy_alloc(zip_size, &lru, FALSE); data = buf_buddy_alloc(zip_size, &lru);
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
block->page.zip.data = data; block->page.zip.data = data;
...@@ -3147,8 +3001,7 @@ buf_page_create( ...@@ -3147,8 +3001,7 @@ buf_page_create(
rw_lock_x_unlock(&block->lock); rw_lock_x_unlock(&block->lock);
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX); mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
...@@ -3200,7 +3053,6 @@ buf_page_io_complete( ...@@ -3200,7 +3053,6 @@ buf_page_io_complete(
enum buf_io_fix io_type; enum buf_io_fix io_type;
const ibool uncompressed = (buf_page_get_state(bpage) const ibool uncompressed = (buf_page_get_state(bpage)
== BUF_BLOCK_FILE_PAGE); == BUF_BLOCK_FILE_PAGE);
enum buf_flush flush_type;
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
...@@ -3335,17 +3187,8 @@ corrupt: ...@@ -3335,17 +3187,8 @@ corrupt:
} }
} }
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
if (io_type == BUF_IO_WRITE) {
flush_type = buf_page_get_flush_type(bpage);
/* to keep consistency at buf_LRU_insert_zip_clean() */
//if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
mutex_enter(&LRU_list_mutex);
//}
mutex_enter(&flush_list_mutex);
}
mutex_enter(buf_page_get_mutex(bpage)); mutex_enter(buf_page_get_mutex(bpage));
mutex_enter(&buf_pool_mutex);
#ifdef UNIV_IBUF_COUNT_DEBUG #ifdef UNIV_IBUF_COUNT_DEBUG
if (io_type == BUF_IO_WRITE || uncompressed) { if (io_type == BUF_IO_WRITE || uncompressed) {
...@@ -3385,12 +3228,6 @@ corrupt: ...@@ -3385,12 +3228,6 @@ corrupt:
buf_flush_write_complete(bpage); buf_flush_write_complete(bpage);
mutex_exit(&flush_list_mutex);
/* to keep consistency at buf_LRU_insert_zip_clean() */
//if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
mutex_exit(&LRU_list_mutex);
//}
if (uncompressed) { if (uncompressed) {
rw_lock_s_unlock_gen(&((buf_block_t*) bpage)->lock, rw_lock_s_unlock_gen(&((buf_block_t*) bpage)->lock,
BUF_IO_WRITE); BUF_IO_WRITE);
...@@ -3413,9 +3250,8 @@ corrupt: ...@@ -3413,9 +3250,8 @@ corrupt:
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
mutex_exit(&buf_pool_mutex);
mutex_exit(buf_page_get_mutex(bpage)); mutex_exit(buf_page_get_mutex(bpage));
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
} }
/************************************************************************* /*************************************************************************
...@@ -3437,14 +3273,12 @@ buf_pool_invalidate(void) ...@@ -3437,14 +3273,12 @@ buf_pool_invalidate(void)
freed = buf_LRU_search_and_free_block(100); freed = buf_LRU_search_and_free_block(100);
} }
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0); ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
ut_ad(UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0); ut_ad(UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
} }
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
...@@ -3468,11 +3302,7 @@ buf_validate(void) ...@@ -3468,11 +3302,7 @@ buf_validate(void)
ut_ad(buf_pool); ut_ad(buf_pool);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
/* for keep the new latch order, it cannot validate correctly... */
chunk = buf_pool->chunks; chunk = buf_pool->chunks;
...@@ -3653,25 +3483,19 @@ buf_validate(void) ...@@ -3653,25 +3483,19 @@ buf_validate(void)
} }
ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
/* because of latching order, we cannot get free_list_mutex here. */
/*
if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
fprintf(stderr, "Free list len %lu, free blocks %lu\n", fprintf(stderr, "Free list len %lu, free blocks %lu\n",
(ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) UT_LIST_GET_LEN(buf_pool->free),
(ulong) n_free); (ulong) n_free);
ut_error; ut_error;
} }
*/
ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush); ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
ut_a(buf_LRU_validate()); ut_a(buf_LRU_validate());
ut_a(buf_flush_validate()); ut_a(buf_flush_validate());
...@@ -3705,10 +3529,7 @@ buf_print(void) ...@@ -3705,10 +3529,7 @@ buf_print(void)
index_ids = mem_alloc(sizeof(dulint) * size); index_ids = mem_alloc(sizeof(dulint) * size);
counts = mem_alloc(sizeof(ulint) * size); counts = mem_alloc(sizeof(ulint) * size);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
mutex_enter(&free_list_mutex);
fprintf(stderr, fprintf(stderr,
"buf_pool size %lu\n" "buf_pool size %lu\n"
...@@ -3771,10 +3592,7 @@ buf_print(void) ...@@ -3771,10 +3592,7 @@ buf_print(void)
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
mutex_exit(&free_list_mutex);
for (i = 0; i < n_found; i++) { for (i = 0; i < n_found; i++) {
index = dict_index_get_if_in_cache(index_ids[i]); index = dict_index_get_if_in_cache(index_ids[i]);
...@@ -3812,7 +3630,7 @@ buf_get_latched_pages_number(void) ...@@ -3812,7 +3630,7 @@ buf_get_latched_pages_number(void)
ulint i; ulint i;
ulint fixed_pages_number = 0; ulint fixed_pages_number = 0;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
chunk = buf_pool->chunks; chunk = buf_pool->chunks;
...@@ -3882,7 +3700,7 @@ buf_get_latched_pages_number(void) ...@@ -3882,7 +3700,7 @@ buf_get_latched_pages_number(void)
} }
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
return(fixed_pages_number); return(fixed_pages_number);
} }
...@@ -3911,7 +3729,7 @@ buf_get_modified_ratio_pct(void) ...@@ -3911,7 +3729,7 @@ buf_get_modified_ratio_pct(void)
{ {
ulint ratio; ulint ratio;
//buf_pool_mutex_enter(); /* optimistic */ buf_pool_mutex_enter();
ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list)) ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
/ (1 + UT_LIST_GET_LEN(buf_pool->LRU) / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
...@@ -3919,7 +3737,7 @@ buf_get_modified_ratio_pct(void) ...@@ -3919,7 +3737,7 @@ buf_get_modified_ratio_pct(void)
/* 1 + is there to avoid division by zero */ /* 1 + is there to avoid division by zero */
//buf_pool_mutex_exit(); /* optimistic */ buf_pool_mutex_exit();
return(ratio); return(ratio);
} }
...@@ -3939,11 +3757,7 @@ buf_print_io( ...@@ -3939,11 +3757,7 @@ buf_print_io(
ut_ad(buf_pool); ut_ad(buf_pool);
size = buf_pool->curr_size; size = buf_pool->curr_size;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
mutex_enter(&free_list_mutex);
mutex_enter(&buf_pool_mutex);
fprintf(file, fprintf(file,
"Buffer pool size %lu\n" "Buffer pool size %lu\n"
...@@ -4010,11 +3824,7 @@ buf_print_io( ...@@ -4010,11 +3824,7 @@ buf_print_io(
buf_LRU_stat_sum.io, buf_LRU_stat_cur.io, buf_LRU_stat_sum.io, buf_LRU_stat_cur.io,
buf_LRU_stat_sum.unzip, buf_LRU_stat_cur.unzip); buf_LRU_stat_sum.unzip, buf_LRU_stat_cur.unzip);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
mutex_exit(&free_list_mutex);
mutex_exit(&buf_pool_mutex);
} }
/************************************************************************** /**************************************************************************
...@@ -4043,7 +3853,7 @@ buf_all_freed(void) ...@@ -4043,7 +3853,7 @@ buf_all_freed(void)
ut_ad(buf_pool); ut_ad(buf_pool);
//buf_pool_mutex_enter(); /* optimistic */ buf_pool_mutex_enter();
chunk = buf_pool->chunks; chunk = buf_pool->chunks;
...@@ -4060,7 +3870,7 @@ buf_all_freed(void) ...@@ -4060,7 +3870,7 @@ buf_all_freed(void)
} }
} }
//buf_pool_mutex_exit(); /* optimistic */ buf_pool_mutex_exit();
return(TRUE); return(TRUE);
} }
...@@ -4076,8 +3886,7 @@ buf_pool_check_no_pending_io(void) ...@@ -4076,8 +3886,7 @@ buf_pool_check_no_pending_io(void)
{ {
ibool ret; ibool ret;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU] if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU]
+ buf_pool->n_flush[BUF_FLUSH_LIST] + buf_pool->n_flush[BUF_FLUSH_LIST]
...@@ -4087,8 +3896,7 @@ buf_pool_check_no_pending_io(void) ...@@ -4087,8 +3896,7 @@ buf_pool_check_no_pending_io(void)
ret = TRUE; ret = TRUE;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
return(ret); return(ret);
} }
...@@ -4102,13 +3910,11 @@ buf_get_free_list_len(void) ...@@ -4102,13 +3910,11 @@ buf_get_free_list_len(void)
{ {
ulint len; ulint len;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&free_list_mutex);
len = UT_LIST_GET_LEN(buf_pool->free); len = UT_LIST_GET_LEN(buf_pool->free);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&free_list_mutex);
return(len); return(len);
} }
...@@ -61,8 +61,7 @@ buf_flush_insert_into_flush_list( ...@@ -61,8 +61,7 @@ buf_flush_insert_into_flush_list(
/*=============================*/ /*=============================*/
buf_block_t* block) /* in/out: block which is modified */ buf_block_t* block) /* in/out: block which is modified */
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification || (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
<= block->page.oldest_modification)); <= block->page.oldest_modification));
...@@ -93,8 +92,7 @@ buf_flush_insert_sorted_into_flush_list( ...@@ -93,8 +92,7 @@ buf_flush_insert_sorted_into_flush_list(
buf_page_t* prev_b; buf_page_t* prev_b;
buf_page_t* b; buf_page_t* b;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_ad(block->page.in_LRU_list); ut_ad(block->page.in_LRU_list);
...@@ -136,10 +134,10 @@ buf_flush_ready_for_replace( ...@@ -136,10 +134,10 @@ buf_flush_ready_for_replace(
buf_page_in_file(bpage) and in the LRU list */ buf_page_in_file(bpage) and in the LRU list */
{ {
//ut_ad(buf_pool_mutex_own()); //ut_ad(buf_pool_mutex_own());
//ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
//ut_ad(bpage->in_LRU_list); //ut_ad(bpage->in_LRU_list); /* optimistic use */
if (UNIV_LIKELY(bpage->in_LRU_list && buf_page_in_file(bpage))) { if (UNIV_LIKELY(buf_page_in_file(bpage))) {
return(bpage->oldest_modification == 0 return(bpage->oldest_modification == 0
&& buf_page_get_io_fix(bpage) == BUF_IO_NONE && buf_page_get_io_fix(bpage) == BUF_IO_NONE
...@@ -172,7 +170,7 @@ buf_flush_ready_for_flush( ...@@ -172,7 +170,7 @@ buf_flush_ready_for_flush(
enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
{ {
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); /*optimistic...*/ ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_ad(flush_type == BUF_FLUSH_LRU || BUF_FLUSH_LIST); ut_ad(flush_type == BUF_FLUSH_LRU || BUF_FLUSH_LIST);
...@@ -205,8 +203,7 @@ buf_flush_remove( ...@@ -205,8 +203,7 @@ buf_flush_remove(
/*=============*/ /*=============*/
buf_page_t* bpage) /* in: pointer to the block in question */ buf_page_t* bpage) /* in: pointer to the block in question */
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_ad(bpage->in_flush_list); ut_ad(bpage->in_flush_list);
ut_d(bpage->in_flush_list = FALSE); ut_d(bpage->in_flush_list = FALSE);
...@@ -681,9 +678,7 @@ buf_flush_write_block_low( ...@@ -681,9 +678,7 @@ buf_flush_write_block_low(
io_fixed and oldest_modification != 0. Thus, it cannot be io_fixed and oldest_modification != 0. Thus, it cannot be
relocated in the buffer pool or removed from flush_list or relocated in the buffer pool or removed from flush_list or
LRU_list. */ LRU_list. */
//ut_ad(!buf_pool_mutex_own()); ut_ad(!buf_pool_mutex_own());
ut_ad(!mutex_own(&LRU_list_mutex));
ut_ad(!mutex_own(&flush_list_mutex));
ut_ad(!mutex_own(buf_page_get_mutex(bpage))); ut_ad(!mutex_own(buf_page_get_mutex(bpage)));
ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_WRITE); ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_WRITE);
ut_ad(bpage->oldest_modification != 0); ut_ad(bpage->oldest_modification != 0);
...@@ -767,19 +762,12 @@ buf_flush_page( ...@@ -767,19 +762,12 @@ buf_flush_page(
ibool is_uncompressed; ibool is_uncompressed;
ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST); ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)
|| rw_lock_own(&page_hash_latch, RW_LOCK_SHARED));
#endif
ut_ad(buf_page_in_file(bpage)); ut_ad(buf_page_in_file(bpage));
block_mutex = buf_page_get_mutex(bpage); block_mutex = buf_page_get_mutex(bpage);
ut_ad(mutex_own(block_mutex)); ut_ad(mutex_own(block_mutex));
mutex_enter(&buf_pool_mutex);
rw_lock_s_unlock(&page_hash_latch);
ut_ad(buf_flush_ready_for_flush(bpage, flush_type)); ut_ad(buf_flush_ready_for_flush(bpage, flush_type));
buf_page_set_io_fix(bpage, BUF_IO_WRITE); buf_page_set_io_fix(bpage, BUF_IO_WRITE);
...@@ -810,8 +798,7 @@ buf_flush_page( ...@@ -810,8 +798,7 @@ buf_flush_page(
} }
mutex_exit(block_mutex); mutex_exit(block_mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
/* Even though bpage is not protected by any mutex at /* Even though bpage is not protected by any mutex at
this point, it is safe to access bpage, because it is this point, it is safe to access bpage, because it is
...@@ -848,8 +835,7 @@ buf_flush_page( ...@@ -848,8 +835,7 @@ buf_flush_page(
immediately. */ immediately. */
mutex_exit(block_mutex); mutex_exit(block_mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
break; break;
default: default:
...@@ -913,8 +899,7 @@ buf_flush_try_neighbors( ...@@ -913,8 +899,7 @@ buf_flush_try_neighbors(
high = fil_space_get_size(space); high = fil_space_get_size(space);
} }
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
for (i = low; i < high; i++) { for (i = low; i < high; i++) {
...@@ -951,16 +936,14 @@ buf_flush_try_neighbors( ...@@ -951,16 +936,14 @@ buf_flush_try_neighbors(
ut_ad(!mutex_own(block_mutex)); ut_ad(!mutex_own(block_mutex));
count++; count++;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
} else { } else {
mutex_exit(block_mutex); mutex_exit(block_mutex);
} }
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(count); return(count);
} }
...@@ -1004,29 +987,20 @@ buf_flush_batch( ...@@ -1004,29 +987,20 @@ buf_flush_batch(
ut_ad((flush_type != BUF_FLUSH_LIST) ut_ad((flush_type != BUF_FLUSH_LIST)
|| sync_thread_levels_empty_gen(TRUE)); || sync_thread_levels_empty_gen(TRUE));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
if ((buf_pool->n_flush[flush_type] > 0) if ((buf_pool->n_flush[flush_type] > 0)
|| (buf_pool->init_flush[flush_type] == TRUE)) { || (buf_pool->init_flush[flush_type] == TRUE)) {
/* There is already a flush batch of the same type running */ /* There is already a flush batch of the same type running */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
return(ULINT_UNDEFINED); return(ULINT_UNDEFINED);
} }
buf_pool->init_flush[flush_type] = TRUE; buf_pool->init_flush[flush_type] = TRUE;
mutex_exit(&buf_pool_mutex);
if (flush_type == BUF_FLUSH_LRU) {
mutex_enter(&LRU_list_mutex);
}
mutex_enter(&flush_list_mutex);
for (;;) { for (;;) {
flush_next: flush_next:
/* If we have flushed enough, leave the loop */ /* If we have flushed enough, leave the loop */
...@@ -1073,11 +1047,7 @@ flush_next: ...@@ -1073,11 +1047,7 @@ flush_next:
space = buf_page_get_space(bpage); space = buf_page_get_space(bpage);
offset = buf_page_get_page_no(bpage); offset = buf_page_get_page_no(bpage);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
if (flush_type == BUF_FLUSH_LRU) {
mutex_exit(&LRU_list_mutex);
}
mutex_exit(&flush_list_mutex);
old_page_count = page_count; old_page_count = page_count;
...@@ -1087,8 +1057,7 @@ flush_next: ...@@ -1087,8 +1057,7 @@ flush_next:
space, offset, flush_type); space, offset, flush_type);
} else { } else {
/* Try to flush the page only */ /* Try to flush the page only */
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
mutex_t* block_mutex = buf_page_get_mutex(bpage); mutex_t* block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex); mutex_enter(block_mutex);
...@@ -1104,11 +1073,7 @@ flush_next: ...@@ -1104,11 +1073,7 @@ flush_next:
flush_type, offset, flush_type, offset,
page_count - old_page_count); */ page_count - old_page_count); */
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
if (flush_type == BUF_FLUSH_LRU) {
mutex_enter(&LRU_list_mutex);
}
mutex_enter(&flush_list_mutex);
goto flush_next; goto flush_next;
} else if (flush_type == BUF_FLUSH_LRU) { } else if (flush_type == BUF_FLUSH_LRU) {
...@@ -1126,13 +1091,6 @@ flush_next: ...@@ -1126,13 +1091,6 @@ flush_next:
break; break;
} }
if (flush_type == BUF_FLUSH_LRU) {
mutex_exit(&LRU_list_mutex);
}
mutex_exit(&flush_list_mutex);
mutex_enter(&buf_pool_mutex);
buf_pool->init_flush[flush_type] = FALSE; buf_pool->init_flush[flush_type] = FALSE;
if (buf_pool->n_flush[flush_type] == 0) { if (buf_pool->n_flush[flush_type] == 0) {
...@@ -1142,8 +1100,7 @@ flush_next: ...@@ -1142,8 +1100,7 @@ flush_next:
os_event_set(buf_pool->no_flush[flush_type]); os_event_set(buf_pool->no_flush[flush_type]);
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_flush_buffered_writes(); buf_flush_buffered_writes();
...@@ -1190,14 +1147,8 @@ buf_flush_LRU_recommendation(void) ...@@ -1190,14 +1147,8 @@ buf_flush_LRU_recommendation(void)
buf_page_t* bpage; buf_page_t* bpage;
ulint n_replaceable; ulint n_replaceable;
ulint distance = 0; ulint distance = 0;
ibool have_LRU_mutex = FALSE;
if(UT_LIST_GET_LEN(buf_pool->unzip_LRU))
have_LRU_mutex = TRUE;
//buf_pool_mutex_enter(); //buf_pool_mutex_enter();
if (have_LRU_mutex)
mutex_enter(&LRU_list_mutex);
n_replaceable = UT_LIST_GET_LEN(buf_pool->free); n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
...@@ -1208,12 +1159,6 @@ buf_flush_LRU_recommendation(void) ...@@ -1208,12 +1159,6 @@ buf_flush_LRU_recommendation(void)
+ BUF_FLUSH_EXTRA_MARGIN) + BUF_FLUSH_EXTRA_MARGIN)
&& (distance < BUF_LRU_FREE_SEARCH_LEN)) { && (distance < BUF_LRU_FREE_SEARCH_LEN)) {
if (!bpage->in_LRU_list) {
/* reatart. but it is very optimistic */
bpage = UT_LIST_GET_LAST(buf_pool->LRU);
continue;
}
mutex_t* block_mutex = buf_page_get_mutex(bpage); mutex_t* block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex); mutex_enter(block_mutex);
...@@ -1230,8 +1175,6 @@ buf_flush_LRU_recommendation(void) ...@@ -1230,8 +1175,6 @@ buf_flush_LRU_recommendation(void)
} }
//buf_pool_mutex_exit(); //buf_pool_mutex_exit();
if (have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) { if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
...@@ -1309,13 +1252,11 @@ buf_flush_validate(void) ...@@ -1309,13 +1252,11 @@ buf_flush_validate(void)
{ {
ibool ret; ibool ret;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
ret = buf_flush_validate_low(); ret = buf_flush_validate_low();
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
return(ret); return(ret);
} }
......
...@@ -129,31 +129,25 @@ static ...@@ -129,31 +129,25 @@ static
void void
buf_LRU_block_free_hashed_page( buf_LRU_block_free_hashed_page(
/*===========================*/ /*===========================*/
buf_block_t* block, /* in: block, must contain a file page and buf_block_t* block); /* in: block, must contain a file page and
be in a state where it can be freed */ be in a state where it can be freed */
ibool have_page_hash_mutex);
/********************************************************************** /**********************************************************************
Determines if the unzip_LRU list should be used for evicting a victim Determines if the unzip_LRU list should be used for evicting a victim
instead of the general LRU list. */ instead of the general LRU list. */
UNIV_INLINE UNIV_INLINE
ibool ibool
buf_LRU_evict_from_unzip_LRU( buf_LRU_evict_from_unzip_LRU(void)
ibool have_LRU_mutex)
/*==============================*/ /*==============================*/
/* out: TRUE if should use unzip_LRU */ /* out: TRUE if should use unzip_LRU */
{ {
ulint io_avg; ulint io_avg;
ulint unzip_avg; ulint unzip_avg;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
if (!have_LRU_mutex)
mutex_enter(&LRU_list_mutex);
/* If the unzip_LRU list is empty, we can only use the LRU. */ /* If the unzip_LRU list is empty, we can only use the LRU. */
if (UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0) { if (UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0) {
if (!have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
return(FALSE); return(FALSE);
} }
...@@ -162,20 +156,14 @@ buf_LRU_evict_from_unzip_LRU( ...@@ -162,20 +156,14 @@ buf_LRU_evict_from_unzip_LRU(
decompressed pages in the buffer pool. */ decompressed pages in the buffer pool. */
if (UT_LIST_GET_LEN(buf_pool->unzip_LRU) if (UT_LIST_GET_LEN(buf_pool->unzip_LRU)
<= UT_LIST_GET_LEN(buf_pool->LRU) / 10) { <= UT_LIST_GET_LEN(buf_pool->LRU) / 10) {
if (!have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
return(FALSE); return(FALSE);
} }
/* If eviction hasn't started yet, we assume by default /* If eviction hasn't started yet, we assume by default
that a workload is disk bound. */ that a workload is disk bound. */
if (buf_pool->freed_page_clock == 0) { if (buf_pool->freed_page_clock == 0) {
if (!have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
return(TRUE); return(TRUE);
} }
if (!have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
/* Calculate the average over past intervals, and add the values /* Calculate the average over past intervals, and add the values
of the current interval. */ of the current interval. */
...@@ -241,8 +229,7 @@ buf_LRU_drop_page_hash_for_tablespace( ...@@ -241,8 +229,7 @@ buf_LRU_drop_page_hash_for_tablespace(
page_arr = ut_malloc(sizeof(ulint) page_arr = ut_malloc(sizeof(ulint)
* BUF_LRU_DROP_SEARCH_HASH_SIZE); * BUF_LRU_DROP_SEARCH_HASH_SIZE);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
scan_again: scan_again:
num_entries = 0; num_entries = 0;
...@@ -282,14 +269,12 @@ scan_again: ...@@ -282,14 +269,12 @@ scan_again:
} }
/* Array full. We release the buf_pool_mutex to /* Array full. We release the buf_pool_mutex to
obey the latching order. */ obey the latching order. */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, buf_LRU_drop_page_hash_batch(id, zip_size, page_arr,
num_entries); num_entries);
num_entries = 0; num_entries = 0;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
} else { } else {
mutex_exit(block_mutex); mutex_exit(block_mutex);
} }
...@@ -314,8 +299,7 @@ next_page: ...@@ -314,8 +299,7 @@ next_page:
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
/* Drop any remaining batch of search hashed pages. */ /* Drop any remaining batch of search hashed pages. */
buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, num_entries); buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, num_entries);
...@@ -343,10 +327,7 @@ buf_LRU_invalidate_tablespace( ...@@ -343,10 +327,7 @@ buf_LRU_invalidate_tablespace(
buf_LRU_drop_page_hash_for_tablespace(id); buf_LRU_drop_page_hash_for_tablespace(id);
scan_again: scan_again:
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
all_freed = TRUE; all_freed = TRUE;
...@@ -388,10 +369,7 @@ scan_again: ...@@ -388,10 +369,7 @@ scan_again:
ulint page_no; ulint page_no;
ulint zip_size; ulint zip_size;
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
zip_size = buf_page_get_zip_size(bpage); zip_size = buf_page_get_zip_size(bpage);
page_no = buf_page_get_page_no(bpage); page_no = buf_page_get_page_no(bpage);
...@@ -415,7 +393,7 @@ scan_again: ...@@ -415,7 +393,7 @@ scan_again:
if (buf_LRU_block_remove_hashed_page(bpage, TRUE) if (buf_LRU_block_remove_hashed_page(bpage, TRUE)
!= BUF_BLOCK_ZIP_FREE) { != BUF_BLOCK_ZIP_FREE) {
buf_LRU_block_free_hashed_page((buf_block_t*) buf_LRU_block_free_hashed_page((buf_block_t*)
bpage, TRUE); bpage);
} else { } else {
/* The block_mutex should have been /* The block_mutex should have been
released by buf_LRU_block_remove_hashed_page() released by buf_LRU_block_remove_hashed_page()
...@@ -438,10 +416,7 @@ next_page: ...@@ -438,10 +416,7 @@ next_page:
bpage = prev_bpage; bpage = prev_bpage;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
if (!all_freed) { if (!all_freed) {
os_thread_sleep(20000); os_thread_sleep(20000);
...@@ -464,16 +439,14 @@ buf_LRU_get_recent_limit(void) ...@@ -464,16 +439,14 @@ buf_LRU_get_recent_limit(void)
ulint len; ulint len;
ulint limit; ulint limit;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
len = UT_LIST_GET_LEN(buf_pool->LRU); len = UT_LIST_GET_LEN(buf_pool->LRU);
if (len < BUF_LRU_OLD_MIN_LEN) { if (len < BUF_LRU_OLD_MIN_LEN) {
/* The LRU list is too short to do read-ahead */ /* The LRU list is too short to do read-ahead */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
return(0); return(0);
} }
...@@ -482,8 +455,7 @@ buf_LRU_get_recent_limit(void) ...@@ -482,8 +455,7 @@ buf_LRU_get_recent_limit(void)
limit = buf_page_get_LRU_position(bpage) - len / BUF_LRU_INITIAL_RATIO; limit = buf_page_get_LRU_position(bpage) - len / BUF_LRU_INITIAL_RATIO;
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
return(limit); return(limit);
} }
...@@ -498,8 +470,7 @@ buf_LRU_insert_zip_clean( ...@@ -498,8 +470,7 @@ buf_LRU_insert_zip_clean(
{ {
buf_page_t* b; buf_page_t* b;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_PAGE); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_PAGE);
/* Find the first successor of bpage in the LRU list /* Find the first successor of bpage in the LRU list
...@@ -507,7 +478,7 @@ buf_LRU_insert_zip_clean( ...@@ -507,7 +478,7 @@ buf_LRU_insert_zip_clean(
b = bpage; b = bpage;
do { do {
b = UT_LIST_GET_NEXT(LRU, b); b = UT_LIST_GET_NEXT(LRU, b);
} while (b && (buf_page_get_state(b) != BUF_BLOCK_ZIP_PAGE || !b->in_LRU_list)); } while (b && buf_page_get_state(b) != BUF_BLOCK_ZIP_PAGE);
/* Insert bpage before b, i.e., after the predecessor of b. */ /* Insert bpage before b, i.e., after the predecessor of b. */
if (b) { if (b) {
...@@ -529,17 +500,16 @@ ibool ...@@ -529,17 +500,16 @@ ibool
buf_LRU_free_from_unzip_LRU_list( buf_LRU_free_from_unzip_LRU_list(
/*=============================*/ /*=============================*/
/* out: TRUE if freed */ /* out: TRUE if freed */
ulint n_iterations, /* in: how many times this has been called ulint n_iterations) /* in: how many times this has been called
repeatedly without result: a high value means repeatedly without result: a high value means
that we should search farther; we will search that we should search farther; we will search
n_iterations / 5 of the unzip_LRU list, n_iterations / 5 of the unzip_LRU list,
or nothing if n_iterations >= 5 */ or nothing if n_iterations >= 5 */
ibool have_LRU_mutex)
{ {
buf_block_t* block; buf_block_t* block;
ulint distance; ulint distance;
//ut_ad(buf_pool_mutex_own()); /* optimistic */ ut_ad(buf_pool_mutex_own());
/* Theoratically it should be much easier to find a victim /* Theoratically it should be much easier to find a victim
from unzip_LRU as we can choose even a dirty block (as we'll from unzip_LRU as we can choose even a dirty block (as we'll
...@@ -549,7 +519,7 @@ buf_LRU_free_from_unzip_LRU_list( ...@@ -549,7 +519,7 @@ buf_LRU_free_from_unzip_LRU_list(
if we have done five iterations so far. */ if we have done five iterations so far. */
if (UNIV_UNLIKELY(n_iterations >= 5) if (UNIV_UNLIKELY(n_iterations >= 5)
|| !buf_LRU_evict_from_unzip_LRU(have_LRU_mutex)) { || !buf_LRU_evict_from_unzip_LRU()) {
return(FALSE); return(FALSE);
} }
...@@ -557,23 +527,18 @@ buf_LRU_free_from_unzip_LRU_list( ...@@ -557,23 +527,18 @@ buf_LRU_free_from_unzip_LRU_list(
distance = 100 + (n_iterations distance = 100 + (n_iterations
* UT_LIST_GET_LEN(buf_pool->unzip_LRU)) / 5; * UT_LIST_GET_LEN(buf_pool->unzip_LRU)) / 5;
restart:
for (block = UT_LIST_GET_LAST(buf_pool->unzip_LRU); for (block = UT_LIST_GET_LAST(buf_pool->unzip_LRU);
UNIV_LIKELY(block != NULL) && UNIV_LIKELY(distance > 0); UNIV_LIKELY(block != NULL) && UNIV_LIKELY(distance > 0);
block = UT_LIST_GET_PREV(unzip_LRU, block), distance--) { block = UT_LIST_GET_PREV(unzip_LRU, block), distance--) {
if (!block->in_unzip_LRU_list || !block->page.in_LRU_list
|| buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE)
goto restart;
enum buf_lru_free_block_status freed; enum buf_lru_free_block_status freed;
/* optimistic */ ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
//ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_ad(block->in_unzip_LRU_list);
//ut_ad(block->in_unzip_LRU_list); ut_ad(block->page.in_LRU_list);
//ut_ad(block->page.in_LRU_list);
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
freed = buf_LRU_free_block(&block->page, FALSE, NULL, have_LRU_mutex); freed = buf_LRU_free_block(&block->page, FALSE, NULL);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
switch (freed) { switch (freed) {
...@@ -606,39 +571,33 @@ ibool ...@@ -606,39 +571,33 @@ ibool
buf_LRU_free_from_common_LRU_list( buf_LRU_free_from_common_LRU_list(
/*==============================*/ /*==============================*/
/* out: TRUE if freed */ /* out: TRUE if freed */
ulint n_iterations, /* in: how many times this has been called ulint n_iterations) /* in: how many times this has been called
repeatedly without result: a high value means repeatedly without result: a high value means
that we should search farther; if that we should search farther; if
n_iterations < 10, then we search n_iterations < 10, then we search
n_iterations / 10 * buf_pool->curr_size n_iterations / 10 * buf_pool->curr_size
pages from the end of the LRU list */ pages from the end of the LRU list */
ibool have_LRU_mutex)
{ {
buf_page_t* bpage; buf_page_t* bpage;
ulint distance; ulint distance;
//ut_ad(buf_pool_mutex_own()); /* optimistic */ ut_ad(buf_pool_mutex_own());
distance = 100 + (n_iterations * buf_pool->curr_size) / 10; distance = 100 + (n_iterations * buf_pool->curr_size) / 10;
restart:
for (bpage = UT_LIST_GET_LAST(buf_pool->LRU); for (bpage = UT_LIST_GET_LAST(buf_pool->LRU);
UNIV_LIKELY(bpage != NULL) && UNIV_LIKELY(distance > 0); UNIV_LIKELY(bpage != NULL) && UNIV_LIKELY(distance > 0);
bpage = UT_LIST_GET_PREV(LRU, bpage), distance--) { bpage = UT_LIST_GET_PREV(LRU, bpage), distance--) {
if (!bpage->in_LRU_list
|| buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE)
goto restart;
enum buf_lru_free_block_status freed; enum buf_lru_free_block_status freed;
mutex_t* block_mutex mutex_t* block_mutex
= buf_page_get_mutex(bpage); = buf_page_get_mutex(bpage);
/* optimistic */ ut_ad(buf_page_in_file(bpage));
//ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list);
//ut_ad(bpage->in_LRU_list);
mutex_enter(block_mutex); mutex_enter(block_mutex);
freed = buf_LRU_free_block(bpage, TRUE, NULL, have_LRU_mutex); freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(block_mutex); mutex_exit(block_mutex);
switch (freed) { switch (freed) {
...@@ -681,33 +640,22 @@ buf_LRU_search_and_free_block( ...@@ -681,33 +640,22 @@ buf_LRU_search_and_free_block(
n_iterations / 5 of the unzip_LRU list. */ n_iterations / 5 of the unzip_LRU list. */
{ {
ibool freed = FALSE; ibool freed = FALSE;
ibool have_LRU_mutex = FALSE;
if (UT_LIST_GET_LEN(buf_pool->unzip_LRU))
have_LRU_mutex = TRUE;
/* optimistic search... */ buf_pool_mutex_enter();
//buf_pool_mutex_enter();
if (have_LRU_mutex)
mutex_enter(&LRU_list_mutex);
freed = buf_LRU_free_from_unzip_LRU_list(n_iterations, have_LRU_mutex); freed = buf_LRU_free_from_unzip_LRU_list(n_iterations);
if (!freed) { if (!freed) {
freed = buf_LRU_free_from_common_LRU_list(n_iterations, have_LRU_mutex); freed = buf_LRU_free_from_common_LRU_list(n_iterations);
} }
mutex_enter(&buf_pool_mutex);
if (!freed) { if (!freed) {
buf_pool->LRU_flush_ended = 0; buf_pool->LRU_flush_ended = 0;
} else if (buf_pool->LRU_flush_ended > 0) { } else if (buf_pool->LRU_flush_ended > 0) {
buf_pool->LRU_flush_ended--; buf_pool->LRU_flush_ended--;
} }
mutex_exit(&buf_pool_mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
if (have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
return(freed); return(freed);
} }
...@@ -725,22 +673,18 @@ void ...@@ -725,22 +673,18 @@ void
buf_LRU_try_free_flushed_blocks(void) buf_LRU_try_free_flushed_blocks(void)
/*=================================*/ /*=================================*/
{ {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
while (buf_pool->LRU_flush_ended > 0) { while (buf_pool->LRU_flush_ended > 0) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_LRU_search_and_free_block(1); buf_LRU_search_and_free_block(1);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
} }
/********************************************************************** /**********************************************************************
...@@ -756,9 +700,7 @@ buf_LRU_buf_pool_running_out(void) ...@@ -756,9 +700,7 @@ buf_LRU_buf_pool_running_out(void)
{ {
ibool ret = FALSE; ibool ret = FALSE;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
mutex_enter(&free_list_mutex);
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 4) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 4) {
...@@ -766,9 +708,7 @@ buf_LRU_buf_pool_running_out(void) ...@@ -766,9 +708,7 @@ buf_LRU_buf_pool_running_out(void)
ret = TRUE; ret = TRUE;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&free_list_mutex);
return(ret); return(ret);
} }
...@@ -785,10 +725,9 @@ buf_LRU_get_free_only(void) ...@@ -785,10 +725,9 @@ buf_LRU_get_free_only(void)
{ {
buf_block_t* block; buf_block_t* block;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
mutex_enter(&free_list_mutex); block = (buf_block_t*) UT_LIST_GET_FIRST(buf_pool->free);
block = (buf_block_t*) UT_LIST_GET_LAST(buf_pool->free);
if (block) { if (block) {
ut_ad(block->page.in_free_list); ut_ad(block->page.in_free_list);
...@@ -798,16 +737,12 @@ buf_LRU_get_free_only(void) ...@@ -798,16 +737,12 @@ buf_LRU_get_free_only(void)
ut_a(!buf_page_in_file(&block->page)); ut_a(!buf_page_in_file(&block->page));
UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); UT_LIST_REMOVE(list, buf_pool->free, (&block->page));
mutex_exit(&free_list_mutex);
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE); buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
UNIV_MEM_ALLOC(block->frame, UNIV_PAGE_SIZE); UNIV_MEM_ALLOC(block->frame, UNIV_PAGE_SIZE);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
} else {
mutex_exit(&free_list_mutex);
} }
return(block); return(block);
...@@ -832,7 +767,7 @@ buf_LRU_get_free_block( ...@@ -832,7 +767,7 @@ buf_LRU_get_free_block(
ibool mon_value_was = FALSE; ibool mon_value_was = FALSE;
ibool started_monitor = FALSE; ibool started_monitor = FALSE;
loop: loop:
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 20) { + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 20) {
...@@ -912,16 +847,14 @@ loop: ...@@ -912,16 +847,14 @@ loop:
if (UNIV_UNLIKELY(zip_size)) { if (UNIV_UNLIKELY(zip_size)) {
ibool lru; ibool lru;
page_zip_set_size(&block->page.zip, zip_size); page_zip_set_size(&block->page.zip, zip_size);
mutex_enter(&LRU_list_mutex); block->page.zip.data = buf_buddy_alloc(zip_size, &lru);
block->page.zip.data = buf_buddy_alloc(zip_size, &lru, FALSE);
mutex_exit(&LRU_list_mutex);
UNIV_MEM_DESC(block->page.zip.data, zip_size, block); UNIV_MEM_DESC(block->page.zip.data, zip_size, block);
} else { } else {
page_zip_set_size(&block->page.zip, 0); page_zip_set_size(&block->page.zip, 0);
block->page.zip.data = NULL; block->page.zip.data = NULL;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
if (started_monitor) { if (started_monitor) {
srv_print_innodb_monitor = mon_value_was; srv_print_innodb_monitor = mon_value_was;
...@@ -933,7 +866,7 @@ loop: ...@@ -933,7 +866,7 @@ loop:
/* If no block was in the free list, search from the end of the LRU /* If no block was in the free list, search from the end of the LRU
list and try to free a block there */ list and try to free a block there */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
freed = buf_LRU_search_and_free_block(n_iterations); freed = buf_LRU_search_and_free_block(n_iterations);
...@@ -982,21 +915,18 @@ loop: ...@@ -982,21 +915,18 @@ loop:
os_aio_simulated_wake_handler_threads(); os_aio_simulated_wake_handler_threads();
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
if (buf_pool->LRU_flush_ended > 0) { if (buf_pool->LRU_flush_ended > 0) {
/* We have written pages in an LRU flush. To make the insert /* We have written pages in an LRU flush. To make the insert
buffer more efficient, we try to move these pages to the free buffer more efficient, we try to move these pages to the free
list. */ list. */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_LRU_try_free_flushed_blocks(); buf_LRU_try_free_flushed_blocks();
} else { } else {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
} }
if (n_iterations > 10) { if (n_iterations > 10) {
...@@ -1021,8 +951,7 @@ buf_LRU_old_adjust_len(void) ...@@ -1021,8 +951,7 @@ buf_LRU_old_adjust_len(void)
ulint new_len; ulint new_len;
ut_a(buf_pool->LRU_old); ut_a(buf_pool->LRU_old);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
#if 3 * (BUF_LRU_OLD_MIN_LEN / 8) <= BUF_LRU_OLD_TOLERANCE + 5 #if 3 * (BUF_LRU_OLD_MIN_LEN / 8) <= BUF_LRU_OLD_TOLERANCE + 5
# error "3 * (BUF_LRU_OLD_MIN_LEN / 8) <= BUF_LRU_OLD_TOLERANCE + 5" # error "3 * (BUF_LRU_OLD_MIN_LEN / 8) <= BUF_LRU_OLD_TOLERANCE + 5"
#endif #endif
...@@ -1080,8 +1009,7 @@ buf_LRU_old_init(void) ...@@ -1080,8 +1009,7 @@ buf_LRU_old_init(void)
{ {
buf_page_t* bpage; buf_page_t* bpage;
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN); ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN);
/* We first initialize all blocks in the LRU list as old and then use /* We first initialize all blocks in the LRU list as old and then use
...@@ -1113,14 +1041,13 @@ buf_unzip_LRU_remove_block_if_needed( ...@@ -1113,14 +1041,13 @@ buf_unzip_LRU_remove_block_if_needed(
ut_ad(buf_pool); ut_ad(buf_pool);
ut_ad(bpage); ut_ad(bpage);
ut_ad(buf_page_in_file(bpage)); ut_ad(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
if (buf_page_belongs_to_unzip_LRU(bpage)) { if (buf_page_belongs_to_unzip_LRU(bpage)) {
buf_block_t* block = (buf_block_t*) bpage; buf_block_t* block = (buf_block_t*) bpage;
ut_ad(block->in_unzip_LRU_list); ut_ad(block->in_unzip_LRU_list);
block->in_unzip_LRU_list = FALSE; ut_d(block->in_unzip_LRU_list = FALSE);
UT_LIST_REMOVE(unzip_LRU, buf_pool->unzip_LRU, block); UT_LIST_REMOVE(unzip_LRU, buf_pool->unzip_LRU, block);
} }
...@@ -1136,8 +1063,7 @@ buf_LRU_remove_block( ...@@ -1136,8 +1063,7 @@ buf_LRU_remove_block(
{ {
ut_ad(buf_pool); ut_ad(buf_pool);
ut_ad(bpage); ut_ad(bpage);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
...@@ -1164,7 +1090,7 @@ buf_LRU_remove_block( ...@@ -1164,7 +1090,7 @@ buf_LRU_remove_block(
/* Remove the block from the LRU list */ /* Remove the block from the LRU list */
UT_LIST_REMOVE(LRU, buf_pool->LRU, bpage); UT_LIST_REMOVE(LRU, buf_pool->LRU, bpage);
bpage->in_LRU_list = FALSE; ut_d(bpage->in_LRU_list = FALSE);
buf_unzip_LRU_remove_block_if_needed(bpage); buf_unzip_LRU_remove_block_if_needed(bpage);
...@@ -1200,13 +1126,12 @@ buf_unzip_LRU_add_block( ...@@ -1200,13 +1126,12 @@ buf_unzip_LRU_add_block(
{ {
ut_ad(buf_pool); ut_ad(buf_pool);
ut_ad(block); ut_ad(block);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_a(buf_page_belongs_to_unzip_LRU(&block->page)); ut_a(buf_page_belongs_to_unzip_LRU(&block->page));
ut_ad(!block->in_unzip_LRU_list); ut_ad(!block->in_unzip_LRU_list);
block->in_unzip_LRU_list = TRUE; ut_d(block->in_unzip_LRU_list = TRUE);
if (old) { if (old) {
UT_LIST_ADD_LAST(unzip_LRU, buf_pool->unzip_LRU, block); UT_LIST_ADD_LAST(unzip_LRU, buf_pool->unzip_LRU, block);
...@@ -1227,8 +1152,7 @@ buf_LRU_add_block_to_end_low( ...@@ -1227,8 +1152,7 @@ buf_LRU_add_block_to_end_low(
ut_ad(buf_pool); ut_ad(buf_pool);
ut_ad(bpage); ut_ad(bpage);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
...@@ -1242,7 +1166,7 @@ buf_LRU_add_block_to_end_low( ...@@ -1242,7 +1166,7 @@ buf_LRU_add_block_to_end_low(
ut_ad(!bpage->in_LRU_list); ut_ad(!bpage->in_LRU_list);
UT_LIST_ADD_LAST(LRU, buf_pool->LRU, bpage); UT_LIST_ADD_LAST(LRU, buf_pool->LRU, bpage);
bpage->in_LRU_list = TRUE; ut_d(bpage->in_LRU_list = TRUE);
buf_page_set_old(bpage, TRUE); buf_page_set_old(bpage, TRUE);
...@@ -1288,8 +1212,7 @@ buf_LRU_add_block_low( ...@@ -1288,8 +1212,7 @@ buf_LRU_add_block_low(
{ {
ut_ad(buf_pool); ut_ad(buf_pool);
ut_ad(bpage); ut_ad(bpage);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
ut_ad(!bpage->in_LRU_list); ut_ad(!bpage->in_LRU_list);
...@@ -1320,7 +1243,7 @@ buf_LRU_add_block_low( ...@@ -1320,7 +1243,7 @@ buf_LRU_add_block_low(
bpage->LRU_position = (buf_pool->LRU_old)->LRU_position; bpage->LRU_position = (buf_pool->LRU_old)->LRU_position;
} }
bpage->in_LRU_list = TRUE; ut_d(bpage->in_LRU_list = TRUE);
buf_page_set_old(bpage, old); buf_page_set_old(bpage, old);
...@@ -1408,24 +1331,22 @@ buf_LRU_free_block( ...@@ -1408,24 +1331,22 @@ buf_LRU_free_block(
buf_page_t* bpage, /* in: block to be freed */ buf_page_t* bpage, /* in: block to be freed */
ibool zip, /* in: TRUE if should remove also the ibool zip, /* in: TRUE if should remove also the
compressed page of an uncompressed page */ compressed page of an uncompressed page */
ibool* buf_pool_mutex_released, ibool* buf_pool_mutex_released)
/* in: pointer to a variable that will /* in: pointer to a variable that will
be assigned TRUE if buf_pool_mutex be assigned TRUE if buf_pool_mutex
was temporarily released, or NULL */ was temporarily released, or NULL */
ibool have_LRU_mutex)
{ {
buf_page_t* b = NULL; buf_page_t* b = NULL;
mutex_t* block_mutex = buf_page_get_mutex(bpage); mutex_t* block_mutex = buf_page_get_mutex(bpage);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
/* optimistic */ ut_ad(mutex_own(block_mutex));
//ut_ad(mutex_own(block_mutex)); ut_ad(buf_page_in_file(bpage));
//ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list);
//ut_ad(bpage->in_LRU_list); ut_ad(!bpage->in_flush_list == !bpage->oldest_modification);
//ut_ad(!bpage->in_flush_list == !bpage->oldest_modification);
UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage); UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage);
if (!bpage->in_LRU_list || !block_mutex || !buf_page_can_relocate(bpage)) { if (!buf_page_can_relocate(bpage)) {
/* Do not free buffer-fixed or I/O-fixed blocks. */ /* Do not free buffer-fixed or I/O-fixed blocks. */
return(BUF_LRU_NOT_FREED); return(BUF_LRU_NOT_FREED);
...@@ -1457,15 +1378,15 @@ buf_LRU_free_block( ...@@ -1457,15 +1378,15 @@ buf_LRU_free_block(
If it cannot be allocated (without freeing a block If it cannot be allocated (without freeing a block
from the LRU list), refuse to free bpage. */ from the LRU list), refuse to free bpage. */
alloc: alloc:
//buf_pool_mutex_exit_forbid(); buf_pool_mutex_exit_forbid();
b = buf_buddy_alloc(sizeof *b, NULL, FALSE); b = buf_buddy_alloc(sizeof *b, NULL);
//buf_pool_mutex_exit_allow(); buf_pool_mutex_exit_allow();
if (UNIV_UNLIKELY(!b)) { if (UNIV_UNLIKELY(!b)) {
return(BUF_LRU_CANNOT_RELOCATE); return(BUF_LRU_CANNOT_RELOCATE);
} }
//memcpy(b, bpage, sizeof *b); memcpy(b, bpage, sizeof *b);
} }
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -1476,41 +1397,6 @@ alloc: ...@@ -1476,41 +1397,6 @@ alloc:
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/* not to break latch order, must re-enter block_mutex */
mutex_exit(block_mutex);
if (!have_LRU_mutex)
mutex_enter(&LRU_list_mutex); /* optimistic */
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
mutex_enter(block_mutex);
/* recheck states of block */
if (!bpage->in_LRU_list || block_mutex != buf_page_get_mutex(bpage)
|| !buf_page_can_relocate(bpage)) {
not_freed:
if (b) {
buf_buddy_free(b, sizeof *b, TRUE);
}
if (!have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
return(BUF_LRU_NOT_FREED);
} else if (zip || !bpage->zip.data) {
if (bpage->oldest_modification)
goto not_freed;
} else if (bpage->oldest_modification) {
if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) {
ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_DIRTY);
goto not_freed;
}
}
if (b) {
memcpy(b, bpage, sizeof *b);
}
if (buf_LRU_block_remove_hashed_page(bpage, zip) if (buf_LRU_block_remove_hashed_page(bpage, zip)
!= BUF_BLOCK_ZIP_FREE) { != BUF_BLOCK_ZIP_FREE) {
ut_a(bpage->buf_fix_count == 0); ut_a(bpage->buf_fix_count == 0);
...@@ -1522,10 +1408,6 @@ not_freed: ...@@ -1522,10 +1408,6 @@ not_freed:
ut_a(!buf_page_hash_get(bpage->space, bpage->offset)); ut_a(!buf_page_hash_get(bpage->space, bpage->offset));
while (prev_b && !prev_b->in_LRU_list) {
prev_b = UT_LIST_GET_PREV(LRU, prev_b);
}
b->state = b->oldest_modification b->state = b->oldest_modification
? BUF_BLOCK_ZIP_DIRTY ? BUF_BLOCK_ZIP_DIRTY
: BUF_BLOCK_ZIP_PAGE; : BUF_BLOCK_ZIP_PAGE;
...@@ -1596,7 +1478,7 @@ not_freed: ...@@ -1596,7 +1478,7 @@ not_freed:
buf_LRU_old_init(); buf_LRU_old_init();
} }
} else { } else {
b->in_LRU_list = FALSE; ut_d(b->in_LRU_list = FALSE);
buf_LRU_add_block_low(b, buf_page_is_old(b)); buf_LRU_add_block_low(b, buf_page_is_old(b));
} }
...@@ -1639,10 +1521,7 @@ not_freed: ...@@ -1639,10 +1521,7 @@ not_freed:
*buf_pool_mutex_released = TRUE; *buf_pool_mutex_released = TRUE;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
mutex_exit(block_mutex); mutex_exit(block_mutex);
/* Remove possible adaptive hash index on the page. /* Remove possible adaptive hash index on the page.
...@@ -1674,9 +1553,7 @@ not_freed: ...@@ -1674,9 +1553,7 @@ not_freed:
: BUF_NO_CHECKSUM_MAGIC); : BUF_NO_CHECKSUM_MAGIC);
} }
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
if (have_LRU_mutex)
mutex_enter(&LRU_list_mutex);
mutex_enter(block_mutex); mutex_enter(block_mutex);
if (b) { if (b) {
...@@ -1686,18 +1563,13 @@ not_freed: ...@@ -1686,18 +1563,13 @@ not_freed:
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
} }
buf_LRU_block_free_hashed_page((buf_block_t*) bpage, FALSE); buf_LRU_block_free_hashed_page((buf_block_t*) bpage);
} else { } else {
/* The block_mutex should have been released by /* The block_mutex should have been released by
buf_LRU_block_remove_hashed_page() when it returns buf_LRU_block_remove_hashed_page() when it returns
BUF_BLOCK_ZIP_FREE. */ BUF_BLOCK_ZIP_FREE. */
ut_ad(block_mutex == &buf_pool_zip_mutex); ut_ad(block_mutex == &buf_pool_zip_mutex);
mutex_enter(block_mutex); mutex_enter(block_mutex);
if (!have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
} }
return(BUF_LRU_FREED); return(BUF_LRU_FREED);
...@@ -1709,13 +1581,12 @@ UNIV_INTERN ...@@ -1709,13 +1581,12 @@ UNIV_INTERN
void void
buf_LRU_block_free_non_file_page( buf_LRU_block_free_non_file_page(
/*=============================*/ /*=============================*/
buf_block_t* block, /* in: block, must not contain a file page */ buf_block_t* block) /* in: block, must not contain a file page */
ibool have_page_hash_mutex)
{ {
void* data; void* data;
ut_ad(block); ut_ad(block);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&block->mutex)); ut_ad(mutex_own(&block->mutex));
switch (buf_block_get_state(block)) { switch (buf_block_get_state(block)) {
...@@ -1749,17 +1620,15 @@ buf_LRU_block_free_non_file_page( ...@@ -1749,17 +1620,15 @@ buf_LRU_block_free_non_file_page(
if (data) { if (data) {
block->page.zip.data = NULL; block->page.zip.data = NULL;
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
//buf_pool_mutex_exit_forbid(); buf_pool_mutex_exit_forbid();
buf_buddy_free(data, page_zip_get_size(&block->page.zip), have_page_hash_mutex); buf_buddy_free(data, page_zip_get_size(&block->page.zip));
//buf_pool_mutex_exit_allow(); buf_pool_mutex_exit_allow();
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
page_zip_set_size(&block->page.zip, 0); page_zip_set_size(&block->page.zip, 0);
} }
mutex_enter(&free_list_mutex);
UT_LIST_ADD_FIRST(list, buf_pool->free, (&block->page)); UT_LIST_ADD_FIRST(list, buf_pool->free, (&block->page));
ut_d(block->page.in_free_list = TRUE); ut_d(block->page.in_free_list = TRUE);
mutex_exit(&free_list_mutex);
UNIV_MEM_ASSERT_AND_FREE(block->frame, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_AND_FREE(block->frame, UNIV_PAGE_SIZE);
} }
...@@ -1788,11 +1657,7 @@ buf_LRU_block_remove_hashed_page( ...@@ -1788,11 +1657,7 @@ buf_LRU_block_remove_hashed_page(
{ {
const buf_page_t* hashed_bpage; const buf_page_t* hashed_bpage;
ut_ad(bpage); ut_ad(bpage);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX));
#endif
ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE); ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE);
...@@ -1893,9 +1758,7 @@ buf_LRU_block_remove_hashed_page( ...@@ -1893,9 +1758,7 @@ buf_LRU_block_remove_hashed_page(
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
mutex_exit(buf_page_get_mutex(bpage)); mutex_exit(buf_page_get_mutex(bpage));
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
buf_print(); buf_print();
buf_LRU_print(); buf_LRU_print();
buf_validate(); buf_validate();
...@@ -1921,11 +1784,11 @@ buf_LRU_block_remove_hashed_page( ...@@ -1921,11 +1784,11 @@ buf_LRU_block_remove_hashed_page(
UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage);
mutex_exit(&buf_pool_zip_mutex); mutex_exit(&buf_pool_zip_mutex);
//buf_pool_mutex_exit_forbid(); buf_pool_mutex_exit_forbid();
buf_buddy_free(bpage->zip.data, buf_buddy_free(bpage->zip.data,
page_zip_get_size(&bpage->zip), TRUE); page_zip_get_size(&bpage->zip));
buf_buddy_free(bpage, sizeof(*bpage), TRUE); buf_buddy_free(bpage, sizeof(*bpage));
//buf_pool_mutex_exit_allow(); buf_pool_mutex_exit_allow();
UNIV_MEM_UNDESC(bpage); UNIV_MEM_UNDESC(bpage);
return(BUF_BLOCK_ZIP_FREE); return(BUF_BLOCK_ZIP_FREE);
...@@ -1944,9 +1807,9 @@ buf_LRU_block_remove_hashed_page( ...@@ -1944,9 +1807,9 @@ buf_LRU_block_remove_hashed_page(
bpage->zip.data = NULL; bpage->zip.data = NULL;
mutex_exit(&((buf_block_t*) bpage)->mutex); mutex_exit(&((buf_block_t*) bpage)->mutex);
//buf_pool_mutex_exit_forbid(); buf_pool_mutex_exit_forbid();
buf_buddy_free(data, page_zip_get_size(&bpage->zip), TRUE); buf_buddy_free(data, page_zip_get_size(&bpage->zip));
//buf_pool_mutex_exit_allow(); buf_pool_mutex_exit_allow();
mutex_enter(&((buf_block_t*) bpage)->mutex); mutex_enter(&((buf_block_t*) bpage)->mutex);
page_zip_set_size(&bpage->zip, 0); page_zip_set_size(&bpage->zip, 0);
} }
...@@ -1972,16 +1835,15 @@ static ...@@ -1972,16 +1835,15 @@ static
void void
buf_LRU_block_free_hashed_page( buf_LRU_block_free_hashed_page(
/*===========================*/ /*===========================*/
buf_block_t* block, /* in: block, must contain a file page and buf_block_t* block) /* in: block, must contain a file page and
be in a state where it can be freed */ be in a state where it can be freed */
ibool have_page_hash_mutex)
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&block->mutex)); ut_ad(mutex_own(&block->mutex));
buf_block_set_state(block, BUF_BLOCK_MEMORY); buf_block_set_state(block, BUF_BLOCK_MEMORY);
buf_LRU_block_free_non_file_page(block, have_page_hash_mutex); buf_LRU_block_free_non_file_page(block);
} }
/************************************************************************ /************************************************************************
...@@ -1999,8 +1861,7 @@ buf_LRU_stat_update(void) ...@@ -1999,8 +1861,7 @@ buf_LRU_stat_update(void)
goto func_exit; goto func_exit;
} }
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
/* Update the index. */ /* Update the index. */
item = &buf_LRU_stat_arr[buf_LRU_stat_arr_ind]; item = &buf_LRU_stat_arr[buf_LRU_stat_arr_ind];
...@@ -2014,8 +1875,7 @@ buf_LRU_stat_update(void) ...@@ -2014,8 +1875,7 @@ buf_LRU_stat_update(void)
/* Put current entry in the array. */ /* Put current entry in the array. */
memcpy(item, &buf_LRU_stat_cur, sizeof *item); memcpy(item, &buf_LRU_stat_cur, sizeof *item);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
func_exit: func_exit:
/* Clear the current entry. */ /* Clear the current entry. */
...@@ -2037,8 +1897,7 @@ buf_LRU_validate(void) ...@@ -2037,8 +1897,7 @@ buf_LRU_validate(void)
ulint LRU_pos; ulint LRU_pos;
ut_ad(buf_pool); ut_ad(buf_pool);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) { if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
...@@ -2097,9 +1956,6 @@ buf_LRU_validate(void) ...@@ -2097,9 +1956,6 @@ buf_LRU_validate(void)
ut_a(buf_pool->LRU_old_len == old_len); ut_a(buf_pool->LRU_old_len == old_len);
} }
mutex_exit(&LRU_list_mutex);
mutex_enter(&free_list_mutex);
UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free); UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free);
for (bpage = UT_LIST_GET_FIRST(buf_pool->free); for (bpage = UT_LIST_GET_FIRST(buf_pool->free);
...@@ -2109,9 +1965,6 @@ buf_LRU_validate(void) ...@@ -2109,9 +1965,6 @@ buf_LRU_validate(void)
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED); ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED);
} }
mutex_exit(&free_list_mutex);
mutex_enter(&LRU_list_mutex);
UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU); UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU);
for (block = UT_LIST_GET_FIRST(buf_pool->unzip_LRU); for (block = UT_LIST_GET_FIRST(buf_pool->unzip_LRU);
...@@ -2123,8 +1976,7 @@ buf_LRU_validate(void) ...@@ -2123,8 +1976,7 @@ buf_LRU_validate(void)
ut_a(buf_page_belongs_to_unzip_LRU(&block->page)); ut_a(buf_page_belongs_to_unzip_LRU(&block->page));
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
return(TRUE); return(TRUE);
} }
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
...@@ -2140,8 +1992,7 @@ buf_LRU_print(void) ...@@ -2140,8 +1992,7 @@ buf_LRU_print(void)
const buf_page_t* bpage; const buf_page_t* bpage;
ut_ad(buf_pool); ut_ad(buf_pool);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
fprintf(stderr, "Pool ulint clock %lu\n", fprintf(stderr, "Pool ulint clock %lu\n",
(ulong) buf_pool->ulint_clock); (ulong) buf_pool->ulint_clock);
...@@ -2204,7 +2055,6 @@ buf_LRU_print(void) ...@@ -2204,7 +2055,6 @@ buf_LRU_print(void)
bpage = UT_LIST_GET_NEXT(LRU, bpage); bpage = UT_LIST_GET_NEXT(LRU, bpage);
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
} }
#endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */
...@@ -246,22 +246,18 @@ buf_read_ahead_random( ...@@ -246,22 +246,18 @@ buf_read_ahead_random(
LRU_recent_limit = buf_LRU_get_recent_limit(); LRU_recent_limit = buf_LRU_get_recent_limit();
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
if (buf_pool->n_pend_reads if (buf_pool->n_pend_reads
> buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
return(0); return(0);
} }
mutex_exit(&buf_pool_mutex);
/* Count how many blocks in the area have been recently accessed, /* Count how many blocks in the area have been recently accessed,
that is, reside near the start of the LRU list. */ that is, reside near the start of the LRU list. */
rw_lock_s_lock(&page_hash_latch);
for (i = low; i < high; i++) { for (i = low; i < high; i++) {
const buf_page_t* bpage = buf_page_hash_get(space, i); const buf_page_t* bpage = buf_page_hash_get(space, i);
...@@ -273,15 +269,13 @@ buf_read_ahead_random( ...@@ -273,15 +269,13 @@ buf_read_ahead_random(
if (recent_blocks >= BUF_READ_AHEAD_RANDOM_THRESHOLD) { if (recent_blocks >= BUF_READ_AHEAD_RANDOM_THRESHOLD) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
goto read_ahead; goto read_ahead;
} }
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
/* Do nothing */ /* Do nothing */
return(0); return(0);
...@@ -475,12 +469,10 @@ buf_read_ahead_linear( ...@@ -475,12 +469,10 @@ buf_read_ahead_linear(
tablespace_version = fil_space_get_version(space); tablespace_version = fil_space_get_version(space);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
if (high > fil_space_get_size(space)) { if (high > fil_space_get_size(space)) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
/* The area is not whole, return */ /* The area is not whole, return */
return(0); return(0);
...@@ -488,12 +480,10 @@ buf_read_ahead_linear( ...@@ -488,12 +480,10 @@ buf_read_ahead_linear(
if (buf_pool->n_pend_reads if (buf_pool->n_pend_reads
> buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
return(0); return(0);
} }
mutex_exit(&buf_pool_mutex);
/* Check that almost all pages in the area have been accessed; if /* Check that almost all pages in the area have been accessed; if
offset == low, the accesses must be in a descending order, otherwise, offset == low, the accesses must be in a descending order, otherwise,
...@@ -507,7 +497,6 @@ buf_read_ahead_linear( ...@@ -507,7 +497,6 @@ buf_read_ahead_linear(
fail_count = 0; fail_count = 0;
rw_lock_s_lock(&page_hash_latch);
for (i = low; i < high; i++) { for (i = low; i < high; i++) {
bpage = buf_page_hash_get(space, i); bpage = buf_page_hash_get(space, i);
...@@ -531,8 +520,7 @@ buf_read_ahead_linear( ...@@ -531,8 +520,7 @@ buf_read_ahead_linear(
* LINEAR_AREA_THRESHOLD_COEF) { * LINEAR_AREA_THRESHOLD_COEF) {
/* Too many failures: return */ /* Too many failures: return */
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(0); return(0);
} }
...@@ -543,8 +531,7 @@ buf_read_ahead_linear( ...@@ -543,8 +531,7 @@ buf_read_ahead_linear(
bpage = buf_page_hash_get(space, offset); bpage = buf_page_hash_get(space, offset);
if (bpage == NULL) { if (bpage == NULL) {
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(0); return(0);
} }
...@@ -570,8 +557,7 @@ buf_read_ahead_linear( ...@@ -570,8 +557,7 @@ buf_read_ahead_linear(
pred_offset = fil_page_get_prev(frame); pred_offset = fil_page_get_prev(frame);
succ_offset = fil_page_get_next(frame); succ_offset = fil_page_get_next(frame);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
if ((offset == low) && (succ_offset == offset + 1)) { if ((offset == low) && (succ_offset == offset + 1)) {
......
...@@ -2282,8 +2282,7 @@ i_s_cmpmem_fill_low( ...@@ -2282,8 +2282,7 @@ i_s_cmpmem_fill_low(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&zip_free_mutex);
for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) { for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
buf_buddy_stat_t* buddy_stat = &buf_buddy_stat[x]; buf_buddy_stat_t* buddy_stat = &buf_buddy_stat[x];
...@@ -2309,8 +2308,7 @@ i_s_cmpmem_fill_low( ...@@ -2309,8 +2308,7 @@ i_s_cmpmem_fill_low(
} }
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&zip_free_mutex);
DBUG_RETURN(status); DBUG_RETURN(status);
} }
......
...@@ -28,7 +28,6 @@ struct innodb_enhancement { ...@@ -28,7 +28,6 @@ struct innodb_enhancement {
{"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_split_buf_pool_mutex","More fix of buffer_pool mutex","Spliting buf_pool_mutex and optimizing based on innodb_opt_lru_count","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"}, {"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_overwrite_relay_log_info","overwrite relay-log.info when slave recovery","Building as plugin, it is not used.","http://www.percona.com/docs/wiki/percona-xtradb:innodb_overwrite_relay_log_info"}, {"innodb_overwrite_relay_log_info","overwrite relay-log.info when slave recovery","Building as plugin, it is not used.","http://www.percona.com/docs/wiki/percona-xtradb:innodb_overwrite_relay_log_info"},
......
...@@ -49,11 +49,10 @@ buf_buddy_alloc( ...@@ -49,11 +49,10 @@ buf_buddy_alloc(
/* out: allocated block, /* out: allocated block,
possibly NULL if lru == NULL */ possibly NULL if lru == NULL */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */ ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
ibool* lru, /* in: pointer to a variable that will be assigned ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released, and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */ or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
__attribute__((malloc)); __attribute__((malloc));
/************************************************************************** /**************************************************************************
...@@ -64,8 +63,7 @@ buf_buddy_free( ...@@ -64,8 +63,7 @@ buf_buddy_free(
/*===========*/ /*===========*/
void* buf, /* in: block to be freed, must not be void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */ pointed to by the buffer pool */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */ ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
ibool have_page_hash_mutex)
__attribute__((nonnull)); __attribute__((nonnull));
/** Statistics of buddy blocks of a given size. */ /** Statistics of buddy blocks of a given size. */
......
...@@ -44,11 +44,10 @@ buf_buddy_alloc_low( ...@@ -44,11 +44,10 @@ buf_buddy_alloc_low(
possibly NULL if lru==NULL */ possibly NULL if lru==NULL */
ulint i, /* in: index of buf_pool->zip_free[], ulint i, /* in: index of buf_pool->zip_free[],
or BUF_BUDDY_SIZES */ or BUF_BUDDY_SIZES */
ibool* lru, /* in: pointer to a variable that will be assigned ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released, and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */ or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
__attribute__((malloc)); __attribute__((malloc));
/************************************************************************** /**************************************************************************
...@@ -59,9 +58,8 @@ buf_buddy_free_low( ...@@ -59,9 +58,8 @@ buf_buddy_free_low(
/*===============*/ /*===============*/
void* buf, /* in: block to be freed, must not be void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */ pointed to by the buffer pool */
ulint i, /* in: index of buf_pool->zip_free[], ulint i) /* in: index of buf_pool->zip_free[],
or BUF_BUDDY_SIZES */ or BUF_BUDDY_SIZES */
ibool have_page_hash_mutex)
__attribute__((nonnull)); __attribute__((nonnull));
/************************************************************************** /**************************************************************************
...@@ -100,15 +98,14 @@ buf_buddy_alloc( ...@@ -100,15 +98,14 @@ buf_buddy_alloc(
/* out: allocated block, /* out: allocated block,
possibly NULL if lru == NULL */ possibly NULL if lru == NULL */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */ ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
ibool* lru, /* in: pointer to a variable that will be assigned ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released, and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */ or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru, have_page_hash_mutex)); return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
} }
/************************************************************************** /**************************************************************************
...@@ -119,26 +116,11 @@ buf_buddy_free( ...@@ -119,26 +116,11 @@ buf_buddy_free(
/*===========*/ /*===========*/
void* buf, /* in: block to be freed, must not be void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */ pointed to by the buffer pool */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */ ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
ibool have_page_hash_mutex)
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
if (!have_page_hash_mutex) {
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
mutex_enter(&zip_free_mutex);
buf_buddy_free_low(buf, buf_buddy_get_slot(size), TRUE);
mutex_exit(&zip_free_mutex);
if (!have_page_hash_mutex) { buf_buddy_free_low(buf, buf_buddy_get_slot(size));
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
} }
#ifdef UNIV_MATERIALIZE #ifdef UNIV_MATERIALIZE
......
...@@ -1061,10 +1061,10 @@ struct buf_page_struct{ ...@@ -1061,10 +1061,10 @@ struct buf_page_struct{
UT_LIST_NODE_T(buf_page_t) LRU; UT_LIST_NODE_T(buf_page_t) LRU;
/* node of the LRU list */ /* node of the LRU list */
//#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
ibool in_LRU_list; /* TRUE if the page is in the LRU list; ibool in_LRU_list; /* TRUE if the page is in the LRU list;
used in debugging */ used in debugging */
//#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
unsigned old:1; /* TRUE if the block is in the old unsigned old:1; /* TRUE if the block is in the old
blocks in the LRU list */ blocks in the LRU list */
unsigned LRU_position:31;/* value which monotonically decreases unsigned LRU_position:31;/* value which monotonically decreases
...@@ -1104,11 +1104,11 @@ struct buf_block_struct{ ...@@ -1104,11 +1104,11 @@ struct buf_block_struct{
a block is in the unzip_LRU list a block is in the unzip_LRU list
if page.state == BUF_BLOCK_FILE_PAGE if page.state == BUF_BLOCK_FILE_PAGE
and page.zip.data != NULL */ and page.zip.data != NULL */
//#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
ibool in_unzip_LRU_list;/* TRUE if the page is in the ibool in_unzip_LRU_list;/* TRUE if the page is in the
decompressed LRU list; decompressed LRU list;
used in debugging */ used in debugging */
//#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
byte* frame; /* pointer to buffer frame which byte* frame; /* pointer to buffer frame which
is of size UNIV_PAGE_SIZE, and is of size UNIV_PAGE_SIZE, and
aligned to an address divisible by aligned to an address divisible by
...@@ -1316,12 +1316,6 @@ struct buf_pool_struct{ ...@@ -1316,12 +1316,6 @@ struct buf_pool_struct{
/* mutex protecting the buffer pool struct and control blocks, except the /* mutex protecting the buffer pool struct and control blocks, except the
read-write lock in them */ read-write lock in them */
extern mutex_t buf_pool_mutex; extern mutex_t buf_pool_mutex;
extern mutex_t LRU_list_mutex;
extern mutex_t flush_list_mutex;
extern rw_lock_t page_hash_latch;
extern mutex_t free_list_mutex;
extern mutex_t zip_free_mutex;
extern mutex_t zip_hash_mutex;
/* mutex protecting the control blocks of compressed-only pages /* mutex protecting the control blocks of compressed-only pages
(of type buf_page_t, not buf_block_t) */ (of type buf_page_t, not buf_block_t) */
extern mutex_t buf_pool_zip_mutex; extern mutex_t buf_pool_zip_mutex;
......
...@@ -100,8 +100,7 @@ buf_pool_get_oldest_modification(void) ...@@ -100,8 +100,7 @@ buf_pool_get_oldest_modification(void)
buf_page_t* bpage; buf_page_t* bpage;
ib_uint64_t lsn; ib_uint64_t lsn;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
bpage = UT_LIST_GET_LAST(buf_pool->flush_list); bpage = UT_LIST_GET_LAST(buf_pool->flush_list);
...@@ -112,8 +111,7 @@ buf_pool_get_oldest_modification(void) ...@@ -112,8 +111,7 @@ buf_pool_get_oldest_modification(void)
lsn = bpage->oldest_modification; lsn = bpage->oldest_modification;
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
/* The returned answer may be out of date: the flush_list can /* The returned answer may be out of date: the flush_list can
change after the mutex has been released. */ change after the mutex has been released. */
...@@ -130,8 +128,7 @@ buf_pool_clock_tic(void) ...@@ -130,8 +128,7 @@ buf_pool_clock_tic(void)
/*====================*/ /*====================*/
/* out: new clock value */ /* out: new clock value */
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
buf_pool->ulint_clock++; buf_pool->ulint_clock++;
...@@ -249,7 +246,7 @@ buf_page_in_file( ...@@ -249,7 +246,7 @@ buf_page_in_file(
case BUF_BLOCK_ZIP_FREE: case BUF_BLOCK_ZIP_FREE:
/* This is a free page in buf_pool->zip_free[]. /* This is a free page in buf_pool->zip_free[].
Such pages should only be accessed by the buddy allocator. */ Such pages should only be accessed by the buddy allocator. */
/* ut_error; */ /* optimistic */ ut_error;
break; break;
case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
...@@ -291,7 +288,7 @@ buf_page_get_LRU_position( ...@@ -291,7 +288,7 @@ buf_page_get_LRU_position(
const buf_page_t* bpage) /* in: control block */ const buf_page_t* bpage) /* in: control block */
{ {
ut_ad(buf_page_in_file(bpage)); ut_ad(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); /* This is used in optimistic */ ut_ad(buf_pool_mutex_own());
return(bpage->LRU_position); return(bpage->LRU_position);
} }
...@@ -308,7 +305,7 @@ buf_page_get_mutex( ...@@ -308,7 +305,7 @@ buf_page_get_mutex(
{ {
switch (buf_page_get_state(bpage)) { switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_FREE: case BUF_BLOCK_ZIP_FREE:
/* ut_error; */ /* optimistic */ ut_error;
return(NULL); return(NULL);
case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
...@@ -413,7 +410,7 @@ buf_page_set_io_fix( ...@@ -413,7 +410,7 @@ buf_page_set_io_fix(
buf_page_t* bpage, /* in/out: control block */ buf_page_t* bpage, /* in/out: control block */
enum buf_io_fix io_fix) /* in: io_fix state */ enum buf_io_fix io_fix) /* in: io_fix state */
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
bpage->io_fix = io_fix; bpage->io_fix = io_fix;
...@@ -441,13 +438,12 @@ buf_page_can_relocate( ...@@ -441,13 +438,12 @@ buf_page_can_relocate(
/*==================*/ /*==================*/
const buf_page_t* bpage) /* control block being relocated */ const buf_page_t* bpage) /* control block being relocated */
{ {
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
/* optimistic */ ut_ad(mutex_own(buf_page_get_mutex(bpage)));
//ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(buf_page_in_file(bpage));
//ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list);
//ut_ad(bpage->in_LRU_list);
return(bpage->in_LRU_list && bpage->io_fix == BUF_IO_NONE return(buf_page_get_io_fix(bpage) == BUF_IO_NONE
&& bpage->buf_fix_count == 0); && bpage->buf_fix_count == 0);
} }
...@@ -461,7 +457,7 @@ buf_page_is_old( ...@@ -461,7 +457,7 @@ buf_page_is_old(
const buf_page_t* bpage) /* in: control block */ const buf_page_t* bpage) /* in: control block */
{ {
ut_ad(buf_page_in_file(bpage)); ut_ad(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); /* This is used in optimistic */ ut_ad(buf_pool_mutex_own());
return(bpage->old); return(bpage->old);
} }
...@@ -476,8 +472,7 @@ buf_page_set_old( ...@@ -476,8 +472,7 @@ buf_page_set_old(
ibool old) /* in: old */ ibool old) /* in: old */
{ {
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_ad(bpage->in_LRU_list); ut_ad(bpage->in_LRU_list);
#ifdef UNIV_LRU_DEBUG #ifdef UNIV_LRU_DEBUG
...@@ -733,17 +728,17 @@ buf_block_free( ...@@ -733,17 +728,17 @@ buf_block_free(
/*===========*/ /*===========*/
buf_block_t* block) /* in, own: block to be freed */ buf_block_t* block) /* in, own: block to be freed */
{ {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
buf_LRU_block_free_non_file_page(block, FALSE); buf_LRU_block_free_non_file_page(block);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
} }
/************************************************************************* /*************************************************************************
...@@ -788,17 +783,14 @@ buf_page_io_query( ...@@ -788,17 +783,14 @@ buf_page_io_query(
buf_page_t* bpage) /* in: buf_pool block, must be bufferfixed */ buf_page_t* bpage) /* in: buf_pool block, must be bufferfixed */
{ {
ibool io_fixed; ibool io_fixed;
mutex_t* block_mutex = buf_page_get_mutex(bpage);
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(block_mutex);
ut_ad(buf_page_in_file(bpage)); ut_ad(buf_page_in_file(bpage));
ut_ad(bpage->buf_fix_count > 0); ut_ad(bpage->buf_fix_count > 0);
io_fixed = buf_page_get_io_fix(bpage) != BUF_IO_NONE; io_fixed = buf_page_get_io_fix(bpage) != BUF_IO_NONE;
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(block_mutex);
return(io_fixed); return(io_fixed);
} }
...@@ -925,11 +917,7 @@ buf_page_hash_get( ...@@ -925,11 +917,7 @@ buf_page_hash_get(
ulint fold; ulint fold;
ut_ad(buf_pool); ut_ad(buf_pool);
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)
|| rw_lock_own(&page_hash_latch, RW_LOCK_SHARED));
#endif
/* Look for the page in the hash table */ /* Look for the page in the hash table */
...@@ -978,13 +966,11 @@ buf_page_peek( ...@@ -978,13 +966,11 @@ buf_page_peek(
{ {
const buf_page_t* bpage; const buf_page_t* bpage;
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
bpage = buf_page_hash_get(space, offset); bpage = buf_page_hash_get(space, offset);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
return(bpage != NULL); return(bpage != NULL);
} }
...@@ -1047,17 +1033,12 @@ buf_page_release( ...@@ -1047,17 +1033,12 @@ buf_page_release(
ut_a(block->page.buf_fix_count > 0); ut_a(block->page.buf_fix_count > 0);
if (rw_latch == RW_X_LATCH && mtr->modifications) { if (rw_latch == RW_X_LATCH && mtr->modifications) {
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
mutex_enter(&block->mutex);
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
buf_flush_note_modification(block, mtr); buf_flush_note_modification(block, mtr);
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
} }
else {
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
}
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_s_unlock(&(block->debug_latch)); rw_lock_s_unlock(&(block->debug_latch));
......
...@@ -59,8 +59,7 @@ buf_flush_note_modification( ...@@ -59,8 +59,7 @@ buf_flush_note_modification(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
//ut_ad(buf_pool_mutex_own()); ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(mtr->start_lsn != 0); ut_ad(mtr->start_lsn != 0);
ut_ad(mtr->modifications); ut_ad(mtr->modifications);
...@@ -100,8 +99,7 @@ buf_flush_recv_note_modification( ...@@ -100,8 +99,7 @@ buf_flush_recv_note_modification(
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
//buf_pool_mutex_enter(); buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
ut_ad(block->page.newest_modification <= end_lsn); ut_ad(block->page.newest_modification <= end_lsn);
...@@ -118,6 +116,5 @@ buf_flush_recv_note_modification( ...@@ -118,6 +116,5 @@ buf_flush_recv_note_modification(
ut_ad(block->page.oldest_modification <= start_lsn); ut_ad(block->page.oldest_modification <= start_lsn);
} }
//buf_pool_mutex_exit(); buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
} }
...@@ -122,11 +122,10 @@ buf_LRU_free_block( ...@@ -122,11 +122,10 @@ buf_LRU_free_block(
buf_page_t* bpage, /* in: block to be freed */ buf_page_t* bpage, /* in: block to be freed */
ibool zip, /* in: TRUE if should remove also the ibool zip, /* in: TRUE if should remove also the
compressed page of an uncompressed page */ compressed page of an uncompressed page */
ibool* buf_pool_mutex_released, ibool* buf_pool_mutex_released);
/* in: pointer to a variable that will /* in: pointer to a variable that will
be assigned TRUE if buf_pool_mutex be assigned TRUE if buf_pool_mutex
was temporarily released, or NULL */ was temporarily released, or NULL */
ibool have_LRU_mutex);
/********************************************************************** /**********************************************************************
Try to free a replaceable block. */ Try to free a replaceable block. */
UNIV_INTERN UNIV_INTERN
...@@ -170,8 +169,7 @@ UNIV_INTERN ...@@ -170,8 +169,7 @@ UNIV_INTERN
void void
buf_LRU_block_free_non_file_page( buf_LRU_block_free_non_file_page(
/*=============================*/ /*=============================*/
buf_block_t* block, /* in: block, must not contain a file page */ buf_block_t* block); /* in: block, must not contain a file page */
ibool have_page_hash_mutex);
/********************************************************************** /**********************************************************************
Adds a block to the LRU list. */ Adds a block to the LRU list. */
UNIV_INTERN UNIV_INTERN
......
...@@ -35,7 +35,7 @@ Created 1/20/1994 Heikki Tuuri ...@@ -35,7 +35,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 1 #define INNODB_VERSION_MAJOR 1
#define INNODB_VERSION_MINOR 0 #define INNODB_VERSION_MINOR 0
#define INNODB_VERSION_BUGFIX 3 #define INNODB_VERSION_BUGFIX 3
#define PERCONA_INNODB_VERSION 5 #define PERCONA_INNODB_VERSION 5a
/* The following is the InnoDB version as shown in /* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins; SELECT plugin_version FROM information_schema.plugins;
......
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