Commit 6f306fad 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 132d888b
......@@ -3625,12 +3625,12 @@ btr_blob_free(
&& buf_block_get_space(block) == space
&& 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) {
/* Attempt to deallocate the uncompressed page
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*
buf_buddy_alloc_clean(
/*==================*/
/* 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;
......@@ -297,7 +300,7 @@ buf_buddy_alloc_clean(
for (; j--; bpage = UT_LIST_GET_NEXT(list, bpage)) {
if (bpage->zip.ssize != dummy_zip.ssize
|| !buf_LRU_free_block(bpage, FALSE)) {
|| !buf_LRU_free_block(bpage, FALSE, lru)) {
continue;
}
......@@ -344,7 +347,7 @@ free_LRU:
mutex_enter(block_mutex);
/* 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);
continue;
......@@ -433,7 +436,7 @@ buf_buddy_alloc_low(
/* Try replacing a clean page in the buffer pool. */
block = buf_buddy_alloc_clean(i);
block = buf_buddy_alloc_clean(i, lru);
if (block) {
......
......@@ -1079,7 +1079,8 @@ shrink_again:
buf_LRU_make_block_old(&block->page);
dirty++;
} else if (!buf_LRU_free_block(&block->page, TRUE)) {
} else if (!buf_LRU_free_block(&block->page,
TRUE, NULL)) {
nonfree++;
}
......@@ -1513,7 +1514,7 @@ lookup:
break;
case BUF_BLOCK_FILE_PAGE:
/* 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);
goto lookup;
......
......@@ -279,7 +279,7 @@ buf_LRU_search_and_free_block(
= buf_page_get_mutex(bpage);
mutex_enter(block_mutex);
freed = buf_LRU_free_block(bpage, TRUE);
freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(block_mutex);
if (freed) {
......@@ -302,7 +302,7 @@ buf_LRU_search_and_free_block(
= buf_page_get_mutex(bpage);
mutex_enter(block_mutex);
freed = buf_LRU_free_block(bpage, TRUE);
freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(block_mutex);
if (freed) {
......@@ -330,7 +330,7 @@ buf_LRU_search_and_free_block(
buf_block_t* block = (buf_block_t*) bpage;
mutex_enter(&block->mutex);
freed = buf_LRU_free_block(bpage, TRUE);
freed = buf_LRU_free_block(bpage, TRUE, NULL);
mutex_exit(&block->mutex);
if (freed) {
......@@ -938,8 +938,12 @@ buf_LRU_free_block(
it will not temporarily release
buf_pool->mutex. */
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 */
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;
mutex_t* block_mutex = buf_page_get_mutex(bpage);
......@@ -1054,6 +1058,10 @@ alloc:
b->io_fix = BUF_IO_READ;
}
if (buf_pool_mutex_released) {
*buf_pool_mutex_released = TRUE;
}
mutex_exit(&buf_pool->mutex);
mutex_exit(block_mutex);
......
......@@ -85,8 +85,12 @@ buf_LRU_free_block(
it will not temporarily release
buf_pool->mutex. */
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 */
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
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