Commit 5669dc3d authored by marko's avatar marko

branches/zip: Reduce the number of buf_block_align() calls.

btr_block_get(): New function to return buf_block_t.

btr_page_alloc(), buf_page_get_release_on_io(), buf_page_get_gen(),
buf_page_create(), fseg_create(), fseg_create_general(): Return buf_block_t.

buf_page_get_known_nowait(): Expect buf_block_t instead of buf_frame_t.

buf_frame_get_newest_modification(): Replace with
buf_block_get_newest_modification().

buf_page_dbg_add_level(): Replace with buf_block_dbg_add_level().

buf_block_get_zip_size(): New function.

buf_block_get_page_zip(): Reintroduce.

recv_recover_page(): Replace page, space, page_no with block.

ibuf_bitmap_page_init(): Replace page, zip_size with block.

ibuf_parse_bitmap_init(): Remove the parameter zip_size.

btr_search_drop_page_hash_index(): Replace page with block.
parent 736a8ffb
This diff is collapsed.
......@@ -470,11 +470,11 @@ btr_cur_search_to_nth_level(
for (;;) {
buf_block_t* block;
retry_page_get:
page = buf_page_get_gen(space, page_no, rw_latch, guess,
buf_mode,
__FILE__, __LINE__,
mtr);
if (page == NULL) {
block = buf_page_get_gen(space, page_no, rw_latch, guess,
buf_mode,
__FILE__, __LINE__,
mtr);
if (block == NULL) {
/* This must be a search to perform an insert;
try insert to the insert buffer */
......@@ -501,19 +501,19 @@ btr_cur_search_to_nth_level(
goto retry_page_get;
}
block = buf_block_align(page);
page = buf_block_get_frame(block);
#ifdef UNIV_ZIP_DEBUG
ut_a(rw_latch == RW_NO_LATCH
|| !buf_frame_get_page_zip(page)
|| page_zip_validate(buf_frame_get_page_zip(page), page));
|| !buf_block_get_page_zip(block)
|| page_zip_validate(buf_block_get_page_zip(block),
page));
#endif /* UNIV_ZIP_DEBUG */
block->check_index_page_at_flush = TRUE;
#ifdef UNIV_SYNC_DEBUG
if (rw_latch != RW_NO_LATCH) {
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
}
#endif
ut_ad(0 == ut_dulint_cmp(index->id,
......@@ -651,7 +651,6 @@ btr_cur_open_at_index_side(
mtr_t* mtr) /* in: mtr */
{
page_cur_t* page_cursor;
page_t* page;
ulint page_no;
ulint space;
ulint height;
......@@ -687,14 +686,17 @@ btr_cur_open_at_index_side(
height = ULINT_UNDEFINED;
for (;;) {
page = buf_page_get_gen(space, page_no, RW_NO_LATCH, NULL,
BUF_GET,
__FILE__, __LINE__,
mtr);
buf_block_t* block;
page_t* page;
block = buf_page_get_gen(space, page_no, RW_NO_LATCH, NULL,
BUF_GET,
__FILE__, __LINE__,
mtr);
page = buf_block_get_frame(block);
ut_ad(0 == ut_dulint_cmp(index->id,
btr_page_get_index_id(page)));
buf_block_align(page)->check_index_page_at_flush = TRUE;
block->check_index_page_at_flush = TRUE;
if (height == ULINT_UNDEFINED) {
/* We are in the root node */
......@@ -777,7 +779,6 @@ btr_cur_open_at_rnd_pos(
mtr_t* mtr) /* in: mtr */
{
page_cur_t* page_cursor;
page_t* page;
ulint page_no;
ulint space;
ulint height;
......@@ -802,10 +803,14 @@ btr_cur_open_at_rnd_pos(
height = ULINT_UNDEFINED;
for (;;) {
page = buf_page_get_gen(space, page_no, RW_NO_LATCH, NULL,
BUF_GET,
__FILE__, __LINE__,
mtr);
buf_block_t* block;
page_t* page;
block = buf_page_get_gen(space, page_no, RW_NO_LATCH, NULL,
BUF_GET,
__FILE__, __LINE__,
mtr);
page = buf_block_get_frame(block);
ut_ad(0 == ut_dulint_cmp(index->id,
btr_page_get_index_id(page)));
......@@ -1930,10 +1935,11 @@ btr_cur_pess_upd_restore_supremum(
rec_t* rec, /* in: updated record */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
page_t* prev_page;
ulint space;
ulint prev_page_no;
page_t* page;
buf_block_t* prev_block;
page_t* prev_page;
ulint space;
ulint prev_page_no;
page = page_align(rec);
......@@ -1947,14 +1953,15 @@ btr_cur_pess_upd_restore_supremum(
prev_page_no = btr_page_get_prev(page, mtr);
ut_ad(prev_page_no != FIL_NULL);
prev_page = buf_page_get_with_no_latch(space, prev_page_no, mtr);
prev_block = buf_page_get_with_no_latch(space, prev_page_no, mtr);
prev_page = buf_block_get_frame(prev_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
/* We must already have an x-latch to prev_page! */
ut_ad(mtr_memo_contains_page(mtr, prev_page, MTR_MEMO_PAGE_X_FIX));
ut_ad(mtr_memo_contains(mtr, prev_block, MTR_MEMO_PAGE_X_FIX));
lock_rec_reset_and_inherit_gap_locks(page_get_supremum_rec(prev_page),
rec);
......@@ -3589,14 +3596,13 @@ btr_store_big_rec_extern_fields(
ulint extern_len;
ulint store_len;
ulint page_no;
page_t* page;
ulint space_id;
page_t* rec_page;
ulint prev_page_no;
ulint hint_page_no;
ulint i;
mtr_t mtr;
page_zip_des_t* page_zip;
buf_block_t* rec_block;
z_stream c_stream;
ut_ad(rec_offs_validate(rec, index, offsets));
......@@ -3652,6 +3658,9 @@ btr_store_big_rec_extern_fields(
}
for (;;) {
buf_block_t* block;
page_t* page;
mtr_start(&mtr);
if (prev_page_no == FIL_NULL) {
......@@ -3661,9 +3670,9 @@ btr_store_big_rec_extern_fields(
hint_page_no = prev_page_no + 1;
}
page = btr_page_alloc(index, hint_page_no,
FSP_NO_DIR, 0, &mtr);
if (UNIV_UNLIKELY(page == NULL)) {
block = btr_page_alloc(index, hint_page_no,
FSP_NO_DIR, 0, &mtr);
if (UNIV_UNLIKELY(block == NULL)) {
mtr_commit(&mtr);
......@@ -3674,18 +3683,21 @@ btr_store_big_rec_extern_fields(
return(DB_OUT_OF_FILE_SPACE);
}
page_no = page_get_page_no(page);
page_no = buf_block_get_page_no(block);
page = buf_block_get_frame(block);
if (prev_page_no != FIL_NULL) {
page_t* prev_page;
buf_block_t* prev_block;
page_t* prev_page;
prev_page = buf_page_get(space_id,
prev_page_no,
RW_X_LATCH, &mtr);
prev_block = buf_page_get(space_id,
prev_page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(prev_page,
SYNC_EXTERN_STORAGE);
buf_block_dbg_add_level(prev_block,
SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */
prev_page = buf_block_get_frame(prev_block);
if (UNIV_LIKELY_NULL(page_zip)) {
mlog_write_ulint(
......@@ -3737,7 +3749,7 @@ btr_store_big_rec_extern_fields(
/* Copy the page to compressed storage,
because it will be flushed to disk
from there. */
blob_page_zip = buf_frame_get_page_zip(page);
blob_page_zip = buf_block_get_page_zip(block);
ut_ad(blob_page_zip);
ut_ad(blob_page_zip->size == page_zip->size);
memcpy(blob_page_zip->data, page,
......@@ -3749,13 +3761,14 @@ btr_store_big_rec_extern_fields(
goto next_zip_page;
}
rec_page = buf_page_get(
space_id, page_get_page_no(
rec_block = buf_page_get(
space_id,
page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(rec_page,
SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(rec_block,
SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
if (err == Z_STREAM_END) {
mach_write_to_4(field_ref
......@@ -3826,13 +3839,14 @@ btr_store_big_rec_extern_fields(
extern_len -= store_len;
rec_page = buf_page_get(
space_id, page_get_page_no(
rec_block = buf_page_get(
space_id,
page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(rec_page,
SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(rec_block,
SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
mlog_write_ulint(field_ref + BTR_EXTERN_LEN, 0,
......@@ -3911,17 +3925,18 @@ btr_free_externally_stored_field(
containing the latch to data an an
X-latch to the index tree */
{
page_t* page;
page_t* rec_page;
ulint space_id;
ulint page_no;
ulint next_page_no;
mtr_t mtr;
page_t* page;
ulint space_id;
ulint page_no;
ulint next_page_no;
mtr_t mtr;
#ifdef UNIV_DEBUG
buf_block_t* block = buf_block_align(field_ref);
#endif /* UNIV_DEBUG */
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(local_mtr, field_ref,
MTR_MEMO_PAGE_X_FIX));
ut_ad(mtr_memo_contains(local_mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(!rec || rec_offs_validate(rec, index, offsets));
#ifdef UNIV_DEBUG
......@@ -3936,16 +3951,20 @@ btr_free_externally_stored_field(
#endif /* UNIV_DEBUG */
for (;;) {
buf_block_t* rec_block;
buf_block_t* ext_block;
mtr_start(&mtr);
rec_page = buf_page_get(page_get_space_id(
page_align(field_ref)),
page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
rec_block = buf_page_get(page_get_space_id(
page_align(field_ref)),
page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(rec_block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
ut_ad(rec_block == block);
space_id = mach_read_from_4(field_ref + BTR_EXTERN_SPACE_ID);
page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO);
......@@ -3966,10 +3985,12 @@ btr_free_externally_stored_field(
return;
}
page = buf_page_get(space_id, page_no, RW_X_LATCH, &mtr);
ext_block = buf_page_get(space_id, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_EXTERN_STORAGE);
buf_block_dbg_add_level(ext_block, SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */
page = buf_block_get_frame(ext_block);
if (dict_table_zip_size(index->table)) {
/* Note that page_zip will be NULL
in row_purge_upd_exist_or_extern(). */
......@@ -4145,7 +4166,6 @@ btr_copy_externally_stored_field_prefix_low(
ulint page_no,/* in: page number of the first BLOB page */
ulint offset) /* in: offset on the first BLOB page */
{
page_t* page;
ulint copied_len = 0;
mtr_t mtr;
z_stream d_stream;
......@@ -4169,12 +4189,17 @@ btr_copy_externally_stored_field_prefix_low(
}
for (;;) {
buf_block_t* block;
page_t* page;
mtr_start(&mtr);
page = buf_page_get(space_id, page_no, RW_S_LATCH, &mtr);
block = buf_page_get(space_id, page_no, RW_S_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_EXTERN_STORAGE);
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */
page = buf_block_get_frame(block);
if (UNIV_UNLIKELY(zip_size)) {
int err;
ulint next_page_no;
......
......@@ -247,7 +247,8 @@ btr_pcur_restore_position(
cursor->modify_clock, mtr))) {
cursor->pos_state = BTR_PCUR_IS_POSITIONED;
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
buf_block_dbg_add_level(buf_block_align(page),
SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
if (cursor->rel_pos == BTR_PCUR_ON) {
#ifdef UNIV_DEBUG
......
......@@ -758,11 +758,12 @@ btr_search_guess_on_hash(
}
page = page_align(rec);
block = buf_block_align(page);
if (UNIV_LIKELY(!has_search_latch)) {
if (UNIV_UNLIKELY(
!buf_page_get_known_nowait(latch_mode, page,
!buf_page_get_known_nowait(latch_mode, block,
BUF_MAKE_YOUNG,
__FILE__, __LINE__,
mtr))) {
......@@ -773,12 +774,10 @@ btr_search_guess_on_hash(
can_only_compare_to_cursor_rec = FALSE;
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH);
buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
#endif /* UNIV_SYNC_DEBUG */
}
block = buf_block_align(page);
if (UNIV_UNLIKELY(block->state == BUF_BLOCK_REMOVE_HASH)) {
if (UNIV_LIKELY(!has_search_latch)) {
......@@ -894,13 +893,15 @@ Drops a page hash index. */
void
btr_search_drop_page_hash_index(
/*============================*/
page_t* page) /* in: index page, s- or x-latched, or an index page
for which we know that block->buf_fix_count == 0 */
buf_block_t* block) /* in: block containing index page,
s- or x-latched, or an index page
for which we know that
block->buf_fix_count == 0 */
{
hash_table_t* table;
buf_block_t* block;
ulint n_fields;
ulint n_bytes;
page_t* page;
rec_t* rec;
ulint fold;
ulint prev_fold;
......@@ -917,10 +918,10 @@ btr_search_drop_page_hash_index(
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
retry:
rw_lock_s_lock(&btr_search_latch);
block = buf_block_align(page);
page = buf_block_get_frame(block);
if (UNIV_LIKELY(!block->is_hashed)) {
......@@ -1054,13 +1055,10 @@ btr_search_drop_page_hash_when_freed(
ulint space, /* in: space id */
ulint page_no) /* in: page number */
{
ibool is_hashed;
page_t* page;
mtr_t mtr;
is_hashed = buf_page_peek_if_search_hashed(space, page_no);
buf_block_t* block;
mtr_t mtr;
if (!is_hashed) {
if (!buf_page_peek_if_search_hashed(space, page_no)) {
return;
}
......@@ -1072,15 +1070,15 @@ btr_search_drop_page_hash_when_freed(
get here. Therefore we can acquire the s-latch to the page without
having to fear a deadlock. */
page = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL,
block = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL,
BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
&mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH);
buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
#endif /* UNIV_SYNC_DEBUG */
btr_search_drop_page_hash_index(page);
btr_search_drop_page_hash_index(block);
mtr_commit(&mtr);
}
......@@ -1137,7 +1135,7 @@ btr_search_build_page_hash_index(
rw_lock_s_unlock(&btr_search_latch);
btr_search_drop_page_hash_index(page);
btr_search_drop_page_hash_index(block);
} else {
rw_lock_s_unlock(&btr_search_latch);
}
......@@ -1307,7 +1305,7 @@ btr_search_move_or_delete_hash_entries(
rw_lock_s_unlock(&btr_search_latch);
btr_search_drop_page_hash_index(page);
btr_search_drop_page_hash_index(block);
return;
}
......
......@@ -1160,10 +1160,10 @@ buf_page_reset_file_page_was_freed(
/************************************************************************
This is the general function used to get access to a database page. */
buf_frame_t*
buf_block_t*
buf_page_get_gen(
/*=============*/
/* out: pointer to the frame or NULL */
/* out: pointer to the block or NULL */
ulint space, /* in: space id */
ulint offset, /* in: page number */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
......@@ -1362,7 +1362,7 @@ buf_page_get_gen(
#ifdef UNIV_IBUF_DEBUG
ut_a(ibuf_count_get(block->space, block->offset) == 0);
#endif
return(block->frame);
return(block);
}
/************************************************************************
......@@ -1441,7 +1441,7 @@ buf_page_optimistic_get_func(
if (UNIV_UNLIKELY(!UT_DULINT_EQ(modify_clock, block->modify_clock))) {
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(block->frame, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
if (rw_latch == RW_S_LATCH) {
rw_lock_s_unlock(&(block->lock));
......@@ -1499,13 +1499,12 @@ buf_page_get_known_nowait(
/*======================*/
/* out: TRUE if success */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */
buf_frame_t* guess, /* in: the known page frame */
buf_block_t* block, /* in: the known page */
ulint mode, /* in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */
const char* file, /* in: file name */
ulint line, /* in: line where called */
mtr_t* mtr) /* in: mini-transaction */
{
buf_block_t* block;
ibool success;
ulint fix_type;
......@@ -1514,8 +1513,6 @@ buf_page_get_known_nowait(
mutex_enter(&(buf_pool->mutex));
block = buf_block_align(guess);
if (block->state == 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
......@@ -1821,10 +1818,10 @@ from a file even if it cannot be found in the buffer buf_pool. This is one
of the functions which perform to a block a state transition NOT_USED =>
FILE_PAGE (the other is buf_page_init_for_read above). */
buf_frame_t*
buf_block_t*
buf_page_create(
/*============*/
/* out: pointer to the frame, page bufferfixed */
/* out: pointer to the block, page bufferfixed */
ulint space, /* in: space id */
ulint offset, /* in: offset of the page within space in units of
a page */
......@@ -1855,9 +1852,7 @@ buf_page_create(
buf_block_free(free_block);
frame = buf_page_get_with_no_latch(space, offset, mtr);
return(frame);
return(buf_page_get_with_no_latch(space, offset, mtr));
}
/* If we get here, the page was not in buf_pool: init it there */
......@@ -1921,7 +1916,7 @@ buf_page_create(
#ifdef UNIV_IBUF_DEBUG
ut_a(ibuf_count_get(block->space, block->offset) == 0);
#endif
return(frame);
return(block);
}
/************************************************************************
......@@ -2068,8 +2063,7 @@ buf_page_io_complete(
}
if (recv_recovery_is_on()) {
recv_recover_page(FALSE, TRUE, block->frame,
block->space, block->offset);
recv_recover_page(FALSE, TRUE, block);
}
if (!recv_no_ibuf_operations) {
......
......@@ -595,7 +595,7 @@ buf_flush_write_block_low(
log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
#endif
buf_flush_init_for_writing(block->frame,
buf_frame_get_page_zip(block->frame),
buf_block_get_page_zip(block),
block->newest_modification);
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
......
......@@ -232,7 +232,7 @@ buf_LRU_search_and_free_block(
frame at all */
if (block->frame) {
btr_search_drop_page_hash_index(block->frame);
btr_search_drop_page_hash_index(block);
}
mutex_enter(&(buf_pool->mutex));
......
......@@ -33,14 +33,14 @@ dict_hdr_get(
page x-latched */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
dict_hdr_t* header;
ut_ad(mtr);
header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
RW_X_LATCH, mtr);
block = buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
RW_X_LATCH, mtr);
header = DICT_HDR + buf_block_get_frame(block);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(header, SYNC_DICT_HEADER);
buf_block_dbg_add_level(block, SYNC_DICT_HEADER);
#endif /* UNIV_SYNC_DEBUG */
return(header);
}
......@@ -111,21 +111,18 @@ dict_hdr_create(
/* out: TRUE if succeed */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
dict_hdr_t* dict_header;
ulint hdr_page_no;
ulint root_page_no;
page_t* page;
ut_ad(mtr);
/* Create the dictionary header file block in a new, allocated file
segment in the system tablespace */
page = fseg_create(DICT_HDR_SPACE, 0,
DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
hdr_page_no = page_get_page_no(page);
block = fseg_create(DICT_HDR_SPACE, 0,
DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
ut_a(DICT_HDR_PAGE_NO == hdr_page_no);
ut_a(DICT_HDR_PAGE_NO == buf_block_get_page_no(block));
dict_header = dict_hdr_get(mtr);
......
This diff is collapsed.
......@@ -274,19 +274,19 @@ ibuf_header_page_get(
ulint space, /* in: space id */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
buf_block_t* block;
ut_a(space == 0);
ut_ad(!ibuf_inside());
page = buf_page_get(space, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
block = buf_page_get(space, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_IBUF_HEADER);
buf_block_dbg_add_level(block, SYNC_IBUF_HEADER);
#endif /* UNIV_SYNC_DEBUG */
return(page);
return(buf_block_get_frame(block));
}
/**********************************************************************
......@@ -300,20 +300,20 @@ ibuf_tree_root_get(
ulint space, /* in: space id */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
buf_block_t* block;
ut_a(space == 0);
ut_ad(ibuf_inside());
mtr_x_lock(dict_index_get_lock(data->index), mtr);
page = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
mtr);
block = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
return(page);
return(buf_block_get_frame(block));
}
#ifdef UNIV_IBUF_DEBUG
......@@ -493,11 +493,14 @@ ibuf_data_init_for_space(
data->seg_size = n_used;
root = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
&mtr);
{
buf_block_t* block = buf_page_get(
space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(root, SYNC_TREE_NODE);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
root = buf_block_get_frame(block);
}
data->size = 0;
data->n_inserts = 0;
......@@ -559,15 +562,16 @@ Initializes an ibuf bitmap page. */
void
ibuf_bitmap_page_init(
/*==================*/
page_t* page, /* in: bitmap page */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
mtr_t* mtr) /* in: mtr */
buf_block_t* block, /* in: bitmap page */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
ulint byte_offset;
ulint zip_size = buf_block_get_zip_size(block);
ut_ad(ut_is_2pow(zip_size));
ut_a(ut_is_2pow(zip_size));
page = buf_block_get_frame(block);
fil_page_set_type(page, FIL_PAGE_IBUF_BITMAP);
/* Write all zeros to the bitmap */
......@@ -595,14 +599,12 @@ ibuf_parse_bitmap_init(
byte* ptr, /* in: buffer */
byte* end_ptr __attribute__((unused)), /* in: buffer end */
page_t* page, /* in: page or NULL */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
mtr_t* mtr) /* in: mtr or NULL */
{
ut_ad(ptr && end_ptr);
if (page) {
ibuf_bitmap_page_init(page, zip_size, mtr);
ibuf_bitmap_page_init(buf_block_align(page), mtr);
}
return(ptr);
......@@ -761,15 +763,16 @@ ibuf_bitmap_get_map_page(
0 for uncompressed pages */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
buf_block_t* block;
page = buf_page_get(space, ibuf_bitmap_page_no_calc(zip_size, page_no),
RW_X_LATCH, mtr);
block = buf_page_get(space,
ibuf_bitmap_page_no_calc(zip_size, page_no),
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_IBUF_BITMAP);
buf_block_dbg_add_level(block, SYNC_IBUF_BITMAP);
#endif /* UNIV_SYNC_DEBUG */
return(page);
return(buf_block_get_frame(block));
}
/****************************************************************************
......@@ -1710,11 +1713,14 @@ ibuf_add_free_page(
return(DB_STRONG_FAIL);
}
page = buf_page_get(space, page_no, RW_X_LATCH, &mtr);
{
buf_block_t* block = buf_page_get(
space, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE_NEW);
buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
#endif /* UNIV_SYNC_DEBUG */
page = buf_block_get_frame(block);
}
ibuf_enter();
......@@ -1837,11 +1843,14 @@ ibuf_remove_free_page(
+ PAGE_BTR_IBUF_FREE_LIST, &mtr)
.page);
page = buf_page_get(space, page_no, RW_X_LATCH, &mtr);
{
buf_block_t* block = buf_page_get(
space, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
page = buf_block_get_frame(block);
}
/* Remove the page from the free list and update the ibuf size data */
......@@ -2396,16 +2405,19 @@ ibuf_get_volume_buffered(
goto count_later;
}
prev_page = buf_page_get(0, prev_page_no, RW_X_LATCH, mtr);
{
buf_block_t* block = buf_page_get(
0, prev_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
prev_page = buf_block_get_frame(block);
}
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(prev_page, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
rec = page_get_supremum_rec(prev_page);
rec = page_rec_get_prev(rec);
......@@ -2463,16 +2475,19 @@ ibuf_get_volume_buffered(
return(volume);
}
next_page = buf_page_get(0, next_page_no, RW_X_LATCH, mtr);
{
buf_block_t* block = buf_page_get(
0, next_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
next_page = buf_block_get_frame(block);
}
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(next_page, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
rec = page_get_infimum_rec(next_page);
rec = page_rec_get_next(rec);
......@@ -3126,7 +3141,7 @@ ibuf_merge_or_delete_for_page(
dtuple_t* entry;
dtuple_t* search_tuple;
rec_t* ibuf_rec;
buf_block_t* block;
buf_block_t* block = NULL;
page_t* bitmap_page;
ibuf_data_t* ibuf_data;
ulint n_inserts;
......@@ -3232,7 +3247,7 @@ ibuf_merge_or_delete_for_page(
block = buf_block_align(page);
rw_lock_x_lock_move_ownership(&(block->lock));
page_zip = buf_frame_get_page_zip(page);
page_zip = buf_block_get_page_zip(block);
if (UNIV_UNLIKELY(fil_page_get_type(page) != FIL_PAGE_INDEX)) {
......@@ -3283,13 +3298,13 @@ ibuf_merge_or_delete_for_page(
mtr_start(&mtr);
if (page) {
ibool success = buf_page_get_known_nowait(RW_X_LATCH, page,
ibool success = buf_page_get_known_nowait(RW_X_LATCH, block,
BUF_KEEP_OLD,
__FILE__, __LINE__,
&mtr);
ut_a(success);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
}
......
......@@ -57,6 +57,16 @@ btr_root_get(
/******************************************************************
Gets a buffer page and declares its latching order level. */
UNIV_INLINE
buf_block_t*
btr_block_get(
/*==========*/
ulint space, /* in: space id */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr); /* in: mtr */
/******************************************************************
Gets a buffer page and declares its latching order level. */
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
......@@ -362,10 +372,10 @@ btr_get_size(
Allocates a new file page to be used in an index tree. NOTE: we assume
that the caller has made the reservation for free extents! */
page_t*
buf_block_t*
btr_page_alloc(
/*===========*/
/* out: new allocated page, x-latched;
/* out: new allocated block, x-latched;
NULL if out of space */
dict_index_t* index, /* in: index tree */
ulint hint_page_no, /* in: hint of a good page */
......
......@@ -16,24 +16,38 @@ Created 6/2/1994 Heikki Tuuri
/******************************************************************
Gets a buffer page and declares its latching order level. */
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
buf_block_t*
btr_block_get(
/*==========*/
ulint space, /* in: space id */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
buf_block_t* block;
page = buf_page_get(space, page_no, mode, mtr);
block = buf_page_get(space, page_no, mode, mtr);
#ifdef UNIV_SYNC_DEBUG
if (mode != RW_NO_LATCH) {
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
}
#endif
return(page);
return(block);
}
/******************************************************************
Gets a buffer page and declares its latching order level. */
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
ulint space, /* in: space id */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr) /* in: mtr */
{
return(buf_block_get_frame(btr_block_get(space, page_no, mode, mtr)));
}
/******************************************************************
......
......@@ -87,7 +87,10 @@ Drops a page hash index. */
void
btr_search_drop_page_hash_index(
/*============================*/
page_t* page); /* in: index page, s- or x-latched */
buf_block_t* block); /* in: block containing index page,
s- or x-latched, or an index page
for which we know that
block->buf_fix_count == 0 */
/************************************************************************
Drops a page hash index when a page is freed from a fseg to the file system.
Drops possible hash index if the page happens to be in the buffer pool. */
......
......@@ -200,10 +200,10 @@ in mtr down to the given savepoint. If io is required, this function
retrieves the page to buffer buf_pool, but does not bufferfix it or latch
it. */
UNIV_INLINE
buf_frame_t*
buf_block_t*
buf_page_get_release_on_io(
/*=======================*/
/* out: pointer to the frame, or NULL
/* out: pointer to the block, or NULL
if not in buffer buf_pool */
ulint space, /* in: space id */
ulint offset, /* in: offset of the page within space
......@@ -222,7 +222,7 @@ buf_page_get_known_nowait(
/*======================*/
/* out: TRUE if success */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */
buf_frame_t* guess, /* in: the known page frame */
buf_block_t* block, /* in: the known page */
ulint mode, /* in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */
const char* file, /* in: file name */
ulint line, /* in: line where called */
......@@ -230,10 +230,10 @@ buf_page_get_known_nowait(
/************************************************************************
This is the general function used to get access to a database page. */
buf_frame_t*
buf_block_t*
buf_page_get_gen(
/*=============*/
/* out: pointer to the frame or NULL */
/* out: pointer to the block or NULL */
ulint space, /* in: space id */
ulint offset, /* in: page number */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
......@@ -249,10 +249,10 @@ from a file even if it cannot be found in the buffer buf_pool. This is one
of the functions which perform to a block a state transition NOT_USED =>
FILE_PAGE (the other is buf_page_init_for_read above). */
buf_frame_t*
buf_block_t*
buf_page_create(
/*============*/
/* out: pointer to the frame, page bufferfixed */
/* out: pointer to the block, page bufferfixed */
ulint space, /* in: space id */
ulint offset, /* in: offset of the page within space in units of
a page */
......@@ -379,10 +379,10 @@ Gets the youngest modification log sequence number for a frame.
Returns zero if not file page or no modification occurred yet. */
UNIV_INLINE
dulint
buf_frame_get_newest_modification(
buf_block_get_newest_modification(
/*==============================*/
/* out: newest modification to page */
buf_frame_t* frame); /* in: pointer to a frame */
buf_block_t* block); /* in: block containing the page frame */
/************************************************************************
Increments the modify clock of a frame by 1. The caller must (1) own the
pool mutex and block bufferfix count has to be zero, (2) or own an x-lock
......@@ -584,10 +584,10 @@ should be called in the debug version after a successful latching of a
page if we know the latching order level of the acquired latch. */
UNIV_INLINE
void
buf_page_dbg_add_level(
/*===================*/
buf_frame_t* frame, /* in: buffer page where we have acquired
a latch */
buf_block_dbg_add_level(
/*====================*/
buf_block_t* block, /* in: buffer page
where we have acquired latch */
ulint level); /* in: latching order level */
#endif /* UNIV_SYNC_DEBUG */
/*************************************************************************
......@@ -615,14 +615,23 @@ buf_block_get_page_no(
/* out: page number */
buf_block_t* block); /* in: pointer to the control block */
/*************************************************************************
Gets the compressed page size of a block. */
UNIV_INLINE
ulint
buf_block_get_zip_size(
/*===================*/
/* out: compressed page size, or 0 */
const buf_block_t* block) /* in: pointer to the control block */
__attribute((const));
/*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
UNIV_INLINE
page_zip_des_t*
buf_frame_get_page_zip(
buf_block_get_page_zip(
/*===================*/
/* out: compressed page descriptor, or NULL */
byte* ptr) /* in: pointer to buffer frame */
buf_block_t* block) /* in: pointer to the control block */
__attribute((const));
/***********************************************************************
Gets the block to whose frame the pointer is pointing to. */
......@@ -632,6 +641,16 @@ buf_block_align(
/*============*/
/* out: pointer to block */
byte* ptr); /* in: pointer to a frame */
/*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
UNIV_INLINE
page_zip_des_t*
buf_frame_get_page_zip(
/*===================*/
/* out: compressed page descriptor, or NULL */
byte* ptr) /* in: pointer to the page */
__attribute((const));
/************************************************************************
This function is used to get info if there is an io operation
going on on a buffer page. */
......
......@@ -192,18 +192,28 @@ buf_block_get_page_no(
return(block->offset);
}
/*************************************************************************
Gets the compressed page size of a block. */
UNIV_INLINE
ulint
buf_block_get_zip_size(
/*===================*/
/* out: compressed page size, or 0 */
const buf_block_t* block) /* in: pointer to the control block */
{
return(block->page_zip.size);
}
/*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
UNIV_INLINE
page_zip_des_t*
buf_frame_get_page_zip(
buf_block_get_page_zip(
/*===================*/
/* out: compressed page descriptor, or NULL */
byte* ptr) /* in: pointer to buffer frame */
buf_block_t* block) /* in: pointer to the control block */
{
buf_block_t* block = buf_block_align(ptr);
if (UNIV_LIKELY_NULL(block->page_zip.data)) {
return(&block->page_zip);
}
......@@ -251,6 +261,19 @@ buf_block_align(
return(block);
}
/*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */
UNIV_INLINE
page_zip_des_t*
buf_frame_get_page_zip(
/*===================*/
/* out: compressed page descriptor, or NULL */
byte* ptr) /* in: pointer to the page */
{
return(buf_block_get_page_zip(buf_block_align(ptr)));
}
/**************************************************************************
Gets the space id, page offset, and byte offset within page of a
pointer pointing to a buffer frame containing a file page. */
......@@ -425,18 +448,13 @@ Gets the youngest modification log sequence number for a frame. Returns zero
if not a file page or no modification occurred yet. */
UNIV_INLINE
dulint
buf_frame_get_newest_modification(
buf_block_get_newest_modification(
/*==============================*/
/* out: newest modification to the page */
buf_frame_t* frame) /* in: pointer to a frame */
buf_block_t* block) /* in: block containing the page frame */
{
buf_block_t* block;
dulint lsn;
ut_ad(frame);
block = buf_block_align(frame);
mutex_enter(&(buf_pool->mutex));
if (block->state == BUF_BLOCK_FILE_PAGE) {
......@@ -581,10 +599,10 @@ in mtr down to the given savepoint. If io is required, this function
retrieves the page to buffer buf_pool, but does not bufferfix it or latch
it. */
UNIV_INLINE
buf_frame_t*
buf_block_t*
buf_page_get_release_on_io(
/*=======================*/
/* out: pointer to the frame, or NULL
/* out: pointer to the block, or NULL
if not in buffer buf_pool */
ulint space, /* in: space id */
ulint offset, /* in: offset of the page within space
......@@ -595,15 +613,15 @@ buf_page_get_release_on_io(
ulint savepoint, /* in: mtr savepoint */
mtr_t* mtr) /* in: mtr */
{
buf_frame_t* frame;
buf_block_t* block;
frame = buf_page_get_gen(space, offset, rw_latch, guess,
block = buf_page_get_gen(space, offset, rw_latch, guess,
BUF_GET_IF_IN_POOL,
__FILE__, __LINE__,
mtr);
if (frame != NULL) {
if (block != NULL) {
return(frame);
return(block);
}
/* The page was not in the buffer buf_pool: release the latches
......@@ -663,17 +681,15 @@ buf_page_release(
/*************************************************************************
Adds latch level info for the rw-lock protecting the buffer frame. This
should be called in the debug version after a successful latching of a
page if we know the latching order level of the acquired latch. If
UNIV_SYNC_DEBUG is not defined, compiles to an empty function. */
page if we know the latching order level of the acquired latch. */
UNIV_INLINE
void
buf_page_dbg_add_level(
/*===================*/
buf_frame_t* frame __attribute__((unused)), /* in: buffer page
buf_block_dbg_add_level(
/*====================*/
buf_block_t* block, /* in: buffer page
where we have acquired latch */
ulint level __attribute__((unused))) /* in: latching order
level */
ulint level) /* in: latching order level */
{
sync_thread_add_level(&(buf_block_align(frame)->lock), level);
sync_thread_add_level(&block->lock, level);
}
#endif /* UNIV_SYNC_DEBUG */
......@@ -125,10 +125,10 @@ fsp_header_inc_size(
/**************************************************************************
Creates a new segment. */
page_t*
buf_block_t*
fseg_create(
/*========*/
/* out: the page where the segment header is placed,
/* out: the block where the segment header is placed,
x-latched, NULL if could not create segment
because of lack of space */
ulint space, /* in: space id */
......@@ -142,10 +142,10 @@ fseg_create(
/**************************************************************************
Creates a new segment. */
page_t*
buf_block_t*
fseg_create_general(
/*================*/
/* out: the page where the segment header is placed,
/* out: the block where the segment header is placed,
x-latched, NULL if could not create segment
because of lack of space */
ulint space, /* in: space id */
......
......@@ -22,16 +22,17 @@ fut_get_ptr(
ulint rw_latch, /* in: RW_S_LATCH, RW_X_LATCH */
mtr_t* mtr) /* in: mtr handle */
{
byte* ptr;
buf_block_t* block;
byte* ptr;
ut_ad(mtr);
ut_ad(addr.boffset < UNIV_PAGE_SIZE);
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
ptr = buf_page_get(space, addr.page, rw_latch, mtr) + addr.boffset;
block = buf_page_get(space, addr.page, rw_latch, mtr);
ptr = buf_block_get_frame(block) + addr.boffset;
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(ptr, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
return(ptr);
......
......@@ -52,10 +52,8 @@ Initializes an ibuf bitmap page. */
void
ibuf_bitmap_page_init(
/*==================*/
page_t* page, /* in: bitmap page */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
mtr_t* mtr); /* in: mtr */
buf_block_t* block, /* in: bitmap page */
mtr_t* mtr); /* in: mtr */
/****************************************************************************
Resets the free bits of the page in the ibuf bitmap. This is done in a
separate mini-transaction, hence this operation does not restrict further
......@@ -270,8 +268,6 @@ ibuf_parse_bitmap_init(
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
page_t* page, /* in: page or NULL */
ulint zip_size,/* in: compressed page size in bytes;
0 for uncompressed pages */
mtr_t* mtr); /* in: mtr or NULL */
#ifdef UNIV_IBUF_DEBUG
/**********************************************************************
......
......@@ -11,7 +11,7 @@ Created 9/20/1997 Heikki Tuuri
#include "univ.i"
#include "ut0byte.h"
#include "page0types.h"
#include "buf0types.h"
#include "hash0hash.h"
#include "log0log.h"
......@@ -72,15 +72,15 @@ read in, or also for a page already in the buffer pool. */
void
recv_recover_page(
/*==============*/
ibool recover_backup, /* in: TRUE if we are recovering a backup
ibool recover_backup,
/* in: TRUE if we are recovering a backup
page: then we do not acquire any latches
since the page was read in outside the
buffer pool */
ibool just_read_in, /* in: TRUE if the i/o-handler calls this for
ibool just_read_in,
/* in: TRUE if the i/o-handler calls this for
a freshly read page */
page_t* page, /* in: buffer page */
ulint space, /* in: space id */
ulint page_no); /* in: page number */
buf_block_t* block); /* in: buffer block */
/************************************************************
Recovers from a checkpoint. When this function returns, the database is able
to start processing of new user transactions, but the function
......
......@@ -20,13 +20,14 @@ trx_rsegf_get(
ulint page_no, /* in: page number of the header */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
trx_rsegf_t* header;
header = TRX_RSEG + buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(header, SYNC_RSEG_HEADER);
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER);
#endif /* UNIV_SYNC_DEBUG */
header = TRX_RSEG + buf_block_get_frame(block);
return(header);
}
......@@ -43,13 +44,14 @@ trx_rsegf_get_new(
ulint page_no, /* in: page number of the header */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
trx_rsegf_t* header;
header = TRX_RSEG + buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(header, SYNC_RSEG_HEADER_NEW);
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
#endif /* UNIV_SYNC_DEBUG */
header = TRX_RSEG + buf_block_get_frame(block);
return(header);
}
......
......@@ -95,16 +95,16 @@ trx_sysf_get(
/* out: pointer to system header, page x-latched. */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
trx_sysf_t* header;
ut_ad(mtr);
header = TRX_SYS + buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
RW_X_LATCH, mtr);
block = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(header, SYNC_TRX_SYS_HEADER);
buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
#endif /* UNIV_SYNC_DEBUG */
header = TRX_SYS + buf_block_get_frame(block);
return(header);
}
......
......@@ -131,15 +131,12 @@ trx_undo_page_get(
ulint page_no, /* in: page number */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
page = buf_page_get(space, page_no, RW_X_LATCH, mtr);
buf_block_t* block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TRX_UNDO_PAGE);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
return(page);
return(buf_block_get_frame(block));
}
/**********************************************************************
......@@ -153,15 +150,12 @@ trx_undo_page_get_s_latched(
ulint page_no, /* in: page number */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
page = buf_page_get(space, page_no, RW_S_LATCH, mtr);
buf_block_t* block = buf_page_get(space, page_no, RW_S_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TRX_UNDO_PAGE);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
return(page);
return(buf_block_get_frame(block));
}
/**********************************************************************
......
......@@ -4215,7 +4215,7 @@ lock_rec_print(
FILE* file, /* in: file where to print */
lock_t* lock) /* in: record type lock */
{
page_t* page;
buf_block_t* block;
ulint space;
ulint page_no;
ulint i;
......@@ -4273,25 +4273,25 @@ lock_rec_print(
because we have the kernel mutex and ibuf operations would
break the latching order */
page = buf_page_get_gen(space, page_no, RW_NO_LATCH,
NULL, BUF_GET_IF_IN_POOL,
__FILE__, __LINE__, &mtr);
if (page) {
page = buf_page_get_nowait(space, page_no, RW_S_LATCH, &mtr);
block = buf_page_get_gen(space, page_no, RW_NO_LATCH,
NULL, BUF_GET_IF_IN_POOL,
__FILE__, __LINE__, &mtr);
if (block) {
block = buf_page_get_nowait(space, page_no, RW_S_LATCH, &mtr);
if (!page) {
if (!block) {
/* Let us try to get an X-latch. If the current thread
is holding an X-latch on the page, we cannot get an
S-latch. */
page = buf_page_get_nowait(space, page_no, RW_X_LATCH,
&mtr);
block = buf_page_get_nowait(space, page_no, RW_X_LATCH,
&mtr);
}
}
if (page) {
if (block) {
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
}
......@@ -4301,9 +4301,10 @@ lock_rec_print(
fprintf(file, "Record lock, heap no %lu ", (ulong) i);
if (page) {
if (block) {
rec_t* rec
= page_find_rec_with_heap_no(page, i);
= page_find_rec_with_heap_no(
buf_block_get_frame(block), i);
offsets = rec_get_offsets(
rec, lock->index, offsets,
ULINT_UNDEFINED, &heap);
......@@ -4408,7 +4409,6 @@ lock_print_info_all_transactions(
lock_t* lock;
ulint space;
ulint page_no;
page_t* page;
ibool load_page_first = TRUE;
ulint nth_trx = 0;
ulint nth_lock = 0;
......@@ -4528,8 +4528,7 @@ lock_print_info_all_transactions(
mtr_start(&mtr);
page = buf_page_get_with_no_latch(
space, page_no, &mtr);
buf_page_get_with_no_latch(space, page_no, &mtr);
mtr_commit(&mtr);
......@@ -4745,13 +4744,14 @@ lock_rec_validate_page(
ulint page_no)/* in: page number */
{
dict_index_t* index;
page_t* page;
lock_t* lock;
rec_t* rec;
ulint nth_lock = 0;
ulint nth_bit = 0;
ulint i;
mtr_t mtr;
buf_block_t* block;
page_t* page;
lock_t* lock;
rec_t* rec;
ulint nth_lock = 0;
ulint nth_bit = 0;
ulint i;
mtr_t mtr;
mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
......@@ -4763,10 +4763,11 @@ lock_rec_validate_page(
mtr_start(&mtr);
page = buf_page_get(space, page_no, RW_X_LATCH, &mtr);
block = buf_page_get(space, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
page = buf_block_get_frame(block);
lock_mutex_enter_kernel();
loop:
......
......@@ -918,9 +918,7 @@ recv_parse_or_apply_log_rec_body(
}
break;
case MLOG_IBUF_BITMAP_INIT:
ptr = ibuf_parse_bitmap_init(ptr, end_ptr, page,
page_zip ? page_zip->size : 0,
mtr);
ptr = ibuf_parse_bitmap_init(ptr, end_ptr, page, mtr);
break;
case MLOG_INIT_FILE_PAGE:
ptr = fsp_parse_init_file_page(ptr, end_ptr, page);
......@@ -1146,18 +1144,18 @@ read in, or also for a page already in the buffer pool. */
void
recv_recover_page(
/*==============*/
ibool recover_backup, /* in: TRUE if we are recovering a backup
ibool recover_backup,
/* in: TRUE if we are recovering a backup
page: then we do not acquire any latches
since the page was read in outside the
buffer pool */
ibool just_read_in, /* in: TRUE if the i/o-handler calls this for
ibool just_read_in,
/* in: TRUE if the i/o-handler calls this for
a freshly read page */
page_t* page, /* in: buffer page */
ulint space, /* in: space id */
ulint page_no) /* in: page number */
buf_block_t* block) /* in: buffer block */
{
buf_block_t* block = NULL;
page_zip_des_t* page_zip = NULL;
page_t* page;
page_zip_des_t* page_zip;
recv_addr_t* recv_addr;
recv_t* recv;
byte* buf;
......@@ -1180,7 +1178,7 @@ recv_recover_page(
return;
}
recv_addr = recv_get_fil_addr_struct(space, page_no);
recv_addr = recv_get_fil_addr_struct(block->space, block->offset);
if ((recv_addr == NULL)
|| (recv_addr->state == RECV_BEING_PROCESSED)
......@@ -1192,7 +1190,8 @@ recv_recover_page(
}
#if 0
fprintf(stderr, "Recovering space %lu, page %lu\n", space, page_no);
fprintf(stderr, "Recovering space %lu, page %lu\n",
block->space, block->offset);
#endif
recv_addr->state = RECV_BEING_PROCESSED;
......@@ -1202,10 +1201,10 @@ recv_recover_page(
mtr_start(&mtr);
mtr_set_log_mode(&mtr, MTR_LOG_NONE);
if (!recover_backup) {
block = buf_block_align(page);
page_zip = buf_frame_get_page_zip(page);
page = block->frame;
page_zip = buf_block_get_page_zip(block);
if (!recover_backup) {
if (just_read_in) {
/* Move the ownership of the x-latch on the
page to this OS thread, so that we can acquire
......@@ -1216,14 +1215,14 @@ recv_recover_page(
rw_lock_x_lock_move_ownership(&(block->lock));
}
success = buf_page_get_known_nowait(RW_X_LATCH, page,
success = buf_page_get_known_nowait(RW_X_LATCH, block,
BUF_KEEP_OLD,
__FILE__, __LINE__,
&mtr);
ut_a(success);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
}
......@@ -1234,7 +1233,7 @@ 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_frame_get_newest_modification(page);
page_newest_lsn = buf_block_get_newest_modification(block);
if (!ut_dulint_is_zero(page_newest_lsn)) {
......@@ -1406,7 +1405,6 @@ recv_apply_hashed_log_recs(
mutex */
{
recv_addr_t* recv_addr;
page_t* page;
ulint i;
ulint space;
ulint page_no;
......@@ -1457,18 +1455,17 @@ recv_apply_hashed_log_recs(
mutex_exit(&(recv_sys->mutex));
if (buf_page_peek(space, page_no)) {
buf_block_t* block;
mtr_start(&mtr);
page = buf_page_get(space, page_no,
RW_X_LATCH, &mtr);
block = buf_page_get(space, page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(
page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(
block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
recv_recover_page(FALSE, FALSE, page,
space, page_no);
recv_recover_page(FALSE, FALSE, block);
mtr_commit(&mtr);
} else {
recv_read_in_area(space, page_no);
......
......@@ -3510,8 +3510,9 @@ page_zip_reorganize(
dict_index_t* index, /* in: index of the B-tree node */
mtr_t* mtr) /* in: mini-transaction */
{
page_t* temp_page;
ulint log_mode;
buf_block_t* block;
page_t* temp_page;
ulint log_mode;
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_is_comp(page));
......@@ -3529,7 +3530,8 @@ page_zip_reorganize(
segment headers, next page-field, etc.) is preserved intact */
page_create(page, mtr, dict_table_is_comp(index->table));
buf_block_align(page)->check_index_page_at_flush = TRUE;
block = buf_block_align(page);
block->check_index_page_at_flush = TRUE;
/* Copy the records from the temporary space to the recreated page;
do not copy the lock bits yet */
......@@ -3552,7 +3554,7 @@ page_zip_reorganize(
}
lock_move_reorganize_page(page, temp_page);
btr_search_drop_page_hash_index(page);
btr_search_drop_page_hash_index(block);
buf_frame_free(temp_page);
return(TRUE);
......
......@@ -404,8 +404,9 @@ row_purge_upd_exist_or_extern(
ufield = upd_get_nth_field(node->update, i);
if (UNIV_UNLIKELY(ufield->extern_storage)) {
ulint internal_offset;
byte* data_field;
buf_block_t* block;
ulint internal_offset;
byte* data_field;
/* We use the fact that new_val points to
node->undo_rec and get thus the offset of
......@@ -444,13 +445,13 @@ row_purge_upd_exist_or_extern(
/* We assume in purge of externally stored fields
that the space id of the undo log record is 0! */
data_field = buf_page_get(0, page_no, RW_X_LATCH, &mtr)
+ offset + internal_offset;
block = buf_page_get(0, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page_align(data_field),
SYNC_TRX_UNDO_PAGE);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
data_field = buf_block_get_frame(block)
+ offset + internal_offset;
ut_a(ufield->new_val.len >= BTR_EXTERN_FIELD_REF_SIZE);
btr_free_externally_stored_field(
index, data_field + ufield->new_val.len
......
......@@ -1093,15 +1093,16 @@ trx_undo_report_row_operation(
mtr_start(&mtr);
for (;;) {
undo_page = buf_page_get_gen(undo->space, page_no,
RW_X_LATCH, undo->guess_page,
BUF_GET,
__FILE__, __LINE__,
&mtr);
buf_block_t* block = buf_page_get_gen(undo->space, page_no,
RW_X_LATCH,
undo->guess_page,
BUF_GET,
__FILE__, __LINE__,
&mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
undo_page = buf_block_get_frame(block);
if (op_type == TRX_UNDO_INSERT_OP) {
offset = trx_undo_page_report_insert(
......
......@@ -57,7 +57,7 @@ trx_rseg_header_create(
trx_rsegf_t* rsegf;
trx_sysf_t* sys_header;
ulint i;
page_t* page;
buf_block_t* block;
ut_ad(mtr);
#ifdef UNIV_SYNC_DEBUG
......@@ -75,19 +75,19 @@ trx_rseg_header_create(
}
/* Allocate a new file segment for the rollback segment */
page = fseg_create(space, 0, TRX_RSEG + TRX_RSEG_FSEG_HEADER, mtr);
block = fseg_create(space, 0, TRX_RSEG + TRX_RSEG_FSEG_HEADER, mtr);
if (page == NULL) {
if (block == NULL) {
/* No space left */
return(FIL_NULL);
}
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_RSEG_HEADER_NEW);
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
#endif /* UNIV_SYNC_DEBUG */
page_no = page_get_page_no(page);
page_no = buf_block_get_page_no(block);
/* Get the rollback segment file page */
rsegf = trx_rsegf_get_new(space, page_no, mtr);
......
......@@ -126,9 +126,9 @@ void
trx_sys_mark_upgraded_to_multiple_tablespaces(void)
/*===============================================*/
{
page_t* page;
byte* doublewrite;
mtr_t mtr;
buf_block_t* block;
byte* doublewrite;
mtr_t mtr;
/* We upgraded to 4.1.x and reset the space id fields in the
doublewrite buffer. Let us mark to the trx_sys header that the upgrade
......@@ -136,12 +136,12 @@ trx_sys_mark_upgraded_to_multiple_tablespaces(void)
mtr_start(&mtr);
page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
block = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
doublewrite = page + TRX_SYS_DOUBLEWRITE;
doublewrite = buf_block_get_frame(block) + TRX_SYS_DOUBLEWRITE;
mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED,
TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N,
......@@ -162,9 +162,9 @@ void
trx_sys_create_doublewrite_buf(void)
/*================================*/
{
page_t* page;
page_t* page2;
page_t* new_page;
buf_block_t* block;
buf_block_t* block2;
buf_block_t* new_block;
byte* doublewrite;
byte* fseg_header;
ulint page_no;
......@@ -181,12 +181,12 @@ trx_sys_create_doublewrite_buf(void)
start_again:
mtr_start(&mtr);
page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
block = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
doublewrite = page + TRX_SYS_DOUBLEWRITE;
doublewrite = buf_block_get_frame(block) + TRX_SYS_DOUBLEWRITE;
if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC)
== TRX_SYS_DOUBLEWRITE_MAGIC_N) {
......@@ -214,18 +214,18 @@ trx_sys_create_doublewrite_buf(void)
exit(1);
}
page2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
TRX_SYS_DOUBLEWRITE
+ TRX_SYS_DOUBLEWRITE_FSEG, &mtr);
block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
TRX_SYS_DOUBLEWRITE
+ TRX_SYS_DOUBLEWRITE_FSEG, &mtr);
/* fseg_create acquires a second latch on the page,
therefore we must declare it: */
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page2, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(block2, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
if (page2 == NULL) {
if (block2 == NULL) {
fprintf(stderr,
"InnoDB: Cannot create doublewrite buffer:"
" you must\n"
......@@ -238,8 +238,8 @@ trx_sys_create_doublewrite_buf(void)
exit(1);
}
fseg_header = page + TRX_SYS_DOUBLEWRITE
+ TRX_SYS_DOUBLEWRITE_FSEG;
fseg_header = buf_block_get_frame(block)
+ TRX_SYS_DOUBLEWRITE + TRX_SYS_DOUBLEWRITE_FSEG;
prev_page_no = 0;
for (i = 0; i < 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
......@@ -268,16 +268,18 @@ trx_sys_create_doublewrite_buf(void)
the page position in the tablespace, then the page
has not been written to in doublewrite. */
new_page = buf_page_get(TRX_SYS_SPACE, page_no,
RW_X_LATCH, &mtr);
new_block = buf_page_get(TRX_SYS_SPACE, page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK);
buf_block_dbg_add_level(new_block,
SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
/* Make a dummy change to the page to ensure it will
be written to disk in a flush */
mlog_write_ulint(new_page + FIL_PAGE_DATA,
mlog_write_ulint(buf_block_get_frame(new_block)
+ FIL_PAGE_DATA,
TRX_SYS_DOUBLEWRITE_MAGIC_N,
MLOG_4BYTES, &mtr);
......@@ -835,6 +837,7 @@ trx_sysf_create(
{
trx_sysf_t* sys_header;
ulint slot_no;
buf_block_t* block;
page_t* page;
ulint page_no;
ulint i;
......@@ -849,13 +852,14 @@ trx_sysf_create(
mutex_enter(&kernel_mutex);
/* Create the trx sys file block in a new allocated file segment */
page = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,
mtr);
ut_a(page_get_page_no(page) == TRX_SYS_PAGE_NO);
block = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,
mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TRX_SYS_HEADER);
buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
#endif /* UNIV_SYNC_DEBUG */
ut_a(buf_block_get_page_no(block) == TRX_SYS_PAGE_NO);
page = buf_block_get_frame(block);
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_TRX_SYS,
MLOG_2BYTES, mtr);
......
......@@ -388,6 +388,7 @@ trx_undo_seg_create(
{
ulint slot_no;
ulint space;
buf_block_t* block;
page_t* undo_page;
trx_upagef_t* page_hdr;
trx_usegf_t* seg_hdr;
......@@ -425,21 +426,22 @@ trx_undo_seg_create(
}
/* Allocate a new file segment for the undo log */
undo_page = fseg_create_general(space, 0,
TRX_UNDO_SEG_HDR
+ TRX_UNDO_FSEG_HEADER, TRUE, mtr);
block = fseg_create_general(space, 0,
TRX_UNDO_SEG_HDR
+ TRX_UNDO_FSEG_HEADER, TRUE, mtr);
fil_space_release_free_extents(space, n_reserved);
if (undo_page == NULL) {
if (block == NULL) {
/* No space left */
return(NULL);
}
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
undo_page = buf_block_get_frame(block);
page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
......
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