Commit 8af15911 authored by marko's avatar marko

branches/zip: buf_page_t: Introduce the field in_flush_list #ifdef UNIV_DEBUG.

buf_flush_batch(): Remove the local variable "found".
parent e8d77f6d
...@@ -612,6 +612,7 @@ buf_block_init( ...@@ -612,6 +612,7 @@ buf_block_init(
block->index = NULL; block->index = NULL;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
block->page.in_flush_list = FALSE;
block->page.in_free_list = FALSE; block->page.in_free_list = FALSE;
block->page.in_LRU_list = FALSE; block->page.in_LRU_list = FALSE;
block->n_pointers = 0; block->n_pointers = 0;
...@@ -851,6 +852,7 @@ buf_chunk_free( ...@@ -851,6 +852,7 @@ buf_chunk_free(
ut_a(!block->page.zip.data); ut_a(!block->page.zip.data);
ut_ad(!block->page.in_LRU_list); ut_ad(!block->page.in_LRU_list);
ut_ad(!block->page.in_flush_list);
/* Remove the block from the free list. */ /* Remove the block from the free list. */
ut_ad(block->page.in_free_list); ut_ad(block->page.in_free_list);
UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); UT_LIST_REMOVE(list, buf_pool->free, (&block->page));
...@@ -1211,6 +1213,7 @@ buf_pool_page_hash_rebuild(void) ...@@ -1211,6 +1213,7 @@ buf_pool_page_hash_rebuild(void)
for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b; for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b;
b = UT_LIST_GET_NEXT(list, b)) { b = UT_LIST_GET_NEXT(list, b)) {
ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE); 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, HASH_INSERT(buf_page_t, hash, page_hash,
buf_page_address_fold(b->space, b->offset), b); buf_page_address_fold(b->space, b->offset), b);
...@@ -1218,6 +1221,8 @@ buf_pool_page_hash_rebuild(void) ...@@ -1218,6 +1221,8 @@ buf_pool_page_hash_rebuild(void)
for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
b = UT_LIST_GET_NEXT(list, b)) { b = UT_LIST_GET_NEXT(list, b)) {
ut_ad(b->in_flush_list);
switch (buf_page_get_state(b)) { switch (buf_page_get_state(b)) {
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
HASH_INSERT(buf_page_t, hash, page_hash, HASH_INSERT(buf_page_t, hash, page_hash,
...@@ -2138,6 +2143,10 @@ buf_page_init_for_read( ...@@ -2138,6 +2143,10 @@ buf_page_init_for_read(
buf_page_t* b; buf_page_t* b;
b = UT_LIST_GET_PREV(list, bpage); 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, UT_LIST_REMOVE(list, buf_pool->flush_list,
bpage); bpage);
...@@ -2707,6 +2716,8 @@ buf_validate(void) ...@@ -2707,6 +2716,8 @@ buf_validate(void)
for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
b = UT_LIST_GET_NEXT(list, b)) { b = UT_LIST_GET_NEXT(list, b)) {
ut_ad(b->in_flush_list);
switch (buf_page_get_state(b)) { switch (buf_page_get_state(b)) {
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
ut_a(b->oldest_modification); ut_a(b->oldest_modification);
...@@ -2950,6 +2961,8 @@ buf_get_latched_pages_number(void) ...@@ -2950,6 +2961,8 @@ buf_get_latched_pages_number(void)
for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
b = UT_LIST_GET_NEXT(list, b)) { b = UT_LIST_GET_NEXT(list, b)) {
ut_ad(b->in_flush_list);
switch (buf_page_get_state(b)) { switch (buf_page_get_state(b)) {
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
if (b->buf_fix_count != 0 if (b->buf_fix_count != 0
......
...@@ -68,6 +68,8 @@ buf_flush_insert_into_flush_list( ...@@ -68,6 +68,8 @@ buf_flush_insert_into_flush_list(
/* fall through */ /* fall through */
case BUF_BLOCK_ZIP_DIRTY: case BUF_BLOCK_ZIP_DIRTY:
case BUF_BLOCK_FILE_PAGE: 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); UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage);
break; break;
case BUF_BLOCK_ZIP_FREE: case BUF_BLOCK_ZIP_FREE:
...@@ -124,10 +126,14 @@ buf_flush_insert_sorted_into_flush_list( ...@@ -124,10 +126,14 @@ buf_flush_insert_sorted_into_flush_list(
b = UT_LIST_GET_FIRST(buf_pool->flush_list); b = UT_LIST_GET_FIRST(buf_pool->flush_list);
while (b && b->oldest_modification > bpage->oldest_modification) { while (b && b->oldest_modification > bpage->oldest_modification) {
ut_ad(b->in_flush_list);
prev_b = b; prev_b = b;
b = UT_LIST_GET_NEXT(list, 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) { if (prev_b == NULL) {
UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage); UT_LIST_ADD_FIRST(list, buf_pool->flush_list, bpage);
} else { } else {
...@@ -223,6 +229,9 @@ buf_flush_remove( ...@@ -223,6 +229,9 @@ buf_flush_remove(
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(bpage->in_flush_list);
ut_d(bpage->in_flush_list = FALSE);
switch (buf_page_get_state(bpage)) { switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_PAGE:
/* clean compressed pages should not be on the flush list */ /* clean compressed pages should not be on the flush list */
...@@ -972,7 +981,6 @@ buf_flush_batch( ...@@ -972,7 +981,6 @@ buf_flush_batch(
ulint old_page_count; ulint old_page_count;
ulint space; ulint space;
ulint offset; ulint offset;
ibool found;
ut_ad((flush_type == BUF_FLUSH_LRU) ut_ad((flush_type == BUF_FLUSH_LRU)
|| (flush_type == BUF_FLUSH_LIST)); || (flush_type == BUF_FLUSH_LIST));
...@@ -995,6 +1003,7 @@ buf_flush_batch( ...@@ -995,6 +1003,7 @@ buf_flush_batch(
buf_pool->init_flush[flush_type] = TRUE; buf_pool->init_flush[flush_type] = TRUE;
for (;;) { for (;;) {
flush_next:
/* If we have flushed enough, leave the loop */ /* If we have flushed enough, leave the loop */
if (page_count >= min_n) { if (page_count >= min_n) {
...@@ -1016,17 +1025,16 @@ buf_flush_batch( ...@@ -1016,17 +1025,16 @@ buf_flush_batch(
break; break;
} }
ut_ad(bpage->in_flush_list);
} }
found = FALSE;
/* Note that after finding a single flushable page, we try to /* Note that after finding a single flushable page, we try to
flush also all its neighbors, and after that start from the flush also all its neighbors, and after that start from the
END of the LRU list or flush list again: the list may change END of the LRU list or flush list again: the list may change
during the flushing and we cannot safely preserve within this during the flushing and we cannot safely preserve within this
function a pointer to a block in the list! */ function a pointer to a block in the list! */
while ((bpage != NULL) && !found) { do {
mutex_t* block_mutex = buf_page_get_mutex(bpage); mutex_t* block_mutex = buf_page_get_mutex(bpage);
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
...@@ -1035,7 +1043,6 @@ buf_flush_batch( ...@@ -1035,7 +1043,6 @@ buf_flush_batch(
if (buf_flush_ready_for_flush(bpage, flush_type)) { if (buf_flush_ready_for_flush(bpage, flush_type)) {
found = TRUE;
space = buf_page_get_space(bpage); space = buf_page_get_space(bpage);
offset = buf_page_get_page_no(bpage); offset = buf_page_get_page_no(bpage);
...@@ -1053,6 +1060,7 @@ buf_flush_batch( ...@@ -1053,6 +1060,7 @@ buf_flush_batch(
page_count - old_page_count); */ page_count - old_page_count); */
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
goto flush_next;
} else if (flush_type == BUF_FLUSH_LRU) { } else if (flush_type == BUF_FLUSH_LRU) {
...@@ -1065,14 +1073,13 @@ buf_flush_batch( ...@@ -1065,14 +1073,13 @@ buf_flush_batch(
mutex_exit(block_mutex); mutex_exit(block_mutex);
bpage = UT_LIST_GET_PREV(list, bpage); 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 we could not find anything to flush, leave the loop */
if (!found) { break;
break;
}
} }
buf_pool->init_flush[flush_type] = FALSE; buf_pool->init_flush[flush_type] = FALSE;
...@@ -1216,6 +1223,7 @@ buf_flush_validate_low(void) ...@@ -1216,6 +1223,7 @@ buf_flush_validate_low(void)
while (bpage != NULL) { while (bpage != NULL) {
const ib_uint64_t om = bpage->oldest_modification; const ib_uint64_t om = bpage->oldest_modification;
ut_ad(bpage->in_flush_list);
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
ut_a(om > 0); ut_a(om > 0);
......
...@@ -371,6 +371,7 @@ buf_LRU_get_free_only(void) ...@@ -371,6 +371,7 @@ buf_LRU_get_free_only(void)
if (block) { if (block) {
ut_ad(block->page.in_free_list); ut_ad(block->page.in_free_list);
ut_d(block->page.in_free_list = FALSE); ut_d(block->page.in_free_list = FALSE);
ut_ad(!block->page.in_flush_list);
ut_ad(!block->page.in_LRU_list); ut_ad(!block->page.in_LRU_list);
ut_a(!buf_page_in_file(&block->page)); ut_a(!buf_page_in_file(&block->page));
UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); UT_LIST_REMOVE(list, buf_pool->free, (&block->page));
...@@ -1022,6 +1023,8 @@ buf_LRU_block_free_non_file_page( ...@@ -1022,6 +1023,8 @@ buf_LRU_block_free_non_file_page(
ut_ad(block->n_pointers == 0); ut_ad(block->n_pointers == 0);
ut_ad(!block->page.in_free_list); 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); buf_block_set_state(block, BUF_BLOCK_NOT_USED);
...@@ -1131,6 +1134,7 @@ buf_LRU_block_remove_hashed_page( ...@@ -1131,6 +1134,7 @@ buf_LRU_block_remove_hashed_page(
switch (buf_page_get_state(bpage)) { switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_PAGE:
ut_ad(!bpage->in_free_list); ut_ad(!bpage->in_free_list);
ut_ad(!bpage->in_flush_list);
ut_ad(!bpage->in_LRU_list); ut_ad(!bpage->in_LRU_list);
ut_a(bpage->zip.data); ut_a(bpage->zip.data);
ut_a(buf_page_get_zip_size(bpage)); ut_a(buf_page_get_zip_size(bpage));
......
...@@ -959,6 +959,11 @@ struct buf_page_struct{ ...@@ -959,6 +959,11 @@ struct buf_page_struct{
BUF_BLOCK_ZIP_PAGE: zip_clean BUF_BLOCK_ZIP_PAGE: zip_clean
BUF_BLOCK_ZIP_FREE: zip_free[] */ BUF_BLOCK_ZIP_FREE: zip_free[] */
#ifdef UNIV_DEBUG #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 ibool in_free_list; /* TRUE if in buf_pool->free; when
buf_pool->mutex is free, the following buf_pool->mutex is free, the following
should hold: in_free_list should hold: in_free_list
......
...@@ -83,6 +83,7 @@ buf_pool_get_oldest_modification(void) ...@@ -83,6 +83,7 @@ buf_pool_get_oldest_modification(void)
if (bpage == NULL) { if (bpage == NULL) {
lsn = 0; lsn = 0;
} else { } else {
ut_ad(bpage->in_flush_list);
lsn = bpage->oldest_modification; lsn = bpage->oldest_modification;
} }
......
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