Commit 6c8dfab1 authored by marko's avatar marko

branches/zip: Replace most references to block->state, block->offset,

and block->space with buf_block_get_state(block), buf_block_get_page_no(block),
and buf_block_get_space(block).

enum buf_block_state: Replaces the #define'd buf_block_t.state values.

buf_block_get_state(): New function.

buf_block_get_frame(): Add __attribute__((const)).
parent 64ead9c3
......@@ -2323,7 +2323,8 @@ btr_compress(
mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr) == block->offset);
ut_a(btr_page_get_next(merge_page, mtr)
== buf_block_get_page_no(block));
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
......@@ -2331,7 +2332,8 @@ btr_compress(
mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr) == block->offset);
ut_a(btr_page_get_prev(merge_page, mtr)
== buf_block_get_page_no(block));
#endif /* UNIV_BTR_DEBUG */
} else {
/* The page is the only one on the level, lift the records
......@@ -2580,14 +2582,16 @@ btr_discard_page(
mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr) == block->offset);
ut_a(btr_page_get_next(merge_page, mtr)
== buf_block_get_page_no(block));
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
merge_block = btr_block_get(space, right_page_no, RW_X_LATCH,
mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr) == block->offset);
ut_a(btr_page_get_prev(merge_page, mtr)
== buf_block_get_page_no(block));
#endif /* UNIV_BTR_DEBUG */
} else {
btr_discard_only_page_on_level(index, block, mtr);
......
......@@ -825,7 +825,8 @@ btr_search_guess_on_hash(
#endif /* UNIV_SYNC_DEBUG */
}
if (UNIV_UNLIKELY(block->state == BUF_BLOCK_REMOVE_HASH)) {
if (UNIV_UNLIKELY(buf_block_get_state(block)
== BUF_BLOCK_REMOVE_HASH)) {
if (UNIV_LIKELY(!has_search_latch)) {
btr_leaf_page_release(block, latch_mode, mtr);
......
......@@ -738,7 +738,7 @@ buf_chunk_not_freed(
for (i = chunk->size; i--; block++) {
mutex_enter(&block->mutex);
if (block->state == BUF_BLOCK_FILE_PAGE
if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE
&& !buf_flush_ready_for_replace(block)) {
mutex_exit(&block->mutex);
......@@ -772,7 +772,7 @@ buf_chunk_all_free(
for (i = chunk->size; i--; block++) {
if (block->state != BUF_BLOCK_NOT_USED) {
if (buf_block_get_state(block) != BUF_BLOCK_NOT_USED) {
return(FALSE);
}
......@@ -799,7 +799,7 @@ buf_chunk_free(
block_end = chunk->blocks + chunk->size;
for (block = chunk->blocks; block < block_end; block++) {
ut_a(block->state == BUF_BLOCK_NOT_USED);
ut_a(buf_block_get_state(block) == BUF_BLOCK_NOT_USED);
ut_a(!block->page_zip.data);
ut_a(!block->in_LRU_list);
......@@ -972,7 +972,7 @@ shrink_again:
/* Move the blocks of chunk to the end of the
LRU list and try to flush them. */
for (; block < bend; block++) {
switch (block->state) {
switch (buf_block_get_state(block)) {
case BUF_BLOCK_NOT_USED:
continue;
case BUF_BLOCK_FILE_PAGE:
......@@ -1079,7 +1079,8 @@ buf_pool_page_hash_rebuild(void)
buf_block_t* block = chunk->blocks;
for (j = 0; j < chunk->size; j++, block++) {
if (block->state == BUF_BLOCK_FILE_PAGE) {
if (buf_block_get_state(block)
== BUF_BLOCK_FILE_PAGE) {
HASH_INSERT(buf_block_t, hash, page_hash,
buf_page_address_fold(
block->space,
......@@ -1189,7 +1190,7 @@ buf_page_make_young(
{
mutex_enter(&(buf_pool->mutex));
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
buf_LRU_make_block_young(block);
......@@ -1429,7 +1430,7 @@ loop:
mutex_enter(&block->mutex);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
must_read = FALSE;
......@@ -1573,7 +1574,7 @@ buf_page_optimistic_get_func(
mutex_enter(&block->mutex);
if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE)) {
if (UNIV_UNLIKELY(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE)) {
mutex_exit(&block->mutex);
......@@ -1695,7 +1696,7 @@ buf_page_get_known_nowait(
mutex_enter(&block->mutex);
if (block->state == BUF_BLOCK_REMOVE_HASH) {
if (buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH) {
/* Another thread is just freeing the block from the LRU list
of the buffer pool: do not try to access this page; this
attempt to access the page can only come through the hash
......@@ -1708,7 +1709,7 @@ buf_page_get_known_nowait(
return(FALSE);
}
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#ifdef UNIV_SYNC_DEBUG
buf_block_buf_fix_inc_debug(block, file, line);
......@@ -1831,7 +1832,7 @@ buf_page_init(
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(mutex_own(&(block->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state != BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
/* Set the state of the block */
block->magic_n = BUF_BLOCK_MAGIC_N;
......@@ -2121,7 +2122,7 @@ buf_page_io_complete(
ut_ad(block);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
/* We do not need protect block->io_fix here by block->mutex to read
it because this is the only function where we can change the value
......@@ -2137,7 +2138,7 @@ buf_page_io_complete(
byte* frame;
if (block->page_zip.size) {
ut_a(block->space);
ut_a(buf_block_get_space(block) != 0);
frame = block->page_zip.data;
......@@ -2180,15 +2181,16 @@ buf_page_io_complete(
read_space_id = mach_read_from_4(
frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
if (!block->space
&& trx_doublewrite_page_inside(block->offset)) {
if (buf_block_get_space(block) == TRX_SYS_SPACE
&& trx_doublewrite_page_inside(
buf_block_get_page_no(block))) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: reading page %lu\n"
"InnoDB: which is in the"
" doublewrite buffer!\n",
(ulong) block->offset);
(ulong) buf_block_get_page_no(block));
} else if (!read_space_id && !read_page_no) {
/* This is likely an uninitialized page. */
} else if ((block->space && block->space != read_space_id)
......@@ -2386,7 +2388,8 @@ buf_validate(void)
mutex_enter(&block->mutex);
if (block->state == BUF_BLOCK_FILE_PAGE) {
switch (buf_block_get_state(block)) {
case BUF_BLOCK_FILE_PAGE:
ut_a(buf_page_hash_get(block->space,
block->offset)
......@@ -2430,8 +2433,11 @@ buf_validate(void)
n_flush++;
}
} else if (block->state == BUF_BLOCK_NOT_USED) {
break;
case BUF_BLOCK_NOT_USED:
n_free++;
break;
}
mutex_exit(&block->mutex);
......
......@@ -55,7 +55,7 @@ buf_flush_insert_into_flush_list(
ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (ut_dulint_cmp((UT_LIST_GET_FIRST(buf_pool->flush_list))
......@@ -122,12 +122,12 @@ buf_flush_ready_for_replace(
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(mutex_own(&block->mutex));
#endif /* UNIV_SYNC_DEBUG */
if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE)) {
if (UNIV_UNLIKELY(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE)) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: buffer block state %lu"
" in the LRU list!\n",
(ulong)block->state);
(ulong) buf_block_get_state(block));
ut_print_buf(stderr, block, sizeof(buf_block_t));
return(FALSE);
......@@ -158,7 +158,7 @@ buf_flush_ready_for_flush(
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(mutex_own(&(block->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
&& (block->io_fix == 0)) {
......@@ -191,7 +191,7 @@ buf_flush_write_complete(
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
block->oldest_modification = ut_dulint_zero;
......@@ -261,7 +261,7 @@ buf_flush_buffered_writes(void)
for (i = 0; i < trx_doublewrite->first_free; i++) {
block = trx_doublewrite->buf_block_arr[i];
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (UNIV_LIKELY_NULL(block->page_zip.data)) {
/* No simple validate for compressed pages exists. */
......@@ -299,8 +299,8 @@ corrupted_page:
"InnoDB: to prevent corrupt data"
" from ending up in data\n"
"InnoDB: files.\n",
(ulong) block->offset,
(ulong) block->space);
(ulong) buf_block_get_page_no(block),
(ulong) buf_block_get_space(block));
ut_error;
}
......@@ -388,12 +388,12 @@ flush:
for (i = 0; i < trx_doublewrite->first_free; i++) {
block = trx_doublewrite->buf_block_arr[i];
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (UNIV_UNLIKELY(block->page_zip.size)) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space,
FALSE, buf_block_get_space(block),
block->page_zip.size,
block->offset, 0,
buf_block_get_page_no(block), 0,
block->page_zip.size,
(void*)block->page_zip.data,
(void*)block);
......@@ -416,12 +416,12 @@ flush:
" io fix %lu, state %lu\n",
(ulong)block->buf_fix_count,
(ulong)block->io_fix,
(ulong)block->state);
(ulong)buf_block_get_state(block));
}
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, 0,
block->offset, 0, UNIV_PAGE_SIZE,
FALSE, buf_block_get_space(block), 0,
buf_block_get_page_no(block), 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
}
......@@ -460,7 +460,7 @@ buf_flush_post_to_doublewrite_buf(
try_again:
mutex_enter(&(trx_doublewrite->mutex));
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (trx_doublewrite->first_free
>= 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
......@@ -583,7 +583,7 @@ buf_flush_write_block_low(
#ifdef UNIV_LOG_DEBUG
static ibool univ_log_debug_warned;
#endif /* UNIV_LOG_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
#ifdef UNIV_IBUF_DEBUG
ut_a(ibuf_count_get(block->space, block->offset) == 0);
......@@ -607,8 +607,8 @@ buf_flush_write_block_low(
block->newest_modification);
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->page_zip.size,
block->offset, 0, block->page_zip.size
FALSE, buf_block_get_space(block), block->page_zip.size,
buf_block_get_page_no(block), 0, block->page_zip.size
? block->page_zip.size : UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
} else {
......@@ -641,7 +641,7 @@ buf_flush_try_page(
block = buf_page_hash_get(space, offset);
ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
ut_a(!block || buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (!block) {
mutex_exit(&(buf_pool->mutex));
......@@ -812,7 +812,7 @@ buf_flush_try_neighbors(
for (i = low; i < high; i++) {
block = buf_page_hash_get(space, i);
ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
ut_a(!block || buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (!block) {
......@@ -949,15 +949,15 @@ buf_flush_batch(
function a pointer to a block in the list! */
while ((block != NULL) && !found) {
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
mutex_enter(&block->mutex);
if (buf_flush_ready_for_flush(block, flush_type)) {
found = TRUE;
space = block->space;
offset = block->offset;
space = buf_block_get_space(block);
offset = buf_block_get_page_no(block);
mutex_exit(&block->mutex);
mutex_exit(&(buf_pool->mutex));
......@@ -1136,7 +1136,7 @@ buf_flush_validate_low(void)
while (block != NULL) {
om = block->oldest_modification;
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(ut_dulint_cmp(om, ut_dulint_zero) > 0);
block = UT_LIST_GET_NEXT(flush_list, block);
......
......@@ -91,9 +91,9 @@ scan_again:
mutex_enter(&block->mutex);
prev_block = UT_LIST_GET_PREV(LRU, block);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (block->space == id
if (buf_block_get_space(block) == id
&& (block->buf_fix_count > 0 || block->io_fix != 0)) {
/* We cannot remove this page during this scan yet;
......@@ -105,7 +105,7 @@ scan_again:
goto next_page;
}
if (block->space == id) {
if (buf_block_get_space(block) == id) {
#ifdef UNIV_DEBUG
if (buf_debug_prints) {
fprintf(stderr,
......@@ -115,7 +115,7 @@ scan_again:
}
#endif
if (block->is_hashed) {
page_no = block->offset;
page_no = buf_block_get_page_no(block);
mutex_exit(&block->mutex);
......@@ -441,7 +441,7 @@ loop:
ut_a(block->in_free_list);
UT_LIST_REMOVE(free, buf_pool->free, block);
block->in_free_list = FALSE;
ut_a(block->state != BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
ut_a(!block->in_LRU_list);
if (block->page_zip.size != zip_size) {
......@@ -618,7 +618,7 @@ buf_LRU_old_init(void)
block = UT_LIST_GET_FIRST(buf_pool->LRU);
while (block != NULL) {
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(block->in_LRU_list);
block->old = TRUE;
block = UT_LIST_GET_NEXT(LRU, block);
......@@ -644,7 +644,7 @@ buf_LRU_remove_block(
ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(block->in_LRU_list);
/* If the LRU_old pointer is defined and points to just this block,
......@@ -703,7 +703,7 @@ buf_LRU_add_block_to_end_low(
ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
block->old = TRUE;
......@@ -761,7 +761,7 @@ buf_LRU_add_block_low(
ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(!block->in_LRU_list);
block->old = old;
......@@ -857,8 +857,13 @@ buf_LRU_block_free_non_file_page(
#endif /* UNIV_SYNC_DEBUG */
ut_ad(block);
ut_a((block->state == BUF_BLOCK_MEMORY)
|| (block->state == BUF_BLOCK_READY_FOR_USE));
switch (buf_block_get_state(block)) {
case BUF_BLOCK_MEMORY:
case BUF_BLOCK_READY_FOR_USE:
break;
default:
ut_error;
}
ut_ad(block->n_pointers == 0);
ut_a(!block->in_free_list);
......@@ -904,7 +909,7 @@ buf_LRU_block_remove_hashed_page(
#endif /* UNIV_SYNC_DEBUG */
ut_ad(block);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(block->io_fix == 0);
ut_a(block->buf_fix_count == 0);
ut_a(ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) == 0);
......@@ -964,7 +969,7 @@ buf_LRU_block_free_hashed_page(
ut_ad(mutex_own(&(buf_pool->mutex)));
ut_ad(mutex_own(&block->mutex));
#endif /* UNIV_SYNC_DEBUG */
ut_a(block->state == BUF_BLOCK_REMOVE_HASH);
ut_a(buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH);
block->state = BUF_BLOCK_MEMORY;
......@@ -1004,7 +1009,7 @@ buf_LRU_validate(void)
while (block != NULL) {
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (block->old) {
old_len++;
......@@ -1035,7 +1040,7 @@ buf_LRU_validate(void)
block = UT_LIST_GET_FIRST(buf_pool->free);
while (block != NULL) {
ut_a(block->state == BUF_BLOCK_NOT_USED);
ut_a(buf_block_get_state(block) == BUF_BLOCK_NOT_USED);
block = UT_LIST_GET_NEXT(free, block);
}
......
......@@ -129,7 +129,7 @@ buf_read_page_low(
}
#endif
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if (zip_size) {
*err = fil_io(OS_FILE_READ | wake_later,
......
......@@ -818,33 +818,32 @@ fsp_init_file_page_low(
buf_block_t* block) /* in: pointer to a page */
{
page_t* page = buf_block_get_frame(block);
page_zip_des_t* page_zip;
page_zip_des_t* page_zip= buf_block_get_page_zip(block);
block->check_index_page_at_flush = FALSE;
page_zip = buf_block_get_page_zip(block);
if (UNIV_LIKELY_NULL(page_zip)) {
memset(page, 0, UNIV_PAGE_SIZE);
memset(page_zip->data, 0, page_zip->size);
mach_write_to_4(page + FIL_PAGE_OFFSET, block->offset);
mach_write_to_4(page + FIL_PAGE_OFFSET,
buf_block_get_page_no(block));
mach_write_to_4(page
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
block->space);
mach_write_to_4(page_zip->data
+ FIL_PAGE_OFFSET, block->offset);
mach_write_to_4(page_zip->data
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
block->space);
buf_block_get_space(block));
memcpy(page_zip->data + FIL_PAGE_OFFSET,
page + FIL_PAGE_OFFSET, 4);
memcpy(page_zip->data + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 4);
return;
}
#ifdef UNIV_BASIC_LOG_DEBUG
memset(page, 0xff, UNIV_PAGE_SIZE);
#endif
mach_write_to_4(page + FIL_PAGE_OFFSET, block->offset);
mach_write_to_4(page + FIL_PAGE_OFFSET, buf_block_get_page_no(block));
memset(page + FIL_PAGE_LSN, 0, 8);
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, block->space);
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
buf_block_get_space(block));
memset(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, 0, 8);
}
......
......@@ -65,6 +65,17 @@ extern ibool buf_debug_prints;/* If this is set TRUE, the program
extern ulint srv_buf_pool_write_requests; /* variable to count write request
issued */
/* States of a control block */
enum buf_block_state {
BUF_BLOCK_NOT_USED = 211, /* is in the free list */
BUF_BLOCK_READY_FOR_USE, /* when buf_get_free_block returns
a block, it is in this state */
BUF_BLOCK_FILE_PAGE, /* contains a buffered file page */
BUF_BLOCK_MEMORY, /* contains some main memory object */
BUF_BLOCK_REMOVE_HASH /* hash index should be removed
before putting to the free list */
};
/************************************************************************
Creates the buffer pool. */
......@@ -523,13 +534,23 @@ buf_block_dbg_add_level(
ulint level); /* in: latching order level */
#endif /* UNIV_SYNC_DEBUG */
/*************************************************************************
Gets the state of a block. */
UNIV_INLINE
enum buf_block_state
buf_block_get_state(
/*================*/
/* out: state */
const buf_block_t* block) /* in: pointer to the control block */
__attribute__((pure));
/*************************************************************************
Gets a pointer to the memory frame of a block. */
UNIV_INLINE
buf_frame_t*
buf_block_get_frame(
/*================*/
/* out: pointer to the frame */
buf_block_t* block); /* in: pointer to the control block */
buf_block_t* block) /* in: pointer to the control block */
__attribute__((const));
/*************************************************************************
Gets the space id of a block. */
UNIV_INLINE
......@@ -919,15 +940,6 @@ struct buf_pool_struct{
LRU_old == NULL */
};
/* States of a control block */
#define BUF_BLOCK_NOT_USED 211 /* is in the free list */
#define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
a block, it is in this state */
#define BUF_BLOCK_FILE_PAGE 213 /* contains a buffered file page */
#define BUF_BLOCK_MEMORY 214 /* contains some main memory object */
#define BUF_BLOCK_REMOVE_HASH 215 /* hash index should be removed
before putting to the free list */
/* Io_fix states of a control block; these must be != 0 */
#define BUF_IO_READ 561
#define BUF_IO_WRITE 562
......
......@@ -83,6 +83,33 @@ buf_pool_clock_tic(void)
return(buf_pool->ulint_clock);
}
/*************************************************************************
Gets the state of a block. */
UNIV_INLINE
enum buf_block_state
buf_block_get_state(
/*================*/
/* out: state */
const buf_block_t* block) /* in: pointer to the control block */
{
enum buf_block_state state = block->state;
#ifdef UNIV_DEBUG
switch (state) {
case BUF_BLOCK_NOT_USED:
case BUF_BLOCK_READY_FOR_USE:
case BUF_BLOCK_FILE_PAGE:
case BUF_BLOCK_MEMORY:
case BUF_BLOCK_REMOVE_HASH:
break;
default:
ut_error;
}
#endif /* UNIV_DEBUG */
return(state);
}
/*************************************************************************
Gets a pointer to the memory frame of a block. */
UNIV_INLINE
......@@ -262,7 +289,7 @@ buf_block_free(
mutex_enter(&block->mutex);
ut_a(block->state != BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
buf_LRU_block_free_non_file_page(block);
......@@ -342,7 +369,7 @@ buf_block_get_newest_modification(
mutex_enter(&(buf_pool->mutex));
if (block->state == BUF_BLOCK_FILE_PAGE) {
if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) {
lsn = block->newest_modification;
} else {
lsn = ut_dulint_zero;
......@@ -443,7 +470,7 @@ buf_page_hash_get(
HASH_SEARCH(hash, buf_pool->page_hash, fold, block,
(block->space == space) && (block->offset == offset));
ut_a(block == NULL || block->state == BUF_BLOCK_FILE_PAGE);
ut_a(!block || buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
return(block);
}
......@@ -508,7 +535,7 @@ buf_page_release(
{
ut_ad(block);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(block->buf_fix_count > 0);
if (rw_latch == RW_X_LATCH && mtr->modifications) {
......
......@@ -1187,7 +1187,8 @@ recv_recover_page(
return;
}
recv_addr = recv_get_fil_addr_struct(block->space, block->offset);
recv_addr = recv_get_fil_addr_struct(buf_block_get_space(block),
buf_block_get_page_no(block));
if ((recv_addr == NULL)
|| (recv_addr->state == RECV_BEING_PROCESSED)
......@@ -1200,7 +1201,7 @@ recv_recover_page(
#if 0
fprintf(stderr, "Recovering space %lu, page %lu\n",
block->space, block->offset);
buf_block_get_space(block), buf_block_get_page_no(block));
#endif
recv_addr->state = RECV_BEING_PROCESSED;
......
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