From 1d2458f813a6af0335faf1bc092805954f526ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 13:26:19 +0200 Subject: MDEV-21024: Clean up rtr_adjust_upper_level() Remove the unnecessary retrieval and null-modifications of the preceding page. --- storage/innobase/gis/gis0rtree.cc | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'storage') diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index dc9e34903c2..befa94d263b 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -649,7 +649,6 @@ rtr_adjust_upper_level( mem_heap_t* heap; ulint level; dtuple_t* node_ptr_upper; - ulint prev_page_no; ulint next_page_no; ulint space; page_cur_t* page_cursor; @@ -760,28 +759,10 @@ rtr_adjust_upper_level( mem_heap_free(heap); /* Get the previous and next pages of page */ - prev_page_no = btr_page_get_prev(page, mtr); next_page_no = btr_page_get_next(page, mtr); space = block->page.id.space(); const page_size_t& page_size = dict_table_page_size(index->table); - /* Update page links of the level */ - if (prev_page_no != FIL_NULL) { - page_id_t prev_page_id(space, prev_page_no); - - buf_block_t* prev_block = btr_block_get( - prev_page_id, page_size, RW_X_LATCH, index, mtr); -#ifdef UNIV_BTR_DEBUG - ut_a(page_is_comp(prev_block->frame) == page_is_comp(page)); - ut_a(btr_page_get_next(prev_block->frame, mtr) - == block->page.id.page_no()); -#endif /* UNIV_BTR_DEBUG */ - - btr_page_set_next(buf_block_get_frame(prev_block), - buf_block_get_page_zip(prev_block), - page_no, mtr); - } - if (next_page_no != FIL_NULL) { page_id_t next_page_id(space, next_page_no); @@ -798,7 +779,6 @@ rtr_adjust_upper_level( new_page_no, mtr); } - btr_page_set_prev(page, page_zip, prev_page_no, mtr); btr_page_set_next(page, page_zip, new_page_no, mtr); btr_page_set_prev(new_page, new_page_zip, page_no, mtr); -- cgit v1.2.1 From 29d67d051a3f6b252c0ab3c3720e6467e4f9a7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 13:36:21 +0200 Subject: Cleanup btr_page_get_prev(), btr_page_get_next() Remove the redundant parameter mtr_t*. Make use of page_has_prev(), page_has_next() whenever possible. --- storage/innobase/btr/btr0btr.cc | 58 ++++++++++++++++------------------ storage/innobase/btr/btr0cur.cc | 36 +++++++++------------ storage/innobase/btr/btr0defragment.cc | 2 +- storage/innobase/btr/btr0pcur.cc | 6 ++-- storage/innobase/btr/btr0scrub.cc | 8 ++--- storage/innobase/btr/btr0sea.cc | 8 ++--- storage/innobase/gis/gis0rtree.cc | 30 +++++++----------- storage/innobase/gis/gis0sea.cc | 4 +-- storage/innobase/ibuf/ibuf0ibuf.cc | 8 ++--- storage/innobase/include/btr0btr.h | 37 ++++++++++------------ storage/innobase/include/btr0btr.ic | 33 ------------------- storage/innobase/page/page0cur.cc | 2 +- storage/innobase/row/row0merge.cc | 2 +- 13 files changed, 89 insertions(+), 145 deletions(-) (limited to 'storage') diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index a325475cdb5..98818dd40c2 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -2480,8 +2480,8 @@ btr_attach_half_pages( } /* Get the previous and next pages of page */ - prev_page_no = btr_page_get_prev(page, mtr); - next_page_no = btr_page_get_next(page, mtr); + prev_page_no = btr_page_get_prev(page); + next_page_no = btr_page_get_next(page); const ulint space = block->page.id.space(); @@ -2522,7 +2522,7 @@ btr_attach_half_pages( if (prev_block) { #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(prev_block->frame) == page_is_comp(page)); - ut_a(btr_page_get_next(prev_block->frame, mtr) + ut_a(btr_page_get_next(prev_block->frame) == block->page.id.page_no()); #endif /* UNIV_BTR_DEBUG */ @@ -2534,7 +2534,7 @@ btr_attach_half_pages( if (next_block) { #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(next_block->frame) == page_is_comp(page)); - ut_a(btr_page_get_prev(next_block->frame, mtr) + ut_a(btr_page_get_prev(next_block->frame) == page_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ @@ -2548,7 +2548,7 @@ btr_attach_half_pages( btr_page_set_prev(lower_page, lower_page_zip, prev_page_no, mtr); } else { - ut_ad(btr_page_get_prev(lower_page, mtr) == prev_page_no); + ut_ad(btr_page_get_prev(lower_page) == prev_page_no); } btr_page_set_next(lower_page, lower_page_zip, upper_page_no, mtr); @@ -2559,7 +2559,7 @@ btr_attach_half_pages( btr_page_set_next(upper_page, upper_page_zip, next_page_no, mtr); } else { - ut_ad(btr_page_get_next(upper_page, mtr) == next_page_no); + ut_ad(btr_page_get_next(upper_page) == next_page_no); } } @@ -2620,7 +2620,7 @@ btr_insert_into_right_sibling( { buf_block_t* block = btr_cur_get_block(cursor); page_t* page = buf_block_get_frame(block); - ulint next_page_no = btr_page_get_next(page, mtr); + const uint32_t next_page_no = btr_page_get_next(page); ut_ad(mtr_memo_contains_flagged( mtr, dict_index_get_lock(cursor->index), @@ -3161,8 +3161,8 @@ btr_level_list_remove_func( ut_ad(space == page_get_space_id(page)); /* Get the previous and next page numbers of page */ - const ulint prev_page_no = btr_page_get_prev(page, mtr); - const ulint next_page_no = btr_page_get_next(page, mtr); + const uint32_t prev_page_no = btr_page_get_prev(page); + const uint32_t next_page_no = btr_page_get_next(page); /* Update page links of the level */ @@ -3175,8 +3175,8 @@ btr_level_list_remove_func( = 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)); + ut_a(!memcmp(prev_page + FIL_PAGE_NEXT, page + FIL_PAGE_OFFSET, + 4)); #endif /* UNIV_BTR_DEBUG */ btr_page_set_next(prev_page, @@ -3194,8 +3194,8 @@ btr_level_list_remove_func( = 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)); + ut_a(!memcmp(next_page + FIL_PAGE_PREV, page + FIL_PAGE_OFFSET, + 4)); #endif /* UNIV_BTR_DEBUG */ btr_page_set_prev(next_page, @@ -3527,8 +3527,8 @@ btr_compress( MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS); - left_page_no = btr_page_get_prev(page, mtr); - right_page_no = btr_page_get_next(page, mtr); + left_page_no = btr_page_get_prev(page); + right_page_no = btr_page_get_next(page); #ifdef UNIV_DEBUG if (!page_is_leaf(page) && left_page_no == FIL_NULL) { @@ -3602,10 +3602,10 @@ retry: #ifdef UNIV_BTR_DEBUG if (is_left) { - ut_a(btr_page_get_next(merge_page, mtr) + ut_a(btr_page_get_next(merge_page) == block->page.id.page_no()); } else { - ut_a(btr_page_get_prev(merge_page, mtr) + ut_a(btr_page_get_prev(merge_page) == block->page.id.page_no()); } #endif /* UNIV_BTR_DEBUG */ @@ -4126,8 +4126,8 @@ btr_discard_page( /* Decide the page which will inherit the locks */ - left_page_no = btr_page_get_prev(buf_block_get_frame(block), mtr); - right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr); + left_page_no = btr_page_get_prev(buf_block_get_frame(block)); + right_page_no = btr_page_get_next(buf_block_get_frame(block)); const page_size_t page_size(dict_table_page_size(index->table)); ut_d(bool parent_is_different = false); @@ -4138,7 +4138,7 @@ btr_discard_page( merge_page = buf_block_get_frame(merge_block); #ifdef UNIV_BTR_DEBUG - ut_a(btr_page_get_next(merge_page, mtr) + ut_a(btr_page_get_next(merge_page) == block->page.id.page_no()); #endif /* UNIV_BTR_DEBUG */ ut_d(parent_is_different = @@ -4154,7 +4154,7 @@ btr_discard_page( merge_page = buf_block_get_frame(merge_block); #ifdef UNIV_BTR_DEBUG - ut_a(btr_page_get_prev(merge_page, mtr) + ut_a(btr_page_get_prev(merge_page) == block->page.id.page_no()); #endif /* UNIV_BTR_DEBUG */ ut_d(parent_is_different = page_rec_is_supremum( @@ -4776,7 +4776,7 @@ btr_validate_level( does not use such scan for any of its DML or query operations */ if (dict_index_is_spatial(index)) { - left_page_no = btr_page_get_prev(page, &mtr); + left_page_no = btr_page_get_prev(page); while (left_page_no != FIL_NULL) { page_id_t left_page_id( @@ -4793,7 +4793,7 @@ btr_validate_level( table_page_size, RW_SX_LATCH, index, &mtr); page = buf_block_get_frame(block); - left_page_no = btr_page_get_prev(page, &mtr); + left_page_no = btr_page_get_prev(page); } } } @@ -4848,8 +4848,8 @@ loop: ut_a(btr_page_get_level(page, &mtr) == level); - right_page_no = btr_page_get_next(page, &mtr); - left_page_no = btr_page_get_prev(page, &mtr); + right_page_no = btr_page_get_next(page); + left_page_no = btr_page_get_prev(page); ut_a(!page_is_empty(page) || (level == 0 @@ -4866,9 +4866,7 @@ loop: right_page = buf_block_get_frame(right_block); - if (btr_page_get_prev(right_page, &mtr) - != page_get_page_no(page)) { - + if (btr_page_get_prev(right_page) != page_get_page_no(page)) { btr_validate_report2(index, level, block, right_block); fputs("InnoDB: broken FIL_PAGE_NEXT" " or FIL_PAGE_PREV links\n", stderr); @@ -4949,7 +4947,7 @@ loop: node_ptr = btr_cur_get_rec(&node_cur); parent_page_no = page_get_page_no(father_page); - parent_right_page_no = btr_page_get_next(father_page, &mtr); + parent_right_page_no = btr_page_get_next(father_page); rightmost_child = page_rec_is_supremum( page_rec_get_next(node_ptr)); @@ -5090,7 +5088,7 @@ loop: } if (page_get_page_no(right_father_page) - != btr_page_get_next(father_page, &mtr)) { + != btr_page_get_next(father_page)) { ret = false; fputs("InnoDB: node pointer 3 to" diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 8c9693bea47..39b20fa6cba 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -279,7 +279,7 @@ btr_cur_latch_leaves( dict_index_get_lock(cursor->index), MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK)); /* x-latch also siblings from left to right */ - left_page_no = btr_page_get_prev(page, mtr); + left_page_no = btr_page_get_prev(page); mode = latch_mode; if (left_page_no != FIL_NULL) { @@ -315,10 +315,9 @@ btr_cur_latch_leaves( /* Sanity check only after both the blocks are latched. */ if (latch_leaves.blocks[0] != NULL) { ut_a(page_is_comp(latch_leaves.blocks[0]->frame) - == page_is_comp(page)); - ut_a(btr_page_get_next( - latch_leaves.blocks[0]->frame, mtr) - == page_get_page_no(page)); + == page_is_comp(page)); + ut_a(btr_page_get_next(latch_leaves.blocks[0]->frame) + == page_get_page_no(page)); } ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -328,7 +327,7 @@ btr_cur_latch_leaves( = get_block; } - right_page_no = btr_page_get_next(page, mtr); + right_page_no = btr_page_get_next(page); if (right_page_no != FIL_NULL) { if (spatial) { @@ -344,7 +343,7 @@ btr_cur_latch_leaves( #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); - ut_a(btr_page_get_prev(get_block->frame, mtr) + ut_a(btr_page_get_prev(get_block->frame) == page_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ if (spatial) { @@ -360,7 +359,7 @@ btr_cur_latch_leaves( mode = latch_mode == BTR_SEARCH_PREV ? RW_S_LATCH : RW_X_LATCH; /* latch also left sibling */ rw_lock_s_lock(&block->lock); - left_page_no = btr_page_get_prev(page, mtr); + left_page_no = btr_page_get_prev(page); rw_lock_s_unlock(&block->lock); if (left_page_no != FIL_NULL) { @@ -373,7 +372,7 @@ btr_cur_latch_leaves( #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); - ut_a(btr_page_get_next(get_block->frame, mtr) + ut_a(btr_page_get_next(get_block->frame) == page_get_page_no(page)); #endif /* UNIV_BTR_DEBUG */ } @@ -443,7 +442,7 @@ btr_cur_optimistic_latch_leaves( goto unpin_failed; } left_page_no = btr_page_get_prev( - buf_block_get_frame(block), mtr); + buf_block_get_frame(block)); rw_lock_s_unlock(&block->lock); if (left_page_no != FIL_NULL) { @@ -461,7 +460,7 @@ btr_cur_optimistic_latch_leaves( if (buf_page_optimistic_get(mode, block, modify_clock, file, line, mtr)) { - if (btr_page_get_prev(buf_block_get_frame(block), mtr) + if (btr_page_get_prev(buf_block_get_frame(block)) == left_page_no) { buf_block_buf_fix_dec(block); *latch_mode = mode; @@ -1341,8 +1340,7 @@ retry_page_get: rw_latch = upper_rw_latch; rw_lock_s_lock(&block->lock); - left_page_no = btr_page_get_prev( - buf_block_get_frame(block), mtr); + left_page_no = btr_page_get_prev(buf_block_get_frame(block)); rw_lock_s_unlock(&block->lock); if (left_page_no != FIL_NULL) { @@ -3419,10 +3417,7 @@ btr_cur_pessimistic_insert( } if (!page_rec_is_infimum(btr_cur_get_rec(cursor)) - || btr_page_get_prev( - buf_block_get_frame( - btr_cur_get_block(cursor)), mtr) - == FIL_NULL) { + || !page_has_prev(btr_cur_get_page(cursor))) { /* split and inserted need to call lock_update_insert() always. */ inherit = TRUE; @@ -4212,15 +4207,14 @@ btr_cur_pess_upd_restore_supremum( return; } - const ulint prev_page_no = btr_page_get_prev(page, mtr); + const uint32_t prev_page_no = btr_page_get_prev(page); const page_id_t page_id(block->page.id.space(), prev_page_no); ut_ad(prev_page_no != FIL_NULL); prev_block = buf_page_get_with_no_latch(page_id, block->page.size, mtr); #ifdef UNIV_BTR_DEBUG - ut_a(btr_page_get_next(prev_block->frame, mtr) - == page_get_page_no(page)); + ut_a(btr_page_get_next(prev_block->frame) == block->page.id.page_no()); #endif /* UNIV_BTR_DEBUG */ /* We must already have an x-latch on prev_block! */ @@ -5627,7 +5621,7 @@ btr_estimate_n_rows_in_range_on_level( n_rows += page_get_n_recs(page); } - page_id.set_page_no(btr_page_get_next(page, &mtr)); + page_id.set_page_no(btr_page_get_next(page)); mtr_commit(&mtr); diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index bcabfd3a3bf..4646b3252a7 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -586,7 +586,7 @@ btr_defragment_n_pages( blocks[0] = block; for (uint i = 1; i <= n_pages; i++) { page_t* page = buf_block_get_frame(blocks[i-1]); - ulint page_no = btr_page_get_next(page, mtr); + ulint page_no = btr_page_get_next(page); total_data_size += page_get_data_size(page); total_n_recs += page_get_n_recs(page); if (page_no == FIL_NULL) { diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 11dd60be229..cb5e18457f2 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -420,7 +420,7 @@ btr_pcur_move_to_next_page( return; } - next_page_no = btr_page_get_next(page, mtr); + next_page_no = btr_page_get_next(page); ut_ad(next_page_no != FIL_NULL); @@ -447,7 +447,7 @@ btr_pcur_move_to_next_page( 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) + ut_a(btr_page_get_prev(next_page) == btr_pcur_get_block(cursor)->page.id.page_no()); #endif /* UNIV_BTR_DEBUG */ @@ -509,7 +509,7 @@ btr_pcur_move_backward_from_page( page = btr_pcur_get_page(cursor); - prev_page_no = btr_page_get_prev(page, mtr); + prev_page_no = btr_page_get_prev(page); if (prev_page_no == FIL_NULL) { } else if (btr_pcur_is_before_first_on_page(cursor)) { diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc index bb1e5276a12..955a5bc0800 100644 --- a/storage/innobase/btr/btr0scrub.cc +++ b/storage/innobase/btr/btr0scrub.cc @@ -433,8 +433,8 @@ btr_pessimistic_scrub( /* read block variables */ const ulint page_no = mach_read_from_4(page + FIL_PAGE_OFFSET); const page_id_t page_id(dict_index_get_space(index), page_no); - const ulint left_page_no = btr_page_get_prev(page, mtr); - const ulint right_page_no = btr_page_get_next(page, mtr); + const uint32_t left_page_no = btr_page_get_prev(page); + const uint32_t right_page_no = btr_page_get_next(page); const page_id_t lpage_id(dict_index_get_space(index), left_page_no); const page_id_t rpage_id(dict_index_get_space(index), right_page_no); const page_size_t page_size(dict_table_page_size(index->table)); @@ -468,8 +468,8 @@ btr_pessimistic_scrub( /** * structure should be unchanged */ - ut_a(left_page_no == btr_page_get_prev(page, mtr)); - ut_a(right_page_no == btr_page_get_next(page, mtr)); + ut_a(left_page_no == btr_page_get_prev(page)); + ut_a(right_page_no == btr_page_get_next(page)); } if (right_page_no != FIL_NULL) { diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index b64289b3af6..725190e7fee 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -802,9 +802,7 @@ btr_search_check_guess( prev_rec = page_rec_get_prev(rec); if (page_rec_is_infimum(prev_rec)) { - success = btr_page_get_prev(page_align(prev_rec), mtr) - == FIL_NULL; - + success = !page_has_prev(page_align(prev_rec)); goto exit_func; } @@ -827,9 +825,7 @@ btr_search_check_guess( next_rec = page_rec_get_next(rec); if (page_rec_is_supremum(next_rec)) { - if (btr_page_get_next(page_align(next_rec), mtr) - == FIL_NULL) { - + if (!page_has_next(page_align(next_rec))) { cursor->up_match = 0; success = TRUE; } diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index befa94d263b..dde8f92a54b 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -605,16 +605,10 @@ update_mbr: } } -#ifdef UNIV_DEBUG - ulint left_page_no = btr_page_get_prev(page, mtr); - - if (left_page_no == FIL_NULL) { - - ut_a(REC_INFO_MIN_REC_FLAG & rec_get_info_bits( - page_rec_get_next(page_get_infimum_rec(page)), - page_is_comp(page))); - } -#endif /* UNIV_DEBUG */ + ut_ad(page_has_prev(page) + || (REC_INFO_MIN_REC_FLAG & rec_get_info_bits( + page_rec_get_next(page_get_infimum_rec(page)), + page_is_comp(page)))); mem_heap_free(heap); @@ -649,8 +643,6 @@ rtr_adjust_upper_level( mem_heap_t* heap; ulint level; dtuple_t* node_ptr_upper; - ulint next_page_no; - ulint space; page_cur_t* page_cursor; rtr_mbr_t parent_mbr; lock_prdt_t prdt; @@ -759,19 +751,19 @@ rtr_adjust_upper_level( mem_heap_free(heap); /* Get the previous and next pages of page */ - next_page_no = btr_page_get_next(page, mtr); - space = block->page.id.space(); - const page_size_t& page_size = dict_table_page_size(index->table); + const uint32_t next_page_no = btr_page_get_next(page); if (next_page_no != FIL_NULL) { - page_id_t next_page_id(space, next_page_no); + page_id_t next_page_id(block->page.id.space(), + next_page_no); buf_block_t* next_block = btr_block_get( - next_page_id, page_size, RW_X_LATCH, index, mtr); + next_page_id, dict_table_page_size(index->table), + RW_X_LATCH, index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(next_block->frame) == page_is_comp(page)); - ut_a(btr_page_get_prev(next_block->frame, mtr) - == page_get_page_no(page)); + ut_a(btr_page_get_prev(next_block->frame) + == block->page.id.page_no()); #endif /* UNIV_BTR_DEBUG */ btr_page_set_prev(buf_block_get_frame(next_block), diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 0a0a542689a..84307659873 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -289,7 +289,7 @@ rtr_pcur_getnext_from_path( Note that we have SX lock on index->lock, there should not be any split/shrink happening here */ if (page_ssn > path_ssn) { - ulint next_page_no = btr_page_get_next(page, mtr); + uint32_t next_page_no = btr_page_get_next(page); rtr_non_leaf_stack_push( rtr_info->path, next_page_no, path_ssn, level, 0, NULL, 0); @@ -1407,7 +1407,7 @@ search_again: /* Check the page SSN to see if it has been splitted, if so, search the right page */ if (!ret && page_ssn > path_ssn) { - page_no = btr_page_get_next(page, mtr); + page_no = btr_page_get_next(page); goto search_again; } diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 57ff91fc14e..0377bdfe57f 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2989,7 +2989,7 @@ ibuf_get_volume_buffered( /* Look at the previous page */ - prev_page_no = btr_page_get_prev(page, mtr); + prev_page_no = btr_page_get_prev(page); if (prev_page_no == FIL_NULL) { @@ -3010,7 +3010,7 @@ ibuf_get_volume_buffered( } #ifdef UNIV_BTR_DEBUG - ut_a(btr_page_get_next(prev_page, mtr) == page_get_page_no(page)); + ut_a(!memcmp(prev_page + FIL_PAGE_NEXT, page + FIL_PAGE_OFFSET, 4)); #endif /* UNIV_BTR_DEBUG */ rec = page_get_supremum_rec(prev_page); @@ -3061,7 +3061,7 @@ count_later: /* Look at the next page */ - next_page_no = btr_page_get_next(page, mtr); + next_page_no = btr_page_get_next(page); if (next_page_no == FIL_NULL) { @@ -3082,7 +3082,7 @@ count_later: } #ifdef UNIV_BTR_DEBUG - ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page)); + ut_a(!memcmp(next_page + FIL_PAGE_PREV, page + FIL_PAGE_OFFSET, 4)); #endif /* UNIV_BTR_DEBUG */ rec = page_get_infimum_rec(next_page); diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index ded01e53bad..ee4e522cf49 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -265,26 +265,23 @@ btr_page_get_level_low( const page_t* page) /*!< in: index page */ MY_ATTRIBUTE((warn_unused_result)); #define btr_page_get_level(page, mtr) btr_page_get_level_low(page) -/********************************************************//** -Gets the next index page number. -@return next page number */ -UNIV_INLINE -ulint -btr_page_get_next( -/*==============*/ - const page_t* page, /*!< in: index page */ - mtr_t* mtr) /*!< in: mini-transaction handle */ - MY_ATTRIBUTE((warn_unused_result)); -/********************************************************//** -Gets the previous index page number. -@return prev page number */ -UNIV_INLINE -ulint -btr_page_get_prev( -/*==============*/ - const page_t* page, /*!< in: index page */ - mtr_t* mtr) /*!< in: mini-transaction handle */ - MY_ATTRIBUTE((warn_unused_result)); + +/** Read FIL_PAGE_NEXT. +@param page buffer pool page +@return previous page number */ +inline uint32_t btr_page_get_next(const page_t* page) +{ + return mach_read_from_4(page + FIL_PAGE_NEXT); +} + +/** Read FIL_PAGE_PREV. +@param page buffer pool page +@return previous page number */ +inline uint32_t btr_page_get_prev(const page_t* page) +{ + return mach_read_from_4(page + FIL_PAGE_PREV); +} + /**************************************************************//** Releases the latch on a leaf page and bufferunfixes it. */ UNIV_INLINE diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index a2f2ec885d9..f4fcd9f4194 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -160,23 +160,6 @@ btr_page_set_level( } } -/********************************************************//** -Gets the next index page number. -@return next page number */ -UNIV_INLINE -ulint -btr_page_get_next( -/*==============*/ - const page_t* page, /*!< in: index page */ - mtr_t* mtr MY_ATTRIBUTE((unused))) - /*!< in: mini-transaction handle */ -{ - ut_ad(page != NULL); - ut_ad(mtr != NULL); - - return(mach_read_from_4(page + FIL_PAGE_NEXT)); -} - /********************************************************//** Sets the next index page field. */ UNIV_INLINE @@ -200,22 +183,6 @@ btr_page_set_next( } } -/********************************************************//** -Gets the previous index page number. -@return prev page number */ -UNIV_INLINE -ulint -btr_page_get_prev( -/*==============*/ - const page_t* page, /*!< in: index page */ - mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ -{ - ut_ad(page != NULL); - ut_ad(mtr != NULL); - - return(mach_read_from_4(page + FIL_PAGE_PREV)); -} - /********************************************************//** Sets the previous index page field. */ UNIV_INLINE diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 90c0dd377e1..b4ec3e6dcdf 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -775,7 +775,7 @@ up_rec_match: ulint rec_info = rec_get_info_bits(mid_rec, rec_offs_comp(offsets)); ut_ad(rec_info & REC_INFO_MIN_REC_FLAG); - ut_ad(btr_page_get_prev(page, &mtr) == FIL_NULL); + ut_ad(!page_has_prev(page)); mtr_commit(&mtr); #endif diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index b9f32b16bc5..1e7a6156479 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2011,7 +2011,7 @@ end_of_index: buf_block_t* block; next_page_no = btr_page_get_next( - page_cur_get_page(cur), &mtr); + page_cur_get_page(cur)); if (next_page_no == FIL_NULL) { goto end_of_index; -- cgit v1.2.1 From 3621df70cac09c43a36a0e64faa5222ccb06d2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 13:26:19 +0200 Subject: MDEV-21024: Clean up rtr_adjust_upper_level() Remove the unnecessary retrieval and null-modifications of the preceding page. --- storage/innobase/gis/gis0rtree.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'storage') diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index dde8f92a54b..a9c30ae2a38 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -750,7 +750,6 @@ rtr_adjust_upper_level( mem_heap_free(heap); - /* Get the previous and next pages of page */ const uint32_t next_page_no = btr_page_get_next(page); if (next_page_no != FIL_NULL) { -- cgit v1.2.1 From 98e1d603bfa608094dedf50f7e35f3a4c75ba038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 8 Nov 2019 11:04:26 +0200 Subject: MDEV-21024: Optimize writing BTR_EXTERN_LEN btr_store_big_rec_extern_fields(): Remove the redundant initialization of the most significant 32 bits of BTR_EXTERN_LEN. InnoDB never supported BLOBs that are longer than 4GiB. In fact, dtuple_convert_big_rec() would write emit an error message if a clustered index record tuple would exceed 1,000,000,000 bytes in length. The BTR_EXTERN_LEN in the BLOB pointers in clustered index leaf page records is zero-initialized at least since commit 41bb3537ba507799ab0143acd75ccab72192931e --- storage/innobase/btr/btr0cur.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 39b20fa6cba..51552dcc513 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -7231,8 +7231,8 @@ next_zip_page: extern_len -= store_len; - mlog_write_ulint(field_ref + BTR_EXTERN_LEN, 0, - MLOG_4BYTES, &mtr); + ut_ad(!mach_read_from_4(BTR_EXTERN_LEN + + field_ref)); mlog_write_ulint(field_ref + BTR_EXTERN_LEN + 4, big_rec_vec->fields[i].len -- cgit v1.2.1 From fc2ca2be4e4f1dd2cfa651747420ea9e2772d172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 13:43:24 +0200 Subject: MDEV-21024: Clean up page allocation fsp_alloc_seg_inode_page(): Ever since commit 3926673ce7149aa223103126b6aeac819b10fab5 all newly allocated pages are zero-initialized. Assert that this is the case for the FSEG_ID fields. --- storage/innobase/fsp/fsp0fsp.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'storage') diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index a3715c19916..2297ac861ec 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1681,9 +1681,7 @@ fsp_alloc_seg_inode_page( fsp_header_t* space_header, mtr_t* mtr) { - fseg_inode_t* inode; buf_block_t* block; - page_t* page; ut_ad(page_offset(space_header) == FSP_HEADER_OFFSET); ut_ad(page_get_space_id(page_align(space_header)) == space->id); @@ -1701,22 +1699,20 @@ fsp_alloc_seg_inode_page( buf_block_dbg_add_level(block, SYNC_FSP_PAGE); ut_ad(rw_lock_get_sx_lock_count(&block->lock) == 1); - page = buf_block_get_frame(block); - - mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_INODE, + mlog_write_ulint(block->frame + FIL_PAGE_TYPE, FIL_PAGE_INODE, MLOG_2BYTES, mtr); - for (ulint i = 0; i < FSP_SEG_INODES_PER_PAGE(page_size); i++) { - - inode = fsp_seg_inode_page_get_nth_inode( - page, i, page_size, mtr); - - mlog_write_ull(inode + FSEG_ID, 0, mtr); +#ifdef UNIV_DEBUG + const byte* inode = FSEG_ID + FSEG_ARR_OFFSET + block->frame; + for (ulint i = FSP_SEG_INODES_PER_PAGE(page_size); i--; + inode += FSEG_INODE_SIZE) { + ut_ad(!mach_read_from_8(inode)); } +#endif flst_add_last( space_header + FSP_SEG_INODES_FREE, - page + FSEG_INODE_PAGE_NODE, mtr); + block->frame + FSEG_INODE_PAGE_NODE, mtr); return(true); } -- cgit v1.2.1 From dfdd96214b64d0ad03ff2192a43ae43fb611e2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 13:56:55 +0200 Subject: MDEV-21024: Clean up btr_root_raise_and_insert() The root page must never have any siblings, so it is unnecessary to clear those fields. --- storage/innobase/btr/btr0btr.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'storage') diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 98818dd40c2..a9b84bdb8da 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1985,13 +1985,7 @@ btr_root_raise_and_insert( /* Rebuild the root page to get free space */ btr_page_empty(root_block, root_page_zip, index, level + 1, mtr); - /* Set the next node and previous node fields, although - they should already have been set. The previous node field - must be FIL_NULL if root_page_zip != NULL, because the - REC_INFO_MIN_REC_FLAG (of the first user record) will be - set if and only if !page_has_prev(). */ - btr_page_set_next(root, root_page_zip, FIL_NULL, mtr); - btr_page_set_prev(root, root_page_zip, FIL_NULL, mtr); + ut_ad(!page_has_siblings(root)); page_cursor = btr_cur_get_page_cur(cursor); -- cgit v1.2.1 From 33f74e8fcfbcfa1c817b2cc329ba3ffdcf2253d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 14:02:38 +0200 Subject: MDEV-21024: Clean up IMPORT TABLESPACE page_rec_write_field(): Remove. dict_create_index_tree_step(): If the SYS_INDEXES.PAGE does not change, do not update it in the data dictionary. Typically, all index page numbers would be unchanged before and after IMPORT TABLESPACE, except if some secondary indexes were created after loading some data. btr_root_fseg_adjust_on_import(): Remove the redundant mtr_t* parameter. Redo logging is disabled during the page adjustments that IMPORT TABLESPACE is performing. --- storage/innobase/btr/btr0btr.cc | 26 ++++++++++++-------------- storage/innobase/dict/dict0crea.cc | 13 ++++++++----- storage/innobase/include/page0page.h | 11 ----------- storage/innobase/include/page0page.ic | 21 --------------------- storage/innobase/row/row0trunc.cc | 12 ++++++------ 5 files changed, 26 insertions(+), 57 deletions(-) (limited to 'storage') diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index a9b84bdb8da..bb0b5c82f06 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -321,26 +321,24 @@ btr_root_fseg_adjust_on_import( fseg_header_t* seg_header, /*!< in/out: segment header */ page_zip_des_t* page_zip, /*!< in/out: compressed page, or NULL */ - ulint space, /*!< in: tablespace identifier */ - mtr_t* mtr) /*!< in/out: mini-transaction */ + ulint space) /*!< in: tablespace identifier */ { ulint offset = mach_read_from_2(seg_header + FSEG_HDR_OFFSET); if (offset < FIL_PAGE_DATA - || offset > UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) { + || offset > srv_page_size - FIL_PAGE_DATA_END) { + return false; + } - return(FALSE); + seg_header += FSEG_HDR_SPACE; - } else if (page_zip) { - mach_write_to_4(seg_header + FSEG_HDR_SPACE, space); - page_zip_write_header(page_zip, seg_header + FSEG_HDR_SPACE, - 4, mtr); - } else { - mlog_write_ulint(seg_header + FSEG_HDR_SPACE, - space, MLOG_4BYTES, mtr); + mach_write_to_4(seg_header, space); + if (UNIV_LIKELY_NULL(page_zip)) { + memcpy(page_zip->data + page_offset(seg_header), seg_header, + 4); } - return(TRUE); + return true; } /**************************************************************//** @@ -400,10 +398,10 @@ btr_root_adjust_on_import( if (err == DB_SUCCESS && (!btr_root_fseg_adjust_on_import( FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF - + page, page_zip, space_id, &mtr) + + page, page_zip, space_id) || !btr_root_fseg_adjust_on_import( FIL_PAGE_DATA + PAGE_BTR_SEG_TOP - + page, page_zip, space_id, &mtr))) { + + page, page_zip, space_id))) { err = DB_CORRUPTION; } diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 00268f54677..74c57fdac6f 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -894,11 +894,14 @@ dict_create_index_tree_step( err = DB_OUT_OF_FILE_SPACE; ); } - page_rec_write_field( - btr_pcur_get_rec(&pcur), DICT_FLD__SYS_INDEXES__PAGE_NO, - node->page_no, &mtr); - - btr_pcur_close(&pcur); + ulint len; + byte* data = rec_get_nth_field_old(btr_pcur_get_rec(&pcur), + DICT_FLD__SYS_INDEXES__PAGE_NO, + &len); + ut_ad(len == 4); + if (mach_read_from_4(data) != node->page_no) { + mlog_write_ulint(data, node->page_no, MLOG_4BYTES, &mtr); + } mtr_commit(&mtr); diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index c50e72a6542..2e3bae2d7ff 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -832,17 +832,6 @@ page_rec_find_owner_rec( /*====================*/ rec_t* rec); /*!< in: the physical record */ -/***********************************************************************//** -Write a 32-bit field in a data dictionary record. */ -UNIV_INLINE -void -page_rec_write_field( -/*=================*/ - rec_t* rec, /*!< in/out: record to update */ - ulint i, /*!< in: index of the field to update */ - ulint val, /*!< in: value to write */ - mtr_t* mtr) /*!< in/out: mini-transaction */ - MY_ATTRIBUTE((nonnull)); /************************************************************//** Returns the maximum combined size of records which can be inserted on top of record heap. diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 3956ecce0ee..6c12c43b237 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -919,27 +919,6 @@ page_get_free_space_of_empty( - 2 * PAGE_DIR_SLOT_SIZE)); } -/***********************************************************************//** -Write a 32-bit field in a data dictionary record. */ -UNIV_INLINE -void -page_rec_write_field( -/*=================*/ - rec_t* rec, /*!< in/out: record to update */ - ulint i, /*!< in: index of the field to update */ - ulint val, /*!< in: value to write */ - mtr_t* mtr) /*!< in/out: mini-transaction */ -{ - byte* data; - ulint len; - - data = rec_get_nth_field_old(rec, i, &len); - - ut_ad(len == 4); - - mlog_write_ulint(data, val, MLOG_4BYTES, mtr); -} - /************************************************************//** Each user record on a page, and also the deleted user records in the heap takes its size plus the fraction of the dir cell size / diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc index 09573610e7c..648a83f7dc6 100644 --- a/storage/innobase/row/row0trunc.cc +++ b/storage/innobase/row/row0trunc.cc @@ -1034,12 +1034,12 @@ CreateIndex::operator()(mtr_t* mtr, btr_pcur_t* pcur) const root_page_no = FIL_NULL;); if (root_page_no != FIL_NULL) { - - rec_t* rec = btr_pcur_get_rec(pcur); - - page_rec_write_field( - rec, DICT_FLD__SYS_INDEXES__PAGE_NO, - root_page_no, mtr); + ulint len; + byte* data = rec_get_nth_field_old( + btr_pcur_get_rec(pcur), + DICT_FLD__SYS_INDEXES__PAGE_NO, &len); + ut_ad(len == 4); + mlog_write_ulint(data, root_page_no, MLOG_4BYTES, mtr); /* We will need to commit and restart the mini-transaction in order to avoid deadlocks. -- cgit v1.2.1 From 878bc854d9d47e65a2618dedcc355d5e0a779cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 14:07:01 +0200 Subject: MDEV-21024: Clean up dict_hdr_create() The DICT_HDR_MAX_SPACE_ID was already zero-initialized at page allocation. --- storage/innobase/dict/dict0boot.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'storage') diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index 52c384f118d..58bcaf29f89 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, MariaDB Corporation. +Copyright (c) 2016, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -197,8 +197,7 @@ dict_hdr_create( mlog_write_ull(dict_header + DICT_HDR_INDEX_ID, DICT_HDR_FIRST_ID, mtr); - mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID, - 0, MLOG_4BYTES, mtr); + ut_ad(mach_read_from_4(dict_header + DICT_HDR_MAX_SPACE_ID) == 0); /* Obsolete, but we must initialize it anyway. */ mlog_write_ulint(dict_header + DICT_HDR_MIX_ID_LOW, -- cgit v1.2.1 From 142442d571dd86c630019ece82e36dc73e1e5f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Nov 2019 14:18:50 +0200 Subject: MDEV-21024: Cleanup XDES_CLEAN_BIT The XDES_CLEAN_BIT is always set for every element of the page allocation bitmap in the extent descriptor pages. Do not bother touching it, to avoid redundant writes. --- storage/innobase/fsp/fsp0fsp.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 2297ac861ec..78d562be9a3 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1524,7 +1524,8 @@ fsp_free_page( const ulint bit = offset % FSP_EXTENT_SIZE; xdes_set_bit(descr, XDES_FREE_BIT, bit, TRUE, mtr); - xdes_set_bit(descr, XDES_CLEAN_BIT, bit, TRUE, mtr); + /* xdes_init() should have set all XDES_CLEAN_BIT */ + ut_ad(xdes_get_bit(descr, XDES_CLEAN_BIT, bit)); frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES, mtr); @@ -3085,7 +3086,8 @@ fseg_free_page_low( const ulint bit = offset % FSP_EXTENT_SIZE; xdes_set_bit(descr, XDES_FREE_BIT, bit, TRUE, mtr); - xdes_set_bit(descr, XDES_CLEAN_BIT, bit, TRUE, mtr); + /* xdes_init() should have set all XDES_CLEAN_BIT */ + ut_ad(xdes_get_bit(descr, XDES_CLEAN_BIT, bit)); if (xdes_is_free(descr, mtr)) { /* The extent has become free: free it to space */ -- cgit v1.2.1