Commit 6c0a4186 authored by marko's avatar marko

branches/zip: Allow some functions to work on compressed-only pages

(state == BUF_BLOCK_ZIP_PAGE).  Make use of buf_page_in_file()
and buf_page_get_mutex().

buf_block_get_newest_modification(): Rename to
buf_page_get_newest_modification().
parent 7b32620f
...@@ -1179,7 +1179,7 @@ buf_page_make_young( ...@@ -1179,7 +1179,7 @@ buf_page_make_young(
{ {
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); ut_a(buf_page_in_file(bpage));
buf_LRU_make_block_young(bpage); buf_LRU_make_block_young(bpage);
...@@ -1771,8 +1771,8 @@ buf_page_init_for_backup_restore( ...@@ -1771,8 +1771,8 @@ buf_page_init_for_backup_restore(
block->freed_page_clock = 0; block->freed_page_clock = 0;
block->newest_modification = 0; block->page.newest_modification = 0;
block->oldest_modification = 0; block->page.oldest_modification = 0;
block->page.state = BUF_BLOCK_FILE_PAGE; block->page.state = BUF_BLOCK_FILE_PAGE;
block->page.accessed = FALSE; block->page.accessed = FALSE;
......
...@@ -55,7 +55,7 @@ buf_flush_insert_into_flush_list( ...@@ -55,7 +55,7 @@ buf_flush_insert_into_flush_list(
ut_ad(mutex_own(&(buf_pool->mutex))); ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); ut_a(buf_page_in_file(bpage));
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification || (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
...@@ -113,9 +113,8 @@ ibool ...@@ -113,9 +113,8 @@ ibool
buf_flush_ready_for_replace( buf_flush_ready_for_replace(
/*========================*/ /*========================*/
/* out: TRUE if can replace immediately */ /* out: TRUE if can replace immediately */
buf_page_t* bpage) /* in: buffer control block, must be in state buf_page_t* bpage) /* in: buffer control block, must be
BUF_BLOCK_FILE_PAGE or BUF_BLOCK_ZIP_PAGE buf_page_in_file(bpage) and in the LRU list */
and in the LRU list */
{ {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(buf_pool->mutex))); ut_ad(mutex_own(&(buf_pool->mutex)));
...@@ -147,8 +146,8 @@ ibool ...@@ -147,8 +146,8 @@ ibool
buf_flush_ready_for_flush( buf_flush_ready_for_flush(
/*======================*/ /*======================*/
/* out: TRUE if can flush immediately */ /* out: TRUE if can flush immediately */
buf_page_t* bpage, /* in: buffer control block, must be in state buf_page_t* bpage, /* in: buffer control block, must be
BUF_BLOCK_FILE_PAGE */ buf_page_in_file(bpage) */
enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
{ {
ut_a(buf_page_in_file(bpage)); ut_a(buf_page_in_file(bpage));
...@@ -792,7 +791,7 @@ buf_flush_try_neighbors( ...@@ -792,7 +791,7 @@ buf_flush_try_neighbors(
enum buf_flush flush_type) /* in: BUF_FLUSH_LRU or enum buf_flush flush_type) /* in: BUF_FLUSH_LRU or
BUF_FLUSH_LIST */ BUF_FLUSH_LIST */
{ {
buf_block_t* block; buf_page_t* bpage;
ulint low, high; ulint low, high;
ulint count = 0; ulint count = 0;
ulint i; ulint i;
...@@ -820,16 +819,15 @@ buf_flush_try_neighbors( ...@@ -820,16 +819,15 @@ buf_flush_try_neighbors(
for (i = low; i < high; i++) { for (i = low; i < high; i++) {
block = (buf_block_t*) buf_page_hash_get(space, i); bpage = buf_page_hash_get(space, i);
ut_a(!block ut_a(!bpage || buf_page_in_file(bpage));
|| buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (!block) { if (!bpage) {
continue; continue;
} else if (flush_type == BUF_FLUSH_LRU && i != offset } else if (flush_type == BUF_FLUSH_LRU && i != offset
&& !buf_page_is_old(&block->page)) { && !buf_page_is_old(bpage)) {
/* We avoid flushing 'non-old' blocks in an LRU flush, /* We avoid flushing 'non-old' blocks in an LRU flush,
because the flushed blocks are soon freed */ because the flushed blocks are soon freed */
...@@ -837,10 +835,12 @@ buf_flush_try_neighbors( ...@@ -837,10 +835,12 @@ buf_flush_try_neighbors(
continue; continue;
} else { } else {
mutex_enter(&block->mutex); mutex_t* block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex);
if (buf_flush_ready_for_flush(&block->page, flush_type) if (buf_flush_ready_for_flush(bpage, flush_type)
&& (i == offset || !block->page.buf_fix_count)) { && (i == offset || !bpage->buf_fix_count)) {
/* We only try to flush those /* We only try to flush those
neighbors != offset where the buf fix count is neighbors != offset where the buf fix count is
zero, as we then know that we probably can zero, as we then know that we probably can
...@@ -849,10 +849,10 @@ buf_flush_try_neighbors( ...@@ -849,10 +849,10 @@ buf_flush_try_neighbors(
flush the doublewrite buffer before we start flush the doublewrite buffer before we start
waiting. */ waiting. */
mutex_exit(&block->mutex);
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
mutex_exit(block_mutex);
/* Note: as we release the buf_pool mutex /* Note: as we release the buf_pool mutex
above, in buf_flush_try_page we cannot be sure above, in buf_flush_try_page we cannot be sure
the page is still in a flushable state: the page is still in a flushable state:
...@@ -864,7 +864,7 @@ buf_flush_try_neighbors( ...@@ -864,7 +864,7 @@ buf_flush_try_neighbors(
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
} else { } else {
mutex_exit(&block->mutex); mutex_exit(block_mutex);
} }
} }
} }
...@@ -1151,7 +1151,7 @@ buf_flush_validate_low(void) ...@@ -1151,7 +1151,7 @@ buf_flush_validate_low(void)
while (bpage != NULL) { while (bpage != NULL) {
om = bpage->oldest_modification; om = bpage->oldest_modification;
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); 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(flush_list, bpage);
......
...@@ -378,10 +378,11 @@ Gets the youngest modification log sequence number for a frame. ...@@ -378,10 +378,11 @@ Gets the youngest modification log sequence number for a frame.
Returns zero if not file page or no modification occurred yet. */ Returns zero if not file page or no modification occurred yet. */
UNIV_INLINE UNIV_INLINE
ib_uint64_t ib_uint64_t
buf_block_get_newest_modification( buf_page_get_newest_modification(
/*==============================*/ /*=============================*/
/* out: newest modification to page */ /* out: newest modification to page */
buf_block_t* block); /* in: block containing the page frame */ const buf_page_t* bpage); /* in: block containing the
page frame */
/************************************************************************ /************************************************************************
Increments the modify clock of a frame by 1. The caller must (1) own the Increments the modify clock of a frame by 1. The caller must (1) own the
buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock
......
...@@ -444,10 +444,23 @@ buf_block_get_frame( ...@@ -444,10 +444,23 @@ buf_block_get_frame(
buf_block_t* block) /* in: pointer to the control block */ buf_block_t* block) /* in: pointer to the control block */
{ {
ut_ad(block); ut_ad(block);
ut_ad(buf_block_get_state(block) != BUF_BLOCK_NOT_USED); #ifdef UNIV_DEBUG
ut_ad(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE switch (buf_block_get_state(block)) {
|| (block->page.buf_fix_count > 0)); case BUF_BLOCK_NOT_USED:
case BUF_BLOCK_ZIP_PAGE:
ut_error;
break;
case BUF_BLOCK_FILE_PAGE:
ut_a(block->page.buf_fix_count > 0);
/* fall through */
case BUF_BLOCK_READY_FOR_USE:
case BUF_BLOCK_MEMORY:
case BUF_BLOCK_REMOVE_HASH:
goto ok;
}
ut_error;
ok:
#endif /* UNIV_DEBUG */
return(block->frame); return(block->frame);
} }
...@@ -725,17 +738,18 @@ Gets the youngest modification log sequence number for a frame. ...@@ -725,17 +738,18 @@ Gets the youngest modification log sequence number for a frame.
Returns zero if not file page or no modification occurred yet. */ Returns zero if not file page or no modification occurred yet. */
UNIV_INLINE UNIV_INLINE
ib_uint64_t ib_uint64_t
buf_block_get_newest_modification( buf_page_get_newest_modification(
/*==============================*/ /*=============================*/
/* out: newest modification to page */ /* out: newest modification to page */
buf_block_t* block) /* in: block containing the page frame */ const buf_page_t* bpage) /* in: block containing the
page frame */
{ {
ib_uint64_t lsn; ib_uint64_t lsn;
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) { if (buf_page_in_file(bpage)) {
lsn = block->page.newest_modification; lsn = bpage->newest_modification;
} else { } else {
lsn = 0; lsn = 0;
} }
......
...@@ -99,9 +99,8 @@ ibool ...@@ -99,9 +99,8 @@ ibool
buf_flush_ready_for_replace( buf_flush_ready_for_replace(
/*========================*/ /*========================*/
/* out: TRUE if can replace immediately */ /* out: TRUE if can replace immediately */
buf_page_t* bpage); /* in: buffer control block, must be in state buf_page_t* bpage); /* in: buffer control block, must be
BUF_BLOCK_FILE_PAGE or BUF_BLOCK_ZIP_PAGE buf_page_in_file(bpage) and in the LRU list */
and in the LRU list */
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/********************************************************************** /**********************************************************************
Validates the flush list. */ Validates the flush list. */
......
...@@ -1242,7 +1242,8 @@ recv_recover_page( ...@@ -1242,7 +1242,8 @@ recv_recover_page(
/* It may be that the page has been modified in the buffer /* It may be that the page has been modified in the buffer
pool: read the newest modification lsn there */ pool: read the newest modification lsn there */
page_newest_lsn = buf_block_get_newest_modification(block); page_newest_lsn
= buf_page_get_newest_modification(&block->page);
if (page_newest_lsn) { if (page_newest_lsn) {
......
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