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(
{
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);
......@@ -1771,8 +1771,8 @@ buf_page_init_for_backup_restore(
block->freed_page_clock = 0;
block->newest_modification = 0;
block->oldest_modification = 0;
block->page.newest_modification = 0;
block->page.oldest_modification = 0;
block->page.state = BUF_BLOCK_FILE_PAGE;
block->page.accessed = FALSE;
......
......@@ -55,7 +55,7 @@ buf_flush_insert_into_flush_list(
ut_ad(mutex_own(&(buf_pool->mutex)));
#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_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
......@@ -113,9 +113,8 @@ ibool
buf_flush_ready_for_replace(
/*========================*/
/* out: TRUE if can replace immediately */
buf_page_t* bpage) /* in: buffer control block, must be in state
BUF_BLOCK_FILE_PAGE or BUF_BLOCK_ZIP_PAGE
and in the LRU list */
buf_page_t* bpage) /* in: buffer control block, must be
buf_page_in_file(bpage) and in the LRU list */
{
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(buf_pool->mutex)));
......@@ -147,8 +146,8 @@ ibool
buf_flush_ready_for_flush(
/*======================*/
/* out: TRUE if can flush immediately */
buf_page_t* bpage, /* in: buffer control block, must be in state
BUF_BLOCK_FILE_PAGE */
buf_page_t* bpage, /* in: buffer control block, must be
buf_page_in_file(bpage) */
enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
{
ut_a(buf_page_in_file(bpage));
......@@ -792,7 +791,7 @@ buf_flush_try_neighbors(
enum buf_flush flush_type) /* in: BUF_FLUSH_LRU or
BUF_FLUSH_LIST */
{
buf_block_t* block;
buf_page_t* bpage;
ulint low, high;
ulint count = 0;
ulint i;
......@@ -820,16 +819,15 @@ buf_flush_try_neighbors(
for (i = low; i < high; i++) {
block = (buf_block_t*) buf_page_hash_get(space, i);
ut_a(!block
|| buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
bpage = buf_page_hash_get(space, i);
ut_a(!bpage || buf_page_in_file(bpage));
if (!block) {
if (!bpage) {
continue;
} 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,
because the flushed blocks are soon freed */
......@@ -837,10 +835,12 @@ buf_flush_try_neighbors(
continue;
} 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)
&& (i == offset || !block->page.buf_fix_count)) {
if (buf_flush_ready_for_flush(bpage, flush_type)
&& (i == offset || !bpage->buf_fix_count)) {
/* We only try to flush those
neighbors != offset where the buf fix count is
zero, as we then know that we probably can
......@@ -849,10 +849,10 @@ buf_flush_try_neighbors(
flush the doublewrite buffer before we start
waiting. */
mutex_exit(&block->mutex);
mutex_exit(&(buf_pool->mutex));
mutex_exit(block_mutex);
/* Note: as we release the buf_pool mutex
above, in buf_flush_try_page we cannot be sure
the page is still in a flushable state:
......@@ -864,7 +864,7 @@ buf_flush_try_neighbors(
mutex_enter(&(buf_pool->mutex));
} else {
mutex_exit(&block->mutex);
mutex_exit(block_mutex);
}
}
}
......@@ -1151,7 +1151,7 @@ buf_flush_validate_low(void)
while (bpage != NULL) {
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);
bpage = UT_LIST_GET_NEXT(flush_list, bpage);
......
......@@ -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. */
UNIV_INLINE
ib_uint64_t
buf_block_get_newest_modification(
/*==============================*/
/* out: newest modification to page */
buf_block_t* block); /* in: block containing the page frame */
buf_page_get_newest_modification(
/*=============================*/
/* out: newest modification to page */
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
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(
buf_block_t* block) /* in: pointer to the control block */
{
ut_ad(block);
ut_ad(buf_block_get_state(block) != BUF_BLOCK_NOT_USED);
ut_ad(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE
|| (block->page.buf_fix_count > 0));
#ifdef UNIV_DEBUG
switch (buf_block_get_state(block)) {
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);
}
......@@ -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. */
UNIV_INLINE
ib_uint64_t
buf_block_get_newest_modification(
/*==============================*/
/* out: newest modification to page */
buf_block_t* block) /* in: block containing the page frame */
buf_page_get_newest_modification(
/*=============================*/
/* out: newest modification to page */
const buf_page_t* bpage) /* in: block containing the
page frame */
{
ib_uint64_t lsn;
mutex_enter(&(buf_pool->mutex));
if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) {
lsn = block->page.newest_modification;
if (buf_page_in_file(bpage)) {
lsn = bpage->newest_modification;
} else {
lsn = 0;
}
......
......@@ -99,9 +99,8 @@ ibool
buf_flush_ready_for_replace(
/*========================*/
/* out: TRUE if can replace immediately */
buf_page_t* bpage); /* in: buffer control block, must be in state
BUF_BLOCK_FILE_PAGE or BUF_BLOCK_ZIP_PAGE
and in the LRU list */
buf_page_t* bpage); /* in: buffer control block, must be
buf_page_in_file(bpage) and in the LRU list */
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
/**********************************************************************
Validates the flush list. */
......
......@@ -1242,7 +1242,8 @@ recv_recover_page(
/* It may be that the page has been modified in the buffer
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) {
......
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