From 0fb620f58d956b8f3b51a9a707574457995b8853 Mon Sep 17 00:00:00 2001 From: marko Date: Fri, 15 Dec 2006 14:47:04 +0000 Subject: [PATCH] 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. --- buf/buf0flu.c | 47 +++++++++++++++++++++++++++++++++++++--------- buf/buf0lru.c | 7 +------ include/buf0buf.ic | 8 ++++++-- include/buf0flu.h | 7 +++++++ 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/buf/buf0flu.c b/buf/buf0flu.c index ffffa651f1c..33820d7d670 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -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]--; diff --git a/buf/buf0lru.c b/buf/buf0lru.c index 0cb6006252a..a5bdce1de0b 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -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 */ diff --git a/include/buf0buf.ic b/include/buf0buf.ic index 54c89c1f3a5..b766d40c40b 100644 --- a/include/buf0buf.ic +++ b/include/buf0buf.ic @@ -163,10 +163,14 @@ buf_page_set_state( switch (old_state) { case BUF_BLOCK_ZIP_FREE: - case BUF_BLOCK_ZIP_PAGE: - case BUF_BLOCK_ZIP_DIRTY: ut_error; break; + case BUF_BLOCK_ZIP_PAGE: + ut_a(state == BUF_BLOCK_ZIP_DIRTY); + break; + case BUF_BLOCK_ZIP_DIRTY: + ut_a(state == BUF_BLOCK_ZIP_PAGE); + break; case BUF_BLOCK_NOT_USED: ut_a(state == BUF_BLOCK_READY_FOR_USE); break; diff --git a/include/buf0flu.h b/include/buf0flu.h index 47a25f3c2de..49c1455ef61 100644 --- a/include/buf0flu.h +++ b/include/buf0flu.h @@ -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. */