Commit 33e082be authored by marko's avatar marko

branches/zip: buf_buddy_alloc(): Assign *lru = TRUE whenever the buffer pool

mutex is temporarily released.

buf_LRU_free_block(), buf_buddy_alloc_clean(): Add an output parameter that
will be assigned TRUE when the buffer pool mutex is released.

This bug was spotted by and fix provided by Sunny.
parent 15ef4c8f
...@@ -3625,12 +3625,12 @@ btr_blob_free( ...@@ -3625,12 +3625,12 @@ 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) if (!buf_LRU_free_block(&block->page, all, NULL)
&& all && block->page.zip.data) { && all && block->page.zip.data) {
/* 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); buf_LRU_free_block(&block->page, FALSE, NULL);
} }
} }
......
...@@ -268,7 +268,10 @@ void* ...@@ -268,7 +268,10 @@ void*
buf_buddy_alloc_clean( buf_buddy_alloc_clean(
/*==================*/ /*==================*/
/* out: allocated block, or NULL */ /* out: allocated block, or NULL */
ulint i) /* in: index of buf_pool->zip_free[] */ ulint i, /* in: index of buf_pool->zip_free[] */
ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list
and buf_pool->mutex was temporarily released */
{ {
buf_page_t* bpage; buf_page_t* bpage;
...@@ -297,7 +300,7 @@ buf_buddy_alloc_clean( ...@@ -297,7 +300,7 @@ buf_buddy_alloc_clean(
for (; j--; bpage = UT_LIST_GET_NEXT(list, bpage)) { for (; j--; bpage = UT_LIST_GET_NEXT(list, bpage)) {
if (bpage->zip.ssize != dummy_zip.ssize if (bpage->zip.ssize != dummy_zip.ssize
|| !buf_LRU_free_block(bpage, FALSE)) { || !buf_LRU_free_block(bpage, FALSE, lru)) {
continue; continue;
} }
...@@ -344,7 +347,7 @@ free_LRU: ...@@ -344,7 +347,7 @@ free_LRU:
mutex_enter(block_mutex); mutex_enter(block_mutex);
/* Keep the compressed pages of uncompressed blocks. */ /* Keep the compressed pages of uncompressed blocks. */
if (!buf_LRU_free_block(bpage, FALSE)) { if (!buf_LRU_free_block(bpage, FALSE, lru)) {
mutex_exit(block_mutex); mutex_exit(block_mutex);
continue; continue;
...@@ -433,7 +436,7 @@ buf_buddy_alloc_low( ...@@ -433,7 +436,7 @@ buf_buddy_alloc_low(
/* Try replacing a clean page in the buffer pool. */ /* Try replacing a clean page in the buffer pool. */
block = buf_buddy_alloc_clean(i); block = buf_buddy_alloc_clean(i, lru);
if (block) { if (block) {
......
...@@ -1079,7 +1079,8 @@ shrink_again: ...@@ -1079,7 +1079,8 @@ 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)) { } else if (!buf_LRU_free_block(&block->page,
TRUE, NULL)) {
nonfree++; nonfree++;
} }
...@@ -1513,7 +1514,7 @@ lookup: ...@@ -1513,7 +1514,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)) { if (buf_LRU_free_block(bpage, FALSE, NULL)) {
mutex_exit(block_mutex); mutex_exit(block_mutex);
goto lookup; goto lookup;
......
...@@ -279,7 +279,7 @@ buf_LRU_search_and_free_block( ...@@ -279,7 +279,7 @@ buf_LRU_search_and_free_block(
= buf_page_get_mutex(bpage); = buf_page_get_mutex(bpage);
mutex_enter(block_mutex); mutex_enter(block_mutex);
freed = buf_LRU_free_block(bpage, TRUE); freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(block_mutex); mutex_exit(block_mutex);
if (freed) { if (freed) {
...@@ -302,7 +302,7 @@ buf_LRU_search_and_free_block( ...@@ -302,7 +302,7 @@ buf_LRU_search_and_free_block(
= buf_page_get_mutex(bpage); = buf_page_get_mutex(bpage);
mutex_enter(block_mutex); mutex_enter(block_mutex);
freed = buf_LRU_free_block(bpage, TRUE); freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(block_mutex); mutex_exit(block_mutex);
if (freed) { if (freed) {
...@@ -330,7 +330,7 @@ buf_LRU_search_and_free_block( ...@@ -330,7 +330,7 @@ buf_LRU_search_and_free_block(
buf_block_t* block = (buf_block_t*) bpage; buf_block_t* block = (buf_block_t*) bpage;
mutex_enter(&block->mutex); mutex_enter(&block->mutex);
freed = buf_LRU_free_block(bpage, TRUE); freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(&block->mutex); mutex_exit(&block->mutex);
if (freed) { if (freed) {
...@@ -938,8 +938,12 @@ buf_LRU_free_block( ...@@ -938,8 +938,12 @@ buf_LRU_free_block(
it will not temporarily release it will not temporarily release
buf_pool->mutex. */ buf_pool->mutex. */
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)
/* in: pointer to a variable that will
be assigned TRUE if buf_pool->mutex
was temporarily released, or NULL */
{ {
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);
...@@ -1054,6 +1058,10 @@ alloc: ...@@ -1054,6 +1058,10 @@ alloc:
b->io_fix = BUF_IO_READ; b->io_fix = BUF_IO_READ;
} }
if (buf_pool_mutex_released) {
*buf_pool_mutex_released = TRUE;
}
mutex_exit(&buf_pool->mutex); mutex_exit(&buf_pool->mutex);
mutex_exit(block_mutex); mutex_exit(block_mutex);
......
...@@ -85,8 +85,12 @@ buf_LRU_free_block( ...@@ -85,8 +85,12 @@ buf_LRU_free_block(
it will not temporarily release it will not temporarily release
buf_pool->mutex. */ buf_pool->mutex. */
buf_page_t* block, /* in: block to be freed */ buf_page_t* block, /* 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);
/* in: pointer to a variable that will
be assigned TRUE if buf_pool->mutex
was temporarily released, or NULL */
/********************************************************************** /**********************************************************************
Look for a replaceable block from the end of the LRU list and put it to Look for a replaceable block from the end of the LRU list and put it to
the free list if found. */ the free list if found. */
......
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