Commit e2db2a87 authored by marko's avatar marko

branches/zip: buf_pool_page_hash_rebuild(): Rebuild also buf_pool->zip_hash

and add compressed-only pages to buf_pool->page_hash.

BUF_POOL_ZIP_FOLD(), BUF_POOL_ZIP_FOLD_PTR(), BUF_POOL_ZIP_FOLD_BPAGE():
Macros for computing buf_pool->zip_hash fold values.  Make use of these
in buf0buddy.c.

buf0buddy.c: Replace some ptr == ut_align_down(ptr, ...) in assertions with
!ut_align_offset(ptr, ...).
parent 91c87cd3
...@@ -96,7 +96,7 @@ buf_buddy_block_free( ...@@ -96,7 +96,7 @@ buf_buddy_block_free(
/*=================*/ /*=================*/
void* buf) /* in: buffer frame to deallocate */ void* buf) /* in: buffer frame to deallocate */
{ {
ulint fold = (ulint) buf / UNIV_PAGE_SIZE; const ulint fold = BUF_POOL_ZIP_FOLD_PTR(buf);
buf_page_t* bpage; buf_page_t* bpage;
buf_block_t* block; buf_block_t* block;
...@@ -104,7 +104,7 @@ buf_buddy_block_free( ...@@ -104,7 +104,7 @@ buf_buddy_block_free(
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex)); ut_a(!mutex_own(&buf_pool->zip_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(buf == ut_align_down(buf, UNIV_PAGE_SIZE)); ut_a(!ut_align_offset(buf, UNIV_PAGE_SIZE));
HASH_SEARCH(hash, buf_pool->zip_hash, fold, bpage, HASH_SEARCH(hash, buf_pool->zip_hash, fold, bpage,
((buf_block_t*) bpage)->frame == buf); ((buf_block_t*) bpage)->frame == buf);
...@@ -128,7 +128,7 @@ buf_buddy_block_register( ...@@ -128,7 +128,7 @@ buf_buddy_block_register(
/*=====================*/ /*=====================*/
buf_block_t* block) /* in: buffer frame to allocate */ buf_block_t* block) /* in: buffer frame to allocate */
{ {
ulint fold; const ulint fold = BUF_POOL_ZIP_FOLD(block);
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
ut_a(!mutex_own(&buf_pool->zip_mutex)); ut_a(!mutex_own(&buf_pool->zip_mutex));
...@@ -136,9 +136,7 @@ buf_buddy_block_register( ...@@ -136,9 +136,7 @@ buf_buddy_block_register(
buf_block_set_state(block, BUF_BLOCK_MEMORY); buf_block_set_state(block, BUF_BLOCK_MEMORY);
ut_a(block->frame); ut_a(block->frame);
ut_a(block->frame == ut_align_down(block->frame, UNIV_PAGE_SIZE)); ut_a(!ut_align_offset(block->frame, UNIV_PAGE_SIZE));
fold = (ulint) block->frame / UNIV_PAGE_SIZE;
HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page); HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page);
} }
......
...@@ -1167,13 +1167,23 @@ buf_pool_page_hash_rebuild(void) ...@@ -1167,13 +1167,23 @@ buf_pool_page_hash_rebuild(void)
ulint n_chunks; ulint n_chunks;
buf_chunk_t* chunk; buf_chunk_t* chunk;
hash_table_t* page_hash; hash_table_t* page_hash;
hash_table_t* zip_hash;
buf_page_t* b;
mutex_enter(&buf_pool->mutex); mutex_enter(&buf_pool->mutex);
/* Free, create, and populate the hash table. */ /* Free, create, and populate the hash table. */
hash_table_free(buf_pool->page_hash); hash_table_free(buf_pool->page_hash);
buf_pool->page_hash = page_hash = hash_create(2 * buf_pool->curr_size); buf_pool->page_hash = page_hash = hash_create(2 * buf_pool->curr_size);
/* TODO: buf_pool->zip_hash */ zip_hash = hash_create(2 * buf_pool->curr_size);
HASH_MIGRATE(buf_pool->zip_hash, zip_hash, buf_page_t, hash,
BUF_POOL_ZIP_FOLD_BPAGE);
hash_table_free(buf_pool->zip_hash);
buf_pool->zip_hash = zip_hash;
/* Insert the uncompressed file pages to buf_pool->page_hash. */
chunk = buf_pool->chunks; chunk = buf_pool->chunks;
n_chunks = buf_pool->n_chunks; n_chunks = buf_pool->n_chunks;
...@@ -1194,6 +1204,40 @@ buf_pool_page_hash_rebuild(void) ...@@ -1194,6 +1204,40 @@ buf_pool_page_hash_rebuild(void)
} }
} }
/* Insert the compressed-only pages to buf_pool->page_hash.
All such blocks are either in buf_pool->zip_clean or
in buf_pool->flush_list. */
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);
HASH_INSERT(buf_page_t, hash, page_hash,
buf_page_address_fold(b->space, b->offset), b);
}
for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
b = UT_LIST_GET_NEXT(list, b)) {
switch (buf_page_get_state(b)) {
case BUF_BLOCK_ZIP_DIRTY:
HASH_INSERT(buf_page_t, hash, page_hash,
buf_page_address_fold(b->space,
b->offset), b);
break;
case BUF_BLOCK_FILE_PAGE:
/* uncompressed page */
break;
case BUF_BLOCK_ZIP_FREE:
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_NOT_USED:
case BUF_BLOCK_READY_FOR_USE:
case BUF_BLOCK_MEMORY:
case BUF_BLOCK_REMOVE_HASH:
ut_error;
break;
}
}
mutex_exit(&buf_pool->mutex); mutex_exit(&buf_pool->mutex);
} }
......
...@@ -1120,6 +1120,12 @@ struct buf_block_struct{ ...@@ -1120,6 +1120,12 @@ struct buf_block_struct{
(buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \ (buf_block_get_state(block) >= BUF_BLOCK_NOT_USED \
&& (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH)) && (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH))
/**************************************************************************
Compute the hash fold value for blocks in buf_pool->zip_hash. */
#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / UNIV_PAGE_SIZE)
#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
/* The buffer pool structure. NOTE! The definition appears here only for /* The buffer pool structure. NOTE! The definition appears here only for
other modules of this directory (buf) to see it. Do not use from outside! */ other modules of this directory (buf) to see it. Do not use from outside! */
......
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