From 968de5a54efa9da28b66b4eeeba539657f8bf956 Mon Sep 17 00:00:00 2001 From: marko Date: Fri, 13 Oct 2006 09:15:17 +0000 Subject: [PATCH] branches/zip: Eliminate some more buf_block_align() calls. ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low(), ibuf_set_free_bits_low(): Replace page_t with buf_block_t. --- btr/btr0btr.c | 89 +++++++++++++++++++++++++-------------------- btr/btr0cur.c | 12 +++--- ibuf/ibuf0ibuf.c | 41 +++++++++++---------- include/ibuf0ibuf.h | 6 +-- 4 files changed, 80 insertions(+), 68 deletions(-) diff --git a/btr/btr0btr.c b/btr/btr0btr.c index f16e9a0aeac..be10b2c154f 100644 --- a/btr/btr0btr.c +++ b/btr/btr0btr.c @@ -1683,6 +1683,7 @@ btr_page_split_and_insert( ulint n_ext, /* in: number of elements in vec */ mtr_t* mtr) /* in: mtr */ { + buf_block_t* block; page_t* page; page_zip_des_t* page_zip; ulint page_no; @@ -1692,8 +1693,9 @@ btr_page_split_and_insert( page_t* new_page; page_zip_des_t* new_page_zip; rec_t* split_rec; - page_t* left_page; - page_t* right_page; + buf_block_t* left_block; + buf_block_t* right_block; + buf_block_t* insert_block; page_t* insert_page; page_zip_des_t* insert_page_zip; page_cur_t* page_cursor; @@ -1720,8 +1722,9 @@ func_start: ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - page = btr_cur_get_page(cursor); - page_zip = buf_frame_get_page_zip(page); + block = buf_block_align(btr_cur_get_rec(cursor)); + page = buf_block_get_frame(block); + page_zip = buf_block_get_page_zip(block); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(page_get_n_recs(page) >= 1); @@ -1832,10 +1835,10 @@ func_start: page_zip, mtr); } - left_page = new_page; - right_page = page; + left_block = new_block; + right_block = block; - lock_update_split_left(right_page, left_page); + lock_update_split_left(page, new_page); } else { /* fputs("Split right\n", stderr); */ @@ -1861,10 +1864,10 @@ func_start: page_zip, mtr); } - left_page = page; - right_page = new_page; + left_block = block; + right_block = new_block; - lock_update_split_right(right_page, left_page); + lock_update_split_right(new_page, page); } #ifdef UNIV_ZIP_DEBUG @@ -1881,12 +1884,13 @@ func_start: page where the tuple should be inserted */ if (insert_left) { - insert_page = left_page; + insert_block = left_block; } else { - insert_page = right_page; + insert_block = right_block; } - insert_page_zip = buf_frame_get_page_zip(insert_page); + insert_page = buf_block_get_frame(insert_block); + insert_page_zip = buf_block_get_page_zip(insert_block); /* 7. Reposition the cursor for insert and try insertion */ page_cursor = btr_cur_get_page_cur(cursor); @@ -1907,11 +1911,11 @@ func_start: left and right pages in the same mtr */ ibuf_update_free_bits_for_two_pages_low(cursor->index, - left_page, - right_page, mtr); + left_block, + right_block, mtr); /* fprintf(stderr, "Split and insert done %lu %lu\n", - page_get_page_no(left_page), - page_get_page_no(right_page)); */ + page_get_page_no(buf_block_get_frame(left_block)), + page_get_page_no(buf_block_get_frame(right_block))); */ mem_heap_free(heap); return(rec); } @@ -1948,16 +1952,16 @@ insert_failed: /* Insert fit on the page: update the free bits for the left and right pages in the same mtr */ - ibuf_update_free_bits_for_two_pages_low(cursor->index, left_page, - right_page, mtr); + ibuf_update_free_bits_for_two_pages_low(cursor->index, left_block, + right_block, mtr); #if 0 fprintf(stderr, "Split and insert done %lu %lu\n", - page_get_page_no(left_page), - page_get_page_no(right_page)); + buf_block_get_page_no(left_block), + buf_block_get_page_no(right_block)); #endif - ut_ad(page_validate(left_page, cursor->index)); - ut_ad(page_validate(right_page, cursor->index)); + ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index)); + ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index)); mem_heap_free(heap); return(rec); @@ -1974,9 +1978,7 @@ btr_level_list_remove( { ulint space; ulint prev_page_no; - page_t* prev_page; ulint next_page_no; - page_t* next_page; ut_ad(page && mtr); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); @@ -1989,28 +1991,34 @@ btr_level_list_remove( /* Update page links of the level */ if (prev_page_no != FIL_NULL) { - - prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr); + buf_block_t* prev_block + = btr_block_get(space, prev_page_no, RW_X_LATCH, mtr); + page_t* prev_page + = buf_block_get_frame(prev_block); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(prev_page) == page_is_comp(page)); ut_a(btr_page_get_next(prev_page, mtr) == page_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ - btr_page_set_next(prev_page, buf_frame_get_page_zip(prev_page), + btr_page_set_next(prev_page, + buf_block_get_page_zip(prev_block), next_page_no, mtr); } if (next_page_no != FIL_NULL) { - - next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr); + buf_block_t* next_block + = btr_block_get(space, next_page_no, RW_X_LATCH, mtr); + page_t* 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 */ - btr_page_set_prev(next_page, buf_frame_get_page_zip(next_page), + btr_page_set_prev(next_page, + buf_block_get_page_zip(next_block), prev_page_no, mtr); } } @@ -2172,7 +2180,7 @@ btr_lift_page_up( /* Copy the page byte for byte. */ page_zip_copy(father_page_zip, father_page, - buf_frame_get_page_zip(page), + buf_block_get_page_zip(block), page, index, mtr); } @@ -2433,17 +2441,18 @@ void btr_discard_only_page_on_level( /*===========================*/ dict_index_t* index, /* in: index tree */ - page_t* page, /* in: page which is the only on its level */ + buf_block_t* block, /* in: page which is the only on its level */ mtr_t* mtr) /* in: mtr */ { buf_block_t* father_block; page_t* father_page; + page_t* page = buf_block_get_frame(block); ulint page_level; ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); - ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); - btr_search_drop_page_hash_index(buf_block_align(page)); + ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); + btr_search_drop_page_hash_index(block); father_block = buf_block_align( btr_page_get_father_node_ptr(index, page, mtr)); @@ -2453,7 +2462,7 @@ btr_discard_only_page_on_level( lock_update_discard(page_get_supremum_rec(father_page), page); - btr_page_set_level(father_page, buf_frame_get_page_zip(father_page), + btr_page_set_level(father_page, buf_block_get_page_zip(father_block), page_level, mtr); /* Free the file page */ @@ -2472,7 +2481,7 @@ btr_discard_only_page_on_level( } else { ut_ad(page_get_n_recs(father_page) == 1); - btr_discard_only_page_on_level(index, father_page, mtr); + btr_discard_only_page_on_level(index, father_block, mtr); } } @@ -2493,10 +2502,12 @@ btr_discard_page( ulint left_page_no; ulint right_page_no; page_t* merge_page; + buf_block_t* block; page_t* page; rec_t* node_ptr; - page = btr_cur_get_page(cursor); + block = buf_block_align(btr_cur_get_rec(cursor)); + page = buf_block_get_frame(block); index = btr_cur_get_index(cursor); ut_ad(dict_index_get_page(index) != page_get_page_no(page)); @@ -2525,7 +2536,7 @@ btr_discard_page( == page_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ } else { - btr_discard_only_page_on_level(index, page, mtr); + btr_discard_only_page_on_level(index, block, mtr); return; } diff --git a/btr/btr0cur.c b/btr/btr0cur.c index 81aec45fe97..284c9985b71 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -2618,7 +2618,7 @@ btr_cur_optimistic_delete( successor of the deleted record */ mtr_t* mtr) /* in: mtr */ { - page_t* page; + buf_block_t* block; ulint max_ins_size; rec_t* rec; mem_heap_t* heap = NULL; @@ -2631,9 +2631,9 @@ btr_cur_optimistic_delete( MTR_MEMO_PAGE_X_FIX)); /* This is intended only for leaf page deletions */ - page = btr_cur_get_page(cursor); + block = buf_block_align(btr_cur_get_rec(cursor)); - ut_ad(page_is_leaf(page)); + ut_ad(page_is_leaf(buf_block_get_frame(block))); rec = btr_cur_get_rec(cursor); offsets = rec_get_offsets(rec, cursor->index, offsets, @@ -2645,7 +2645,8 @@ btr_cur_optimistic_delete( if (no_compress_needed) { - page_zip_des_t* page_zip; + page_t* page = buf_block_get_frame(block); + page_zip_des_t* page_zip= buf_block_get_page_zip(block); lock_update_delete(rec); @@ -2653,7 +2654,6 @@ btr_cur_optimistic_delete( max_ins_size = page_get_max_insert_size_after_reorganize( page, 1); - page_zip = buf_frame_get_page_zip(btr_cur_get_rec(cursor)); #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ @@ -2663,7 +2663,7 @@ btr_cur_optimistic_delete( ut_a(!page_zip || page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ - ibuf_update_free_bits_low(cursor->index, page, max_ins_size, + ibuf_update_free_bits_low(cursor->index, block, max_ins_size, mtr); } diff --git a/ibuf/ibuf0ibuf.c b/ibuf/ibuf0ibuf.c index a61e7675cc9..60374a5ccae 100644 --- a/ibuf/ibuf0ibuf.c +++ b/ibuf/ibuf0ibuf.c @@ -784,11 +784,12 @@ UNIV_INLINE void ibuf_set_free_bits_low( /*===================*/ - 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 */ - mtr_t* mtr) /* in: mtr */ + ulint type, /* in: index type */ + buf_block_t* block, /* in: index page; free bits are set if + the index is non-clustered and page + level is 0 */ + ulint val, /* in: value to set: < 4 */ + mtr_t* mtr) /* in: mtr */ { page_t* bitmap_page; ulint space; @@ -800,24 +801,24 @@ ibuf_set_free_bits_low( return; } - if (!page_is_leaf(page)) { + if (!page_is_leaf(buf_block_get_frame(block))) { return; } - 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); #ifdef UNIV_IBUF_DEBUG # if 0 fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n", page_get_page_no(page), val, - ibuf_index_page_calc_free(page)); + ibuf_index_page_calc_free(buf_block_get_frame(block))); # endif - ut_a(val <= ibuf_index_page_calc_free(page)); + ut_a(val <= ibuf_index_page_calc_free(buf_block_get_frame(block))); #endif /* UNIV_IBUF_DEBUG */ ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size, IBUF_BITMAP_FREE, val, mtr); @@ -926,7 +927,7 @@ void ibuf_update_free_bits_low( /*======================*/ dict_index_t* index, /* in: index */ - page_t* page, /* in: index page */ + buf_block_t* block, /* in: index page */ ulint max_ins_size, /* in: value of maximum insert size with reorganize before the latest operation performed to the page */ @@ -937,10 +938,10 @@ ibuf_update_free_bits_low( before = ibuf_index_page_calc_free_bits(max_ins_size); - after = ibuf_index_page_calc_free(page); + after = ibuf_index_page_calc_free(buf_block_get_frame(block)); if (before != after) { - ibuf_set_free_bits_low(index->type, page, after, mtr); + ibuf_set_free_bits_low(index->type, block, after, mtr); } } @@ -953,8 +954,8 @@ void ibuf_update_free_bits_for_two_pages_low( /*====================================*/ dict_index_t* index, /* in: index */ - page_t* page1, /* in: index page */ - page_t* page2, /* in: index page */ + buf_block_t* block1, /* in: index page */ + buf_block_t* block2, /* in: index page */ mtr_t* mtr) /* in: mtr */ { ulint state; @@ -965,13 +966,13 @@ ibuf_update_free_bits_for_two_pages_low( mutex_enter(&ibuf_bitmap_mutex); - state = ibuf_index_page_calc_free(page1); + state = ibuf_index_page_calc_free(buf_block_get_frame(block1)); - ibuf_set_free_bits_low(index->type, page1, state, mtr); + ibuf_set_free_bits_low(index->type, block1, state, mtr); - state = ibuf_index_page_calc_free(page2); + state = ibuf_index_page_calc_free(buf_block_get_frame(block2)); - ibuf_set_free_bits_low(index->type, page2, state, mtr); + ibuf_set_free_bits_low(index->type, block2, state, mtr); mutex_exit(&ibuf_bitmap_mutex); } diff --git a/include/ibuf0ibuf.h b/include/ibuf0ibuf.h index 4027074e270..664bc19d623 100644 --- a/include/ibuf0ibuf.h +++ b/include/ibuf0ibuf.h @@ -97,7 +97,7 @@ void ibuf_update_free_bits_low( /*======================*/ dict_index_t* index, /* in: index */ - page_t* page, /* in: index page */ + buf_block_t* block, /* in: index page */ ulint max_ins_size, /* in: value of maximum insert size with reorganize before the latest operation performed to the page */ @@ -111,8 +111,8 @@ void ibuf_update_free_bits_for_two_pages_low( /*====================================*/ dict_index_t* index, /* in: index */ - page_t* page1, /* in: index page */ - page_t* page2, /* in: index page */ + buf_block_t* block1, /* in: index page */ + buf_block_t* block2, /* in: index page */ mtr_t* mtr); /* in: mtr */ /************************************************************************** A basic partial test if an insert to the insert buffer could be possible and