From 8af159117ee0644ba1e0603d9aeba9c810afc953 Mon Sep 17 00:00:00 2001 From: marko <> Date: Tue, 9 Jan 2007 12:35:42 +0000 Subject: [PATCH] branches/zip: buf_page_t: Introduce the field in_flush_list #ifdef UNIV_DEBUG. buf_flush_batch(): Remove the local variable "found". --- buf/buf0buf.c | 13 +++++++++++++ buf/buf0flu.c | 26 +++++++++++++++++--------- buf/buf0lru.c | 4 ++++ include/buf0buf.h | 5 +++++ include/buf0buf.ic | 1 + 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/buf/buf0buf.c b/buf/buf0buf.c index a1035f2531c..245a6bc8c2f 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -612,6 +612,7 @@ buf_block_init( block->index = NULL; #ifdef UNIV_DEBUG + block->page.in_flush_list = FALSE; block->page.in_free_list = FALSE; block->page.in_LRU_list = FALSE; block->n_pointers = 0; @@ -851,6 +852,7 @@ buf_chunk_free( ut_a(!block->page.zip.data); ut_ad(!block->page.in_LRU_list); + ut_ad(!block->page.in_flush_list); /* Remove the block from the free list. */ ut_ad(block->page.in_free_list); UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); @@ -1211,6 +1213,7 @@ buf_pool_page_hash_rebuild(void) for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b; b = UT_LIST_GET_NEXT(list, b)) { ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE); + ut_ad(!b->in_flush_list); HASH_INSERT(buf_page_t, hash, page_hash, buf_page_address_fold(b->space, b->offset), b); @@ -1218,6 +1221,8 @@ buf_pool_page_hash_rebuild(void) for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; b = UT_LIST_GET_NEXT(list, b)) { + ut_ad(b->in_flush_list); + switch (buf_page_get_state(b)) { case BUF_BLOCK_ZIP_DIRTY: HASH_INSERT(buf_page_t, hash, page_hash, @@ -2138,6 +2143,10 @@ buf_page_init_for_read( buf_page_t* b; b = UT_LIST_GET_PREV(list, bpage); + ut_ad(bpage->in_flush_list); + ut_ad(!block->page.in_flush_list); + ut_d(bpage->in_flush_list = FALSE); + ut_d(block->page.in_flush_list = TRUE); UT_LIST_REMOVE(list, buf_pool->flush_list, bpage); @@ -2707,6 +2716,8 @@ buf_validate(void) for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; b = UT_LIST_GET_NEXT(list, b)) { + ut_ad(b->in_flush_list); + switch (buf_page_get_state(b)) { case BUF_BLOCK_ZIP_DIRTY: ut_a(b->oldest_modification); @@ -2950,6 +2961,8 @@ buf_get_latched_pages_number(void) for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; b = UT_LIST_GET_NEXT(list, b)) { + ut_ad(b->in_flush_list); + switch (buf_page_get_state(b)) { case BUF_BLOCK_ZIP_DIRTY: if (b->buf_fix_count != 0 diff --git a/buf/buf0flu.c b/buf/buf0flu.c index 973efe3a7ef..37daf07e434 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -68,6 +68,8 @@ buf_flush_insert_into_flush_list( /* fall through */ case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_FILE_PAGE: + ut_ad(!bpage->in_flush_list); + ut_a(bpage->in_flush_list = TRUE); UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage); break; case BUF_BLOCK_ZIP_FREE: @@ -124,10 +126,14 @@ buf_flush_insert_sorted_into_flush_list( b = UT_LIST_GET_FIRST(buf_pool->flush_list); while (b && b->oldest_modification > bpage->oldest_modification) { + ut_ad(b->in_flush_list); prev_b = b; b = UT_LIST_GET_NEXT(list, b); } + ut_ad(!bpage->in_flush_list); + ut_d(bpage->in_flush_list = TRUE); + if (prev_b == NULL) { UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage); } else { @@ -223,6 +229,9 @@ buf_flush_remove( ut_a(mutex_own(&buf_pool->mutex)); #endif /* UNIV_SYNC_DEBUG */ + ut_ad(bpage->in_flush_list); + ut_d(bpage->in_flush_list = FALSE); + switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: /* clean compressed pages should not be on the flush list */ @@ -972,7 +981,6 @@ buf_flush_batch( ulint old_page_count; ulint space; ulint offset; - ibool found; ut_ad((flush_type == BUF_FLUSH_LRU) || (flush_type == BUF_FLUSH_LIST)); @@ -995,6 +1003,7 @@ buf_flush_batch( buf_pool->init_flush[flush_type] = TRUE; for (;;) { +flush_next: /* If we have flushed enough, leave the loop */ if (page_count >= min_n) { @@ -1016,17 +1025,16 @@ buf_flush_batch( break; } + ut_ad(bpage->in_flush_list); } - found = FALSE; - /* Note that after finding a single flushable page, we try to flush also all its neighbors, and after that start from the END of the LRU list or flush list again: the list may change during the flushing and we cannot safely preserve within this function a pointer to a block in the list! */ - while ((bpage != NULL) && !found) { + do { mutex_t* block_mutex = buf_page_get_mutex(bpage); ut_a(buf_page_in_file(bpage)); @@ -1035,7 +1043,6 @@ buf_flush_batch( if (buf_flush_ready_for_flush(bpage, flush_type)) { - found = TRUE; space = buf_page_get_space(bpage); offset = buf_page_get_page_no(bpage); @@ -1053,6 +1060,7 @@ buf_flush_batch( page_count - old_page_count); */ mutex_enter(&(buf_pool->mutex)); + goto flush_next; } else if (flush_type == BUF_FLUSH_LRU) { @@ -1065,14 +1073,13 @@ buf_flush_batch( mutex_exit(block_mutex); bpage = UT_LIST_GET_PREV(list, bpage); + ut_ad(!bpage || bpage->in_flush_list); } - } + } while (bpage != NULL); /* If we could not find anything to flush, leave the loop */ - if (!found) { - break; - } + break; } buf_pool->init_flush[flush_type] = FALSE; @@ -1216,6 +1223,7 @@ buf_flush_validate_low(void) while (bpage != NULL) { const ib_uint64_t om = bpage->oldest_modification; + ut_ad(bpage->in_flush_list); ut_a(buf_page_in_file(bpage)); ut_a(om > 0); diff --git a/buf/buf0lru.c b/buf/buf0lru.c index ed6310c9b20..a6e8fc9afce 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -371,6 +371,7 @@ buf_LRU_get_free_only(void) if (block) { ut_ad(block->page.in_free_list); ut_d(block->page.in_free_list = FALSE); + ut_ad(!block->page.in_flush_list); ut_ad(!block->page.in_LRU_list); ut_a(!buf_page_in_file(&block->page)); UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); @@ -1022,6 +1023,8 @@ buf_LRU_block_free_non_file_page( ut_ad(block->n_pointers == 0); ut_ad(!block->page.in_free_list); + ut_ad(!block->page.in_flush_list); + ut_ad(!block->page.in_LRU_list); buf_block_set_state(block, BUF_BLOCK_NOT_USED); @@ -1131,6 +1134,7 @@ buf_LRU_block_remove_hashed_page( switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: ut_ad(!bpage->in_free_list); + ut_ad(!bpage->in_flush_list); ut_ad(!bpage->in_LRU_list); ut_a(bpage->zip.data); ut_a(buf_page_get_zip_size(bpage)); diff --git a/include/buf0buf.h b/include/buf0buf.h index 736d2fc15cc..b267790fd1f 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -959,6 +959,11 @@ struct buf_page_struct{ BUF_BLOCK_ZIP_PAGE: zip_clean BUF_BLOCK_ZIP_FREE: zip_free[] */ #ifdef UNIV_DEBUG + ibool in_flush_list; /* TRUE if in buf_pool->flush_list; + when buf_pool->mutex is free, the + following should hold: in_flush_list + == (state == BUF_BLOCK_FILE_PAGE + || state == BUF_BLOCK_ZIP_DIRTY) */ ibool in_free_list; /* TRUE if in buf_pool->free; when buf_pool->mutex is free, the following should hold: in_free_list diff --git a/include/buf0buf.ic b/include/buf0buf.ic index f41e825592b..5656ed3012e 100644 --- a/include/buf0buf.ic +++ b/include/buf0buf.ic @@ -83,6 +83,7 @@ buf_pool_get_oldest_modification(void) if (bpage == NULL) { lsn = 0; } else { + ut_ad(bpage->in_flush_list); lsn = bpage->oldest_modification; }