Commit 0fb620f5 authored by marko's avatar marko

branches/zip: Minor improvements.

buf_flush_remove(): New function, for removing a block from the flush list.
Sliced from buf_flush_write_complete().

buf_page_set_state(): Allow transitions between BUF_BLOCK_ZIP_PAGE
and BUF_BLOCK_ZIP_DIRTY.
parent 79782263
......@@ -176,6 +176,43 @@ buf_flush_ready_for_flush(
return(FALSE);
}
/************************************************************************
Remove a block from the flush list of modified blocks. */
void
buf_flush_remove(
/*=============*/
buf_page_t* bpage) /* in: pointer to the block in question */
{
#ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex));
#endif /* UNIV_SYNC_DEBUG */
switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_PAGE:
/* clean compressed pages should not be on the flush list */
case BUF_BLOCK_ZIP_FREE:
case BUF_BLOCK_NOT_USED:
case BUF_BLOCK_READY_FOR_USE:
case BUF_BLOCK_MEMORY:
case BUF_BLOCK_REMOVE_HASH:
ut_error;
return;
case BUF_BLOCK_ZIP_DIRTY:
mutex_enter(&buf_pool->zip_mutex);
buf_page_set_state(bpage, BUF_BLOCK_ZIP_PAGE);
mutex_exit(&buf_pool->zip_mutex);
/* fall through */
case BUF_BLOCK_FILE_PAGE:
UT_LIST_REMOVE(list, buf_pool->flush_list, bpage);
break;
}
bpage->oldest_modification = 0;
ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->flush_list));
}
/************************************************************************
Updates the flush system data structures when a write is completed. */
......@@ -187,16 +224,8 @@ buf_flush_write_complete(
enum buf_flush flush_type;
ut_ad(bpage);
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(buf_page_in_file(bpage));
bpage->oldest_modification = 0;
UT_LIST_REMOVE(list, buf_pool->flush_list, bpage);
ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->flush_list));
buf_flush_remove(bpage);
flush_type = buf_page_get_flush_type(bpage);
buf_pool->n_flush[flush_type]--;
......
......@@ -135,12 +135,7 @@ scan_again:
if (bpage->oldest_modification != 0) {
/* Remove from the flush list of modified
blocks */
bpage->oldest_modification = 0;
UT_LIST_REMOVE(list, buf_pool->flush_list,
bpage);
buf_flush_remove(bpage);
}
/* Remove from the LRU list */
......
......@@ -163,9 +163,13 @@ buf_page_set_state(
switch (old_state) {
case BUF_BLOCK_ZIP_FREE:
ut_error;
break;
case BUF_BLOCK_ZIP_PAGE:
ut_a(state == BUF_BLOCK_ZIP_DIRTY);
break;
case BUF_BLOCK_ZIP_DIRTY:
ut_error;
ut_a(state == BUF_BLOCK_ZIP_PAGE);
break;
case BUF_BLOCK_NOT_USED:
ut_a(state == BUF_BLOCK_READY_FOR_USE);
......
......@@ -14,6 +14,13 @@ Created 11/5/1995 Heikki Tuuri
#include "ut0byte.h"
#include "mtr0types.h"
/************************************************************************
Remove a block from the flush list of modified blocks. */
void
buf_flush_remove(
/*=============*/
buf_page_t* bpage); /* in: pointer to the block in question */
/************************************************************************
Updates the flush system data structures when a write is completed. */
......
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