Commit 2696aa6d authored by marko's avatar marko

branches/zip: Remove buf_block_t:free_list. Rename buf_page_t:flush_list

to free_or_flush_list.  The list node pointers can be shared, because a
block can never be belong to both lists at the same time.
parent 7f903fa0
...@@ -610,9 +610,8 @@ buf_block_init( ...@@ -610,9 +610,8 @@ buf_block_init(
block->check_index_page_at_flush = FALSE; block->check_index_page_at_flush = FALSE;
block->index = NULL; block->index = NULL;
block->in_free_list = FALSE;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
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;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -694,8 +693,9 @@ buf_chunk_init( ...@@ -694,8 +693,9 @@ buf_chunk_init(
memset(block->frame, '\0', UNIV_PAGE_SIZE); memset(block->frame, '\0', UNIV_PAGE_SIZE);
#endif #endif
/* Add the block to the free list */ /* Add the block to the free list */
UT_LIST_ADD_LAST(free, buf_pool->free, block); UT_LIST_ADD_LAST(free_or_flush_list, buf_pool->free,
block->in_free_list = TRUE; (&block->page));
ut_d(block->page.in_free_list = TRUE);
block++; block++;
frame += UNIV_PAGE_SIZE; frame += UNIV_PAGE_SIZE;
...@@ -793,8 +793,9 @@ buf_chunk_free( ...@@ -793,8 +793,9 @@ buf_chunk_free(
ut_ad(!block->page.in_LRU_list); ut_ad(!block->page.in_LRU_list);
/* Remove the block from the free list. */ /* Remove the block from the free list. */
ut_a(block->in_free_list); ut_ad(block->page.in_free_list);
UT_LIST_REMOVE(free, buf_pool->free, block); UT_LIST_REMOVE(free_or_flush_list, buf_pool->free,
(&block->page));
/* Free the latches. */ /* Free the latches. */
mutex_free(&block->mutex); mutex_free(&block->mutex);
......
...@@ -61,7 +61,7 @@ buf_flush_insert_into_flush_list( ...@@ -61,7 +61,7 @@ buf_flush_insert_into_flush_list(
|| (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification || (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
<= bpage->oldest_modification)); <= bpage->oldest_modification));
UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, bpage); UT_LIST_ADD_FIRST(free_or_flush_list, buf_pool->flush_list, bpage);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
ut_a(buf_flush_validate_low()); ut_a(buf_flush_validate_low());
...@@ -90,14 +90,15 @@ buf_flush_insert_sorted_into_flush_list( ...@@ -90,14 +90,15 @@ buf_flush_insert_sorted_into_flush_list(
while (b && b->oldest_modification > bpage->oldest_modification) { while (b && b->oldest_modification > bpage->oldest_modification) {
prev_b = b; prev_b = b;
b = UT_LIST_GET_NEXT(flush_list, b); b = UT_LIST_GET_NEXT(free_or_flush_list, b);
} }
if (prev_b == NULL) { if (prev_b == NULL) {
UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, bpage); UT_LIST_ADD_FIRST(free_or_flush_list,
buf_pool->flush_list, bpage);
} else { } else {
UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b, UT_LIST_INSERT_AFTER(free_or_flush_list,
bpage); buf_pool->flush_list, prev_b, bpage);
} }
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
...@@ -194,9 +195,10 @@ buf_flush_write_complete( ...@@ -194,9 +195,10 @@ buf_flush_write_complete(
bpage->oldest_modification = 0; bpage->oldest_modification = 0;
UT_LIST_REMOVE(flush_list, buf_pool->flush_list, bpage); UT_LIST_REMOVE(free_or_flush_list, buf_pool->flush_list, bpage);
ut_d(UT_LIST_VALIDATE(flush_list, buf_page_t, buf_pool->flush_list)); ut_d(UT_LIST_VALIDATE(free_or_flush_list, buf_page_t,
buf_pool->flush_list));
flush_type = buf_page_get_flush_type(bpage); flush_type = buf_page_get_flush_type(bpage);
buf_pool->n_flush[flush_type]--; buf_pool->n_flush[flush_type]--;
...@@ -998,7 +1000,8 @@ buf_flush_batch( ...@@ -998,7 +1000,8 @@ buf_flush_batch(
mutex_exit(block_mutex); mutex_exit(block_mutex);
bpage = UT_LIST_GET_PREV(flush_list, bpage); bpage = UT_LIST_GET_PREV(free_or_flush_list,
bpage);
} }
} }
...@@ -1145,7 +1148,7 @@ buf_flush_validate_low(void) ...@@ -1145,7 +1148,7 @@ buf_flush_validate_low(void)
buf_page_t* bpage; buf_page_t* bpage;
ib_uint64_t om; ib_uint64_t om;
UT_LIST_VALIDATE(flush_list, buf_page_t, buf_pool->flush_list); UT_LIST_VALIDATE(free_or_flush_list, buf_page_t, buf_pool->flush_list);
bpage = UT_LIST_GET_FIRST(buf_pool->flush_list); bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
...@@ -1154,7 +1157,7 @@ buf_flush_validate_low(void) ...@@ -1154,7 +1157,7 @@ buf_flush_validate_low(void)
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
ut_a(om > 0); ut_a(om > 0);
bpage = UT_LIST_GET_NEXT(flush_list, bpage); bpage = UT_LIST_GET_NEXT(free_or_flush_list, bpage);
if (bpage) { if (bpage) {
ut_a(om >= bpage->oldest_modification); ut_a(om >= bpage->oldest_modification);
......
...@@ -138,7 +138,7 @@ scan_again: ...@@ -138,7 +138,7 @@ scan_again:
blocks */ blocks */
bpage->oldest_modification = 0; bpage->oldest_modification = 0;
UT_LIST_REMOVE(flush_list, UT_LIST_REMOVE(free_or_flush_list,
buf_pool->flush_list, buf_pool->flush_list,
bpage); bpage);
} }
...@@ -457,12 +457,13 @@ loop: ...@@ -457,12 +457,13 @@ loop:
/* If there is a block in the free list, take it */ /* If there is a block in the free list, take it */
if (UT_LIST_GET_LEN(buf_pool->free) > 0) { if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
block = UT_LIST_GET_FIRST(buf_pool->free); block = (buf_block_t*) UT_LIST_GET_FIRST(buf_pool->free);
ut_a(block->in_free_list); ut_ad(block->page.in_free_list);
UT_LIST_REMOVE(free, buf_pool->free, block); ut_d(block->page.in_free_list = FALSE);
block->in_free_list = FALSE;
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
ut_ad(!block->page.in_LRU_list); ut_ad(!block->page.in_LRU_list);
ut_a(!buf_page_in_file(&block->page));
UT_LIST_REMOVE(free_or_flush_list, buf_pool->free,
(&block->page));
if (buf_block_get_zip_size(block) != zip_size) { if (buf_block_get_zip_size(block) != zip_size) {
page_zip_set_size(&block->page.zip, zip_size); page_zip_set_size(&block->page.zip, zip_size);
...@@ -895,7 +896,7 @@ buf_LRU_block_free_non_file_page( ...@@ -895,7 +896,7 @@ buf_LRU_block_free_non_file_page(
} }
ut_ad(block->n_pointers == 0); ut_ad(block->n_pointers == 0);
ut_a(!block->in_free_list); ut_ad(!block->page.in_free_list);
buf_block_set_state(block, BUF_BLOCK_NOT_USED); buf_block_set_state(block, BUF_BLOCK_NOT_USED);
...@@ -914,8 +915,8 @@ buf_LRU_block_free_non_file_page( ...@@ -914,8 +915,8 @@ buf_LRU_block_free_non_file_page(
page_zip_set_size(&block->page.zip, 0); page_zip_set_size(&block->page.zip, 0);
} }
UT_LIST_ADD_FIRST(free, buf_pool->free, block); UT_LIST_ADD_FIRST(free_or_flush_list, buf_pool->free, (&block->page));
block->in_free_list = TRUE; ut_d(block->page.in_free_list = TRUE);
UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE); UNIV_MEM_INVALID(block->frame, UNIV_PAGE_SIZE);
} }
...@@ -1083,16 +1084,13 @@ buf_LRU_validate(void) ...@@ -1083,16 +1084,13 @@ buf_LRU_validate(void)
ut_a(buf_pool->LRU_old_len == old_len); ut_a(buf_pool->LRU_old_len == old_len);
} }
UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free); UT_LIST_VALIDATE(free_or_flush_list, buf_page_t, buf_pool->free);
{ for (bpage = UT_LIST_GET_FIRST(buf_pool->free);
buf_block_t* block = UT_LIST_GET_FIRST(buf_pool->free); bpage != NULL;
bpage = UT_LIST_GET_NEXT(free_or_flush_list, bpage)) {
while (block != NULL) { ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED);
ut_a(buf_block_get_state(block) == BUF_BLOCK_NOT_USED);
block = UT_LIST_GET_NEXT(free, block);
}
} }
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
......
...@@ -915,9 +915,16 @@ struct buf_page_struct{ ...@@ -915,9 +915,16 @@ struct buf_page_struct{
/* 2. Page flushing fields; protected by buf_pool->mutex */ /* 2. Page flushing fields; protected by buf_pool->mutex */
UT_LIST_NODE_T(buf_page_t) flush_list; UT_LIST_NODE_T(buf_page_t) free_or_flush_list;
/* node of the modified, not yet /* if buf_page_in_file(), this is a
flushed blocks list */ node of the modified, not yet
flushed blocks list;
if state == BUF_BLOCK_NOT_USED,
this is a node of the "free" list */
#ifdef UNIV_DEBUG
ibool in_free_list; /* TRUE if in the free list; used in
debugging */
#endif /* UNIV_DEBUG */
ib_uint64_t newest_modification; ib_uint64_t newest_modification;
/* log sequence number of the youngest /* log sequence number of the youngest
modification to this block, zero if modification to this block, zero if
...@@ -994,12 +1001,6 @@ struct buf_block_struct{ ...@@ -994,12 +1001,6 @@ struct buf_block_struct{
but this flag is not set because but this flag is not set because
we do not keep track of all pages */ we do not keep track of all pages */
/* 3. LRU replacement algorithm fields */
UT_LIST_NODE_T(buf_block_t) free;
/* node of the free block list */
ibool in_free_list; /* TRUE if in the free list; used in
debugging */
/* 4. Optimistic search field */ /* 4. Optimistic search field */
ib_uint64_t modify_clock; /* this clock is incremented every ib_uint64_t modify_clock; /* this clock is incremented every
...@@ -1137,7 +1138,7 @@ struct buf_pool_struct{ ...@@ -1137,7 +1138,7 @@ struct buf_pool_struct{
/* 3. LRU replacement algorithm fields */ /* 3. LRU replacement algorithm fields */
UT_LIST_BASE_NODE_T(buf_block_t) free; UT_LIST_BASE_NODE_T(buf_page_t) free;
/* base node of the free block list */ /* base node of the free block list */
UT_LIST_BASE_NODE_T(buf_page_t) LRU; UT_LIST_BASE_NODE_T(buf_page_t) LRU;
/* base node of the LRU list */ /* base node of the LRU list */
......
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