Commit 138ee610 authored by marko's avatar marko

branches/zip: Remove more references to buf_block_align().

ibuf_reset_free_bits(): Remove, as there already is a similar function
ibuf_reset_free_bits_with_type().

ibuf_reset_free_bits_with_type(), ibuf_set_free_bits(),
ibuf_update_free_bits_if_full(), btr_leaf_page_release(),
buf_page_make_young(): Replace page_t with buf_block_t.

btr_compress(): Replace btr_page_get() with btr_block_get().
parent 6064200d
......@@ -747,7 +747,7 @@ btr_create(
trees in the same mtr, otherwise the latch on a bitmap page would
prevent it because of the latching order */
ibuf_reset_free_bits_with_type(type, page);
ibuf_reset_free_bits_with_type(type, block);
/* In the following assertion we test that two records of maximum
allowed size fit on the root page: this fact is needed to ensure
......@@ -1164,7 +1164,7 @@ btr_root_raise_and_insert(
page_get_page_no(new_page));
#endif
ibuf_reset_free_bits(index, new_page);
ibuf_reset_free_bits_with_type(index->type, new_block);
/* Reposition the cursor to the child node */
page_cur_search(new_page, index, tuple,
PAGE_CUR_LE, page_cursor);
......@@ -1934,7 +1934,7 @@ btr_page_split_and_insert(
start of the function for a new split */
insert_failed:
/* We play safe and reset the free bits for new_page */
ibuf_reset_free_bits(cursor->index, new_page);
ibuf_reset_free_bits_with_type(cursor->index->type, new_block);
/* fprintf(stderr, "Split second round %lu\n",
page_get_page_no(page)); */
......@@ -2182,7 +2182,7 @@ btr_lift_page_up(
btr_page_free(index, page, mtr);
/* We play safe and reset the free bits for the father */
ibuf_reset_free_bits(index, father_page);
ibuf_reset_free_bits_with_type(index->type, father_block);
ut_ad(page_validate(father_page, index));
ut_ad(btr_check_node_ptr(index, father_page, mtr));
}
......@@ -2211,6 +2211,7 @@ btr_compress(
ulint space;
ulint left_page_no;
ulint right_page_no;
buf_block_t* merge_block;
page_t* merge_page;
page_zip_des_t* merge_page_zip;
ibool is_left;
......@@ -2252,16 +2253,18 @@ btr_compress(
if (is_left) {
merge_page = btr_page_get(space, left_page_no, RW_X_LATCH,
mtr);
merge_block = btr_block_get(space, left_page_no, RW_X_LATCH,
mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
merge_page = btr_page_get(space, right_page_no, RW_X_LATCH,
mtr);
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)
== page_get_page_no(page));
......@@ -2275,7 +2278,9 @@ btr_compress(
n_recs = page_get_n_recs(page);
data_size = page_get_data_size(page);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(merge_page) == page_is_comp(page));
#endif /* UNIV_BTR_DEBUG */
max_ins_size_reorg = page_get_max_insert_size_after_reorganize(
merge_page, n_recs);
......@@ -2314,13 +2319,11 @@ btr_compress(
}
}
merge_page_zip = buf_frame_get_page_zip(merge_page);
merge_page_zip = buf_block_get_page_zip(merge_block);
#ifdef UNIV_ZIP_DEBUG
if (UNIV_LIKELY_NULL(merge_page_zip)) {
ut_a(page_zip_validate(merge_page_zip, merge_page));
ut_a(page_zip_validate(
buf_frame_get_page_zip(page),
page));
ut_a(page_zip_validate(buf_frame_get_page_zip(page), page));
}
#endif /* UNIV_ZIP_DEBUG */
......@@ -2411,7 +2414,7 @@ btr_compress(
}
/* We have added new records to merge_page: update its free bits */
ibuf_update_free_bits_if_full(index, merge_page,
ibuf_update_free_bits_if_full(index, merge_block,
UNIV_PAGE_SIZE, ULINT_UNDEFINED);
ut_ad(page_validate(merge_page, index));
......@@ -2465,7 +2468,7 @@ btr_discard_only_page_on_level(
mtr, index);
/* We play safe and reset the free bits for the father */
ibuf_reset_free_bits(index, father_page);
ibuf_reset_free_bits_with_type(index->type, father_block);
} else {
ut_ad(page_get_n_recs(father_page) == 1);
......
......@@ -1030,6 +1030,7 @@ btr_cur_optimistic_insert(
big_rec_t* big_rec_vec = NULL;
dict_index_t* index;
page_cur_t* page_cursor;
buf_block_t* block;
page_t* page;
page_zip_des_t* page_zip;
ulint max_size;
......@@ -1044,9 +1045,10 @@ btr_cur_optimistic_insert(
*big_rec = NULL;
page = btr_cur_get_page(cursor);
block = buf_block_align(btr_cur_get_rec(cursor));
page = buf_block_get_frame(block);
index = cursor->index;
page_zip = buf_frame_get_page_zip(page);
page_zip = buf_block_get_page_zip(block);
if (!dtuple_check_typed_no_assert(entry)) {
fputs("InnoDB: Error in a tuple to insert into ", stderr);
......@@ -1059,7 +1061,7 @@ btr_cur_optimistic_insert(
}
#endif /* UNIV_DEBUG */
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
max_size = page_get_max_insert_size_after_reorganize(page, 1);
level = btr_page_get_level(page, mtr);
......@@ -1189,7 +1191,7 @@ btr_cur_optimistic_insert(
#endif
if (!(type & DICT_CLUSTERED)) {
/* We have added a record to page: update its free bits */
ibuf_update_free_bits_if_full(cursor->index, page, max_size,
ibuf_update_free_bits_if_full(cursor->index, block, max_size,
rec_size + PAGE_DIR_SLOT_SIZE);
}
......
......@@ -351,14 +351,14 @@ btr_pcur_release_leaf(
btr_pcur_t* cursor, /* in: persistent cursor */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
buf_block_t* block;
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor));
block = buf_block_align(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor)));
btr_leaf_page_release(page, cursor->latch_mode, mtr);
btr_leaf_page_release(block, cursor->latch_mode, mtr);
cursor->latch_mode = BTR_NO_LATCHES;
......@@ -378,10 +378,11 @@ btr_pcur_move_to_next_page(
last record of the current page */
mtr_t* mtr) /* in: mtr */
{
ulint next_page_no;
ulint space;
page_t* page;
page_t* next_page;
ulint next_page_no;
ulint space;
page_t* page;
buf_block_t* next_block;
page_t* next_page;
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
......@@ -396,14 +397,16 @@ btr_pcur_move_to_next_page(
ut_ad(next_page_no != FIL_NULL);
next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
next_block = btr_block_get(space, next_page_no,
cursor->latch_mode, mtr);
next_page = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(next_page) == page_is_comp(page));
buf_block_align(next_page)->check_index_page_at_flush = TRUE;
next_block->check_index_page_at_flush = TRUE;
btr_leaf_page_release(page, cursor->latch_mode, mtr);
btr_leaf_page_release(buf_block_align(page), cursor->latch_mode, mtr);
page_cur_set_before_first(next_page, btr_pcur_get_page_cur(cursor));
......@@ -471,7 +474,7 @@ btr_pcur_move_backward_from_page(
prev_page = btr_pcur_get_btr_cur(cursor)->left_page;
btr_leaf_page_release(page, latch_mode, mtr);
btr_leaf_page_release(buf_block_align(page), latch_mode, mtr);
page_cur_set_after_last(prev_page,
btr_pcur_get_page_cur(cursor));
......@@ -483,7 +486,8 @@ btr_pcur_move_backward_from_page(
prev_page = btr_pcur_get_btr_cur(cursor)->left_page;
btr_leaf_page_release(prev_page, latch_mode, mtr);
btr_leaf_page_release(buf_block_align(prev_page),
latch_mode, mtr);
}
cursor->latch_mode = latch_mode;
......
......@@ -756,8 +756,8 @@ btr_search_guess_on_hash(
goto failure_unlock;
}
page = page_align(rec);
block = buf_block_align(page);
block = buf_block_align(rec);
page = buf_block_get_frame(block);
if (UNIV_LIKELY(!has_search_latch)) {
......@@ -780,7 +780,7 @@ btr_search_guess_on_hash(
if (UNIV_UNLIKELY(block->state == BUF_BLOCK_REMOVE_HASH)) {
if (UNIV_LIKELY(!has_search_latch)) {
btr_leaf_page_release(page, latch_mode, mtr);
btr_leaf_page_release(block, latch_mode, mtr);
}
goto failure;
......@@ -804,7 +804,7 @@ btr_search_guess_on_hash(
can_only_compare_to_cursor_rec,
tuple, mode, mtr)) {
if (UNIV_LIKELY(!has_search_latch)) {
btr_leaf_page_release(page, latch_mode, mtr);
btr_leaf_page_release(block, latch_mode, mtr);
}
goto failure;
......@@ -824,7 +824,7 @@ btr_search_guess_on_hash(
/* Currently, does not work if the following fails: */
ut_ad(!has_search_latch);
btr_leaf_page_release(page, latch_mode, mtr);
btr_leaf_page_release(block, latch_mode, mtr);
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode,
&cursor2, 0, mtr);
......@@ -856,7 +856,7 @@ btr_search_guess_on_hash(
if (UNIV_LIKELY(!has_search_latch)
&& buf_block_peek_if_too_old(block)) {
buf_page_make_young(page);
buf_page_make_young(block);
}
/* Increment the page get statistics though we did not really
......
......@@ -984,14 +984,10 @@ the buffer pool. */
void
buf_page_make_young(
/*================*/
buf_frame_t* frame) /* in: buffer frame of a file page */
buf_block_t* block) /* in: buffer block of a file page */
{
buf_block_t* block;
mutex_enter(&(buf_pool->mutex));
block = buf_block_align(frame);
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
buf_LRU_make_block_young(block);
......
......@@ -832,15 +832,17 @@ were kept. */
void
ibuf_set_free_bits(
/*===============*/
ulint type, /* in: index type */
page_t* page, /* in: index page; free bit is set if the index is
non-clustered and page level is 0 */
ulint val, /* in: value to set: < 4 */
ulint max_val)/* in: ULINT_UNDEFINED or a maximum value which
the bits must have before setting; this is for
debugging */
ulint type, /* in: index type */
buf_block_t* block, /* in: index page; free bit is reset
if the index is a non-clustered
non-unique, and page level is 0 */
ulint val, /* in: value to set: < 4 */
ulint max_val)/* in: ULINT_UNDEFINED or a maximum
value which the bits must have before
setting; this is for debugging */
{
mtr_t mtr;
page_t* page;
page_t* bitmap_page;
ulint space;
ulint page_no;
......@@ -851,6 +853,8 @@ ibuf_set_free_bits(
return;
}
page = buf_block_get_frame(block);
if (!page_is_leaf(page)) {
return;
......@@ -858,9 +862,9 @@ ibuf_set_free_bits(
mtr_start(&mtr);
space = page_get_space_id(page);
page_no = page_get_page_no(page);
zip_size = fil_space_get_zip_size(space);
space = buf_block_get_space(block);
page_no = buf_block_get_page_no(block);
zip_size = buf_block_get_zip_size(block);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr);
if (max_val != ULINT_UNDEFINED) {
......@@ -905,29 +909,12 @@ bitmap page were kept. */
void
ibuf_reset_free_bits_with_type(
/*===========================*/
ulint type, /* in: index type */
page_t* page) /* in: index page; free bits are set to 0 if the index
is non-clustered and non-unique and the page level is
0 */
{
ibuf_set_free_bits(type, page, 0, ULINT_UNDEFINED);
}
/****************************************************************************
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
work to solely ibuf bitmap operations, which would result if the latch to
the bitmap page were kept. */
void
ibuf_reset_free_bits(
/*=================*/
dict_index_t* index, /* in: index */
page_t* page) /* in: index page; free bits are set to 0 if
the index is non-clustered and non-unique and
the page level is 0 */
ulint type, /* in: index type */
buf_block_t* block) /* in: index page; free bits are set to 0
if the index is a non-clustered
non-unique, and page level is 0 */
{
ibuf_set_free_bits(index->type, page, 0, ULINT_UNDEFINED);
ibuf_set_free_bits(type, block, 0, ULINT_UNDEFINED);
}
/**************************************************************************
......
......@@ -145,9 +145,10 @@ UNIV_INLINE
void
btr_leaf_page_release(
/*==================*/
page_t* page, /* in: page */
ulint latch_mode, /* in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */
mtr_t* mtr); /* in: mtr */
buf_block_t* block, /* in: buffer block */
ulint latch_mode, /* in: BTR_SEARCH_LEAF or
BTR_MODIFY_LEAF */
mtr_t* mtr); /* in: mtr */
/******************************************************************
Gets the child node file address in a node pointer. */
UNIV_INLINE
......
......@@ -263,14 +263,15 @@ UNIV_INLINE
void
btr_leaf_page_release(
/*==================*/
page_t* page, /* in: page */
ulint latch_mode, /* in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */
mtr_t* mtr) /* in: mtr */
buf_block_t* block, /* in: buffer block */
ulint latch_mode, /* in: BTR_SEARCH_LEAF or
BTR_MODIFY_LEAF */
mtr_t* mtr) /* in: mtr */
{
ut_ad(latch_mode == BTR_SEARCH_LEAF || latch_mode == BTR_MODIFY_LEAF);
ut_ad(!mtr_memo_contains_page(mtr, page, MTR_MEMO_MODIFY));
ut_ad(!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY));
mtr_memo_release(mtr, buf_block_align(page),
mtr_memo_release(mtr, block,
latch_mode == BTR_SEARCH_LEAF
? MTR_MEMO_PAGE_S_FIX
: MTR_MEMO_PAGE_X_FIX);
......
......@@ -277,7 +277,7 @@ the buffer pool. */
void
buf_page_make_young(
/*================*/
buf_frame_t* frame); /* in: buffer frame of a file page */
buf_block_t* block); /* in: buffer block of a file page */
/************************************************************************
Returns TRUE if the page can be found in the buffer pool hash table. NOTE
that it is possible that the page is not yet read from disk, though. */
......
......@@ -63,23 +63,10 @@ bitmap page were kept. */
void
ibuf_reset_free_bits_with_type(
/*===========================*/
ulint type, /* in: index type */
page_t* page); /* in: index page; free bits are set to 0 if the index
is non-clustered and non-unique and the page level is
0 */
/****************************************************************************
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
work to solely ibuf bitmap operations, which would result if the latch to
the bitmap page were kept. */
void
ibuf_reset_free_bits(
/*=================*/
dict_index_t* index, /* in: index */
page_t* page); /* in: index page; free bits are set to 0 if
the index is non-clustered and non-unique and
the page level is 0 */
ulint type, /* in: index type */
buf_block_t* block); /* in: index page; free bits are set to 0
if the index is a non-clustered
non-unique, and page level is 0 */
/****************************************************************************
Updates the free bits of the page in the ibuf bitmap if there is not enough
free on the page any more. This is done in a separate mini-transaction, hence
......@@ -90,7 +77,7 @@ void
ibuf_update_free_bits_if_full(
/*==========================*/
dict_index_t* index, /* in: index */
page_t* page, /* in: index page to which we have added new
buf_block_t* block, /* in: index page to which we have added new
records; the free bits are updated if the
index is non-clustered and non-unique and
the page level is 0, and the page becomes
......
......@@ -58,13 +58,14 @@ were kept. */
void
ibuf_set_free_bits(
/*===============*/
ulint type, /* in: index type */
page_t* page, /* in: index page; free bit is reset if the index is
a non-clustered non-unique, and page level is 0 */
ulint val, /* in: value to set: < 4 */
ulint max_val);/* in: ULINT_UNDEFINED or a maximum value which
the bits must have before setting; this is for
debugging */
ulint type, /* in: index type */
buf_block_t* block, /* in: index page; free bit is reset
if the index is a non-clustered
non-unique, and page level is 0 */
ulint val, /* in: value to set: < 4 */
ulint max_val);/* in: ULINT_UNDEFINED or a maximum
value which the bits must have before
setting; this is for debugging */
/**************************************************************************
A basic partial test if an insert to the insert buffer could be possible and
......@@ -185,7 +186,7 @@ void
ibuf_update_free_bits_if_full(
/*==========================*/
dict_index_t* index, /* in: index */
page_t* page, /* in: index page to which we have added new
buf_block_t* block, /* in: index page to which we have added new
records; the free bits are updated if the
index is non-clustered and non-unique and
the page level is 0, and the page becomes
......@@ -209,10 +210,11 @@ ibuf_update_free_bits_if_full(
after = ibuf_index_page_calc_free_bits(max_ins_size
- increase);
#ifdef UNIV_IBUF_DEBUG
ut_a(after <= ibuf_index_page_calc_free(page));
ut_a(after <= ibuf_index_page_calc_free(buf_block_get_frame(
block)));
#endif
} else {
after = ibuf_index_page_calc_free(page);
after = ibuf_index_page_calc_free(buf_block_get_frame(block));
}
if (after == 0) {
......@@ -221,10 +223,10 @@ ibuf_update_free_bits_if_full(
cannot make inserts using the insert buffer from slipping
out of the buffer pool */
buf_page_make_young(page);
buf_page_make_young(block);
}
if (before > after) {
ibuf_set_free_bits(index->type, page, after, before);
ibuf_set_free_bits(index->type, block, after, before);
}
}
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