diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-02-06 19:50:11 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-02-07 12:21:35 +0200 |
commit | 0a1c3477bf359c55be3e11ec6502bc7b5bb87f29 (patch) | |
tree | 2e8ed1a03499e22281dc2c6406d06b63fe7d6f1b /storage/innobase/ibuf | |
parent | 10dac4293f39863552ce2ec8a28629882c92f4d9 (diff) | |
download | mariadb-git-0a1c3477bf359c55be3e11ec6502bc7b5bb87f29.tar.gz |
MDEV-18493 Remove page_size_t
MySQL 5.7 introduced the class page_size_t and increased the size of
buffer pool page descriptors by introducing this object to them.
Maybe the intention of this exercise was to prepare for a future
where the buffer pool could accommodate multiple page sizes.
But that future never arrived, not even in MySQL 8.0. It is much
easier to manage a pool of a single page size, and typically all
storage devices of an InnoDB instance benefit from using the same
page size.
Let us remove page_size_t from MariaDB Server. This will make it
easier to remove support for ROW_FORMAT=COMPRESSED (or make it a
compile-time option) in the future, just by removing various
occurrences of zip_size.
Diffstat (limited to 'storage/innobase/ibuf')
-rw-r--r-- | storage/innobase/ibuf/ibuf0ibuf.cc | 313 |
1 files changed, 150 insertions, 163 deletions
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 1c90e8dd5c8..dd60d5c8096 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, 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 @@ -363,8 +363,7 @@ ibuf_header_page_get( block = buf_page_get( page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO), - univ_page_size, RW_X_LATCH, mtr); - + 0, RW_X_LATCH, mtr); if (!block->page.encrypted) { buf_block_dbg_add_level(block, SYNC_IBUF_HEADER); @@ -395,7 +394,7 @@ ibuf_tree_root_get( /* only segment list access is exclusive each other */ block = buf_page_get( page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO), - univ_page_size, RW_SX_LATCH, mtr); + 0, RW_SX_LATCH, mtr); buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW); @@ -539,7 +538,7 @@ ibuf_init_at_db_start(void) block = buf_page_get( page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO), - univ_page_size, RW_X_LATCH, &mtr); + 0, RW_X_LATCH, &mtr); buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); @@ -602,7 +601,7 @@ ibuf_bitmap_page_init( /* Write all zeros to the bitmap */ compile_time_assert(!(IBUF_BITS_PER_PAGE % 2)); - byte_offset = UT_BITS_IN_BYTES(block->page.size.physical() + byte_offset = UT_BITS_IN_BYTES(block->physical_size() * IBUF_BITS_PER_PAGE); memset(page + IBUF_BITMAP, 0, byte_offset); @@ -636,31 +635,31 @@ ibuf_parse_bitmap_init( /** Gets the desired bits for a given page from a bitmap page. @param[in] page bitmap page @param[in] page_id page id whose bits to get -@param[in] page_size page id whose bits to get +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... @param[in,out] mtr mini-transaction holding an x-latch on the bitmap page @return value of bits */ -# define ibuf_bitmap_page_get_bits(page, page_id, page_size, bit, mtr) \ - ibuf_bitmap_page_get_bits_low(page, page_id, page_size, \ +# define ibuf_bitmap_page_get_bits(page, page_id, zip_size, bit, mtr) \ + ibuf_bitmap_page_get_bits_low(page, page_id, zip_size, \ MTR_MEMO_PAGE_X_FIX, mtr, bit) # else /* UNIV_DEBUG */ /** Gets the desired bits for a given page from a bitmap page. @param[in] page bitmap page @param[in] page_id page id whose bits to get -@param[in] page_size page id whose bits to get +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... @param[in,out] mtr mini-transaction holding an x-latch on the bitmap page @return value of bits */ -# define ibuf_bitmap_page_get_bits(page, page_id, page_size, bit, mtr) \ - ibuf_bitmap_page_get_bits_low(page, page_id, page_size, bit) +# define ibuf_bitmap_page_get_bits(page, page_id, zip_size, bit, mtr) \ + ibuf_bitmap_page_get_bits_low(page, page_id, zip_size, bit) # endif /* UNIV_DEBUG */ /** Gets the desired bits for a given page from a bitmap page. @param[in] page bitmap page @param[in] page_id page id whose bits to get -@param[in] page_size page size +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in] latch_type MTR_MEMO_PAGE_X_FIX, MTR_MEMO_BUF_FIX, ... @param[in,out] mtr mini-transaction holding latch_type on the bitmap page @@ -671,7 +670,7 @@ ulint ibuf_bitmap_page_get_bits_low( const page_t* page, const page_id_t page_id, - const page_size_t& page_size, + ulint zip_size, #ifdef UNIV_DEBUG ulint latch_type, mtr_t* mtr, @@ -682,12 +681,14 @@ ibuf_bitmap_page_get_bits_low( ulint bit_offset; ulint map_byte; ulint value; + const ulint size = zip_size ? zip_size : srv_page_size; + ut_ad(ut_is_2pow(zip_size)); ut_ad(bit < IBUF_BITS_PER_PAGE); compile_time_assert(!(IBUF_BITS_PER_PAGE % 2)); ut_ad(mtr_memo_contains_page(mtr, page, latch_type)); - bit_offset = (page_id.page_no() % page_size.physical()) + bit_offset = (page_id.page_no() & (size - 1)) * IBUF_BITS_PER_PAGE + bit; byte_offset = bit_offset / 8; @@ -711,7 +712,7 @@ ibuf_bitmap_page_get_bits_low( /** Sets the desired bit for a given page in a bitmap page. @param[in,out] page bitmap page @param[in] page_id page id whose bits to set -@param[in] page_size page size +@param[in] physical_size page size @param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... @param[in] val value to set @param[in,out] mtr mtr containing an x-latch to the bitmap page */ @@ -720,7 +721,7 @@ void ibuf_bitmap_page_set_bits( page_t* page, const page_id_t page_id, - const page_size_t& page_size, + ulint physical_size, ulint bit, ulint val, mtr_t* mtr) @@ -738,7 +739,7 @@ ibuf_bitmap_page_set_bits( || (0 == ibuf_count_get(page_id))); #endif - bit_offset = (page_id.page_no() % page_size.physical()) + bit_offset = (page_id.page_no() % physical_size) * IBUF_BITS_PER_PAGE + bit; byte_offset = bit_offset / 8; @@ -765,26 +766,20 @@ ibuf_bitmap_page_set_bits( /** Calculates the bitmap page number for a given page number. @param[in] page_id page id -@param[in] page_size page size +@param[in] size page size @return the bitmap page id where the file page is mapped */ -UNIV_INLINE -const page_id_t -ibuf_bitmap_page_no_calc( - const page_id_t page_id, - const page_size_t& page_size) +inline page_id_t ibuf_bitmap_page_no_calc(const page_id_t page_id, ulint size) { - ulint bitmap_page_no; - - bitmap_page_no = FSP_IBUF_BITMAP_OFFSET - + (page_id.page_no() & ~(page_size.physical() - 1)); + if (!size) size = srv_page_size; - return(page_id_t(page_id.space(), bitmap_page_no)); + return page_id_t(page_id.space(), FSP_IBUF_BITMAP_OFFSET + + (page_id.page_no() & ~(size - 1))); } /** Gets the ibuf bitmap page where the bits describing a given file page are stored. @param[in] page_id page id of the file page -@param[in] page_size page size of the file page +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in] file file name @param[in] line line where called @param[in,out] mtr mini-transaction @@ -795,7 +790,7 @@ static page_t* ibuf_bitmap_get_map_page_func( const page_id_t page_id, - const page_size_t& page_size, + ulint zip_size, const char* file, unsigned line, mtr_t* mtr) @@ -803,8 +798,8 @@ ibuf_bitmap_get_map_page_func( buf_block_t* block = NULL; dberr_t err = DB_SUCCESS; - block = buf_page_get_gen(ibuf_bitmap_page_no_calc(page_id, page_size), - page_size, RW_X_LATCH, NULL, BUF_GET, + block = buf_page_get_gen(ibuf_bitmap_page_no_calc(page_id, zip_size), + zip_size, RW_X_LATCH, NULL, BUF_GET, file, line, mtr, &err); if (err != DB_SUCCESS) { @@ -820,13 +815,13 @@ ibuf_bitmap_get_map_page_func( /** Gets the ibuf bitmap page where the bits describing a given file page are stored. @param[in] page_id page id of the file page -@param[in] page_size page size of the file page +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in,out] mtr mini-transaction @return bitmap page where the file page is mapped, that is, the bitmap page containing the descriptor bits for the file page; the bitmap page is x-latched */ -#define ibuf_bitmap_get_map_page(page_id, page_size, mtr) \ - ibuf_bitmap_get_map_page_func(page_id, page_size, \ +#define ibuf_bitmap_get_map_page(page_id, zip_size, mtr) \ + ibuf_bitmap_get_map_page_func(page_id, zip_size, \ __FILE__, __LINE__, mtr) /************************************************************************//** @@ -860,14 +855,14 @@ ibuf_set_free_bits_low( } bitmap_page = ibuf_bitmap_get_map_page(block->page.id, - block->page.size, mtr); + block->zip_size(), mtr); #ifdef UNIV_IBUF_DEBUG ut_a(val <= ibuf_index_page_calc_free(block)); #endif /* UNIV_IBUF_DEBUG */ ibuf_bitmap_page_set_bits( - bitmap_page, block->page.id, block->page.size, + bitmap_page, block->page.id, block->physical_size(), IBUF_BITMAP_FREE, val, mtr); } @@ -904,7 +899,7 @@ ibuf_set_free_bits_func( block->page.id.space()); bitmap_page = ibuf_bitmap_get_map_page(block->page.id, - block->page.size, &mtr); + block->zip_size(), &mtr); switch (space->purpose) { case FIL_TYPE_LOG: @@ -946,7 +941,7 @@ ibuf_set_free_bits_func( #endif /* UNIV_IBUF_DEBUG */ ibuf_bitmap_page_set_bits( - bitmap_page, block->page.id, block->page.size, + bitmap_page, block->page.id, block->physical_size(), IBUF_BITMAP_FREE, val, &mtr); mtr_commit(&mtr); @@ -996,7 +991,7 @@ ibuf_update_free_bits_low( ut_a(!buf_block_get_page_zip(block)); ut_ad(mtr->is_named_space(block->page.id.space())); - before = ibuf_index_page_calc_free_bits(block->page.size.logical(), + before = ibuf_index_page_calc_free_bits(srv_page_size, max_ins_size); after = ibuf_index_page_calc_free(block); @@ -1031,10 +1026,10 @@ ibuf_update_free_bits_zip( buf_frame_t* frame = buf_block_get_frame(block); ut_a(frame); ut_a(page_is_leaf(frame)); - ut_a(block->page.size.is_compressed()); + ut_a(block->zip_size()); bitmap_page = ibuf_bitmap_get_map_page(block->page.id, - block->page.size, mtr); + block->zip_size(), mtr); after = ibuf_index_page_calc_free_zip(block); @@ -1048,7 +1043,7 @@ ibuf_update_free_bits_zip( } ibuf_bitmap_page_set_bits( - bitmap_page, block->page.id, block->page.size, + bitmap_page, block->page.id, block->physical_size(), IBUF_BITMAP_FREE, after, mtr); } @@ -1090,23 +1085,19 @@ ibuf_update_free_bits_for_two_pages_low( /** Returns TRUE if the page is one of the fixed address ibuf pages. @param[in] page_id page id -@param[in] page_size page size +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @return TRUE if a fixed address ibuf i/o page */ -UNIV_INLINE -ibool -ibuf_fixed_addr_page( - const page_id_t page_id, - const page_size_t& page_size) +inline bool ibuf_fixed_addr_page(const page_id_t page_id, ulint zip_size) { return((page_id.space() == IBUF_SPACE_ID && page_id.page_no() == IBUF_TREE_ROOT_PAGE_NO) - || ibuf_bitmap_page(page_id, page_size)); + || ibuf_bitmap_page(page_id, zip_size)); } /** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. Must not be called when recv_no_ibuf_operations==true. @param[in] page_id page id -@param[in] page_size page size +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in] x_latch FALSE if relaxed check (avoid latching the bitmap page) @param[in] file file name @@ -1115,12 +1106,12 @@ bitmap page) bitmap page if the page is not one of the fixed address ibuf pages, or NULL, in which case a new transaction is created. @return TRUE if level 2 or level 3 page */ -ibool +bool ibuf_page_low( const page_id_t page_id, - const page_size_t& page_size, + ulint zip_size, #ifdef UNIV_DEBUG - ibool x_latch, + bool x_latch, #endif /* UNIV_DEBUG */ const char* file, unsigned line, @@ -1133,12 +1124,10 @@ ibuf_page_low( ut_ad(!recv_no_ibuf_operations); ut_ad(x_latch || mtr == NULL); - if (ibuf_fixed_addr_page(page_id, page_size)) { - - return(TRUE); + if (ibuf_fixed_addr_page(page_id, zip_size)) { + return(true); } else if (page_id.space() != IBUF_SPACE_ID) { - - return(FALSE); + return(false); } compile_time_assert(IBUF_SPACE_ID == 0); @@ -1161,14 +1150,14 @@ ibuf_page_low( dberr_t err = DB_SUCCESS; buf_block_t* block = buf_page_get_gen( - ibuf_bitmap_page_no_calc(page_id, page_size), - page_size, RW_NO_LATCH, NULL, BUF_GET_NO_LATCH, - file, line, &local_mtr, &err); + ibuf_bitmap_page_no_calc(page_id, zip_size), + zip_size, RW_NO_LATCH, NULL, BUF_GET_NO_LATCH, + file, line, &local_mtr, &err); bitmap_page = buf_block_get_frame(block); ret = ibuf_bitmap_page_get_bits_low( - bitmap_page, page_id, page_size, + bitmap_page, page_id, zip_size, MTR_MEMO_BUF_FIX, &local_mtr, IBUF_BITMAP_IBUF); mtr_commit(&local_mtr); @@ -1181,10 +1170,10 @@ ibuf_page_low( mtr_start(mtr); } - bitmap_page = ibuf_bitmap_get_map_page_func(page_id, page_size, + bitmap_page = ibuf_bitmap_get_map_page_func(page_id, zip_size, file, line, mtr); - ret = ibuf_bitmap_page_get_bits(bitmap_page, page_id, page_size, + ret = ibuf_bitmap_page_get_bits(bitmap_page, page_id, zip_size, IBUF_BITMAP_IBUF, mtr); if (mtr == &local_mtr) { @@ -2057,11 +2046,11 @@ ibuf_add_free_page(void) (level 2 page) */ const page_id_t page_id(IBUF_SPACE_ID, block->page.id.page_no()); - bitmap_page = ibuf_bitmap_get_map_page(page_id, univ_page_size, &mtr); + bitmap_page = ibuf_bitmap_get_map_page(page_id, 0, &mtr); mutex_exit(&ibuf_mutex); - ibuf_bitmap_page_set_bits(bitmap_page, page_id, univ_page_size, + ibuf_bitmap_page_set_bits(bitmap_page, page_id, srv_page_size, IBUF_BITMAP_IBUF, TRUE, &mtr); ibuf_mtr_commit(&mtr); @@ -2149,7 +2138,7 @@ ibuf_remove_free_page(void) { buf_block_t* block; - block = buf_page_get(page_id, univ_page_size, RW_X_LATCH, &mtr); + block = buf_page_get(page_id, 0, RW_X_LATCH, &mtr); buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); @@ -2169,13 +2158,13 @@ ibuf_remove_free_page(void) /* Set the bit indicating that this page is no more an ibuf tree page (level 2 page) */ - bitmap_page = ibuf_bitmap_get_map_page(page_id, univ_page_size, &mtr); + bitmap_page = ibuf_bitmap_get_map_page(page_id, 0, &mtr); mutex_exit(&ibuf_mutex); ibuf_bitmap_page_set_bits( - bitmap_page, page_id, univ_page_size, IBUF_BITMAP_IBUF, FALSE, - &mtr); + bitmap_page, page_id, srv_page_size, + IBUF_BITMAP_IBUF, FALSE, &mtr); ut_d(buf_page_set_file_page_was_freed(page_id)); @@ -3025,7 +3014,7 @@ ibuf_get_volume_buffered( block = buf_page_get( page_id_t(IBUF_SPACE_ID, prev_page_no), - univ_page_size, RW_X_LATCH, mtr); + 0, RW_X_LATCH, mtr); buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); @@ -3097,7 +3086,7 @@ count_later: block = buf_page_get( page_id_t(IBUF_SPACE_ID, next_page_no), - univ_page_size, RW_X_LATCH, mtr); + 0, RW_X_LATCH, mtr); buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); @@ -3310,6 +3299,24 @@ ibuf_get_entry_counter_func( } } + +/** Translates the ibuf free bits to the free space on a page in bytes. +@param[in] physical_size page_size +@param[in] bits value for ibuf bitmap bits +@return maximum insert size after reorganize for the page */ +inline ulint +ibuf_index_page_calc_free_from_bits(ulint physical_size, ulint bits) +{ + ut_ad(bits < 4); + ut_ad(physical_size > IBUF_PAGE_SIZE_PER_FREE_SPACE); + + if (bits == 3) { + bits = 4; + } + + return bits * physical_size / IBUF_PAGE_SIZE_PER_FREE_SPACE; +} + /** Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible. @param[in] mode BTR_MODIFY_PREV or BTR_MODIFY_TREE @@ -3321,7 +3328,7 @@ buffering @param[in,out] index index where to insert; must not be unique or clustered @param[in] page_id page id where to insert -@param[in] page_size page size +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in,out] thr query thread @return DB_SUCCESS, DB_STRONG_FAIL or other error */ static MY_ATTRIBUTE((warn_unused_result)) @@ -3334,7 +3341,7 @@ ibuf_insert_low( ulint entry_size, dict_index_t* index, const page_id_t page_id, - const page_size_t& page_size, + ulint zip_size, que_thr_t* thr) { big_rec_t* dummy_big_rec; @@ -3444,6 +3451,8 @@ ibuf_insert_low( ? &min_n_recs : NULL, &mtr); + const ulint physical_size = zip_size ? zip_size : srv_page_size; + if (op == IBUF_OP_DELETE && (min_n_recs < 2 || buf_pool_watch_occurred(page_id))) { /* The page could become empty after the record is @@ -3488,8 +3497,7 @@ fail_exit: ibuf_mtr_start(&bitmap_mtr); index->set_modified(bitmap_mtr); - bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size, - &bitmap_mtr); + bitmap_page = ibuf_bitmap_get_map_page(page_id, zip_size, &bitmap_mtr); /* We check if the index page is suitable for buffered entries */ @@ -3503,11 +3511,12 @@ fail_exit: if (op == IBUF_OP_INSERT) { ulint bits = ibuf_bitmap_page_get_bits( - bitmap_page, page_id, page_size, IBUF_BITMAP_FREE, + bitmap_page, page_id, physical_size, IBUF_BITMAP_FREE, &bitmap_mtr); if (buffered + entry_size + page_dir_calc_reserved_space(1) - > ibuf_index_page_calc_free_from_bits(page_size, bits)) { + > ibuf_index_page_calc_free_from_bits(physical_size, + bits)) { /* Release the bitmap page latch early. */ ibuf_mtr_commit(&bitmap_mtr); @@ -3550,11 +3559,11 @@ fail_exit: buffered entries for this index page, if the bit is not set yet */ old_bit_value = ibuf_bitmap_page_get_bits( - bitmap_page, page_id, page_size, + bitmap_page, page_id, physical_size, IBUF_BITMAP_BUFFERED, &bitmap_mtr); if (!old_bit_value) { - ibuf_bitmap_page_set_bits(bitmap_page, page_id, page_size, + ibuf_bitmap_page_set_bits(bitmap_page, page_id, physical_size, IBUF_BITMAP_BUFFERED, TRUE, &bitmap_mtr); } @@ -3659,23 +3668,23 @@ func_exit: return(err); } -/** Buffer an operation in the insert/delete buffer, instead of doing it -directly to the disk page, if this is possible. Does not do it if the index +/** Buffer an operation in the change buffer, instead of applying it +directly to the file page, if this is possible. Does not do it if the index is clustered or unique. @param[in] op operation type @param[in] entry index entry to insert @param[in,out] index index where to insert @param[in] page_id page id where to insert -@param[in] page_size page size +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in,out] thr query thread -@return TRUE if success */ -ibool +@return true if success */ +bool ibuf_insert( ibuf_op_t op, const dtuple_t* entry, dict_index_t* index, const page_id_t page_id, - const page_size_t& page_size, + ulint zip_size, que_thr_t* thr) { dberr_t err; @@ -3703,7 +3712,7 @@ ibuf_insert( case IBUF_USE_NONE: case IBUF_USE_DELETE: case IBUF_USE_DELETE_MARK: - DBUG_RETURN(FALSE); + DBUG_RETURN(false); case IBUF_USE_INSERT: case IBUF_USE_INSERT_DELETE_MARK: case IBUF_USE_ALL: @@ -3714,7 +3723,7 @@ ibuf_insert( switch (use) { case IBUF_USE_NONE: case IBUF_USE_INSERT: - DBUG_RETURN(FALSE); + DBUG_RETURN(false); case IBUF_USE_DELETE_MARK: case IBUF_USE_DELETE: case IBUF_USE_INSERT_DELETE_MARK: @@ -3728,7 +3737,7 @@ ibuf_insert( case IBUF_USE_NONE: case IBUF_USE_INSERT: case IBUF_USE_INSERT_DELETE_MARK: - DBUG_RETURN(FALSE); + DBUG_RETURN(false); case IBUF_USE_DELETE_MARK: case IBUF_USE_DELETE: case IBUF_USE_ALL: @@ -3768,7 +3777,7 @@ check_watch: is being buffered, have this request executed directly on the page in the buffer pool after the buffered entries for this page have been merged. */ - DBUG_RETURN(FALSE); + DBUG_RETURN(false); } } @@ -3779,30 +3788,22 @@ skip_watch: >= page_get_free_space_of_empty(dict_table_is_comp(index->table)) / 2) { - DBUG_RETURN(FALSE); + DBUG_RETURN(false); } err = ibuf_insert_low(BTR_MODIFY_PREV, op, no_counter, entry, entry_size, - index, page_id, page_size, thr); + index, page_id, zip_size, thr); if (err == DB_FAIL) { err = ibuf_insert_low(BTR_MODIFY_TREE | BTR_LATCH_FOR_INSERT, op, no_counter, entry, entry_size, - index, page_id, page_size, thr); + index, page_id, zip_size, thr); } - if (err == DB_SUCCESS) { -#ifdef UNIV_IBUF_DEBUG - /* fprintf(stderr, "Ibuf insert for page no %lu of index %s\n", - page_no, index->name); */ -#endif - DBUG_RETURN(TRUE); - - } else { - ut_a(err == DB_STRONG_FAIL || err == DB_TOO_BIG_RECORD); + ut_a(err == DB_SUCCESS || err == DB_STRONG_FAIL + || err == DB_TOO_BIG_RECORD); - DBUG_RETURN(FALSE); - } + DBUG_RETURN(err == DB_SUCCESS); } /********************************************************************//** @@ -3866,13 +3867,13 @@ ibuf_insert_to_index_page_low( "InnoDB: that table.\n", stderr); bitmap_page = ibuf_bitmap_get_map_page(block->page.id, - block->page.size, mtr); + block->zip_size(), mtr); old_bits = ibuf_bitmap_page_get_bits( - bitmap_page, block->page.id, block->page.size, + bitmap_page, block->page.id, block->zip_size(), IBUF_BITMAP_FREE, mtr); ib::error() << "page " << block->page.id << ", size " - << block->page.size.physical() << ", bitmap bits " << old_bits; + << block->physical_size() << ", bitmap bits " << old_bits; ib::error() << BUG_REPORT_MSG; @@ -4398,15 +4399,16 @@ subsequently was dropped. @param[in,out] block if page has been read from disk, pointer to the page x-latched, else NULL @param[in] page_id page id of the index page -@param[in] update_ibuf_bitmap normally this is set to TRUE, but +@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 +@param[in] update_ibuf_bitmap normally this is set, but if we have deleted or are deleting the tablespace, then we naturally do not want to update a non-existent bitmap page */ void ibuf_merge_or_delete_for_page( buf_block_t* block, const page_id_t page_id, - const page_size_t* page_size, - ibool update_ibuf_bitmap) + ulint zip_size, + bool update_ibuf_bitmap) { mem_heap_t* heap; btr_pcur_t pcur; @@ -4431,38 +4433,23 @@ ibuf_merge_or_delete_for_page( return; } - /* We cannot refer to page_size in the following, because it is passed - as NULL (it is unknown) when buf_read_ibuf_merge_pages() is merging - (discarding) changes for a dropped tablespace. When block != NULL or - update_ibuf_bitmap is specified, then page_size must be known. - That is why we will repeat the check below, with page_size in - place of univ_page_size. Passing univ_page_size assumes that the - uncompressed page size always is a power-of-2 multiple of the - compressed page size. */ - - if (ibuf_fixed_addr_page(page_id, univ_page_size) - || fsp_descr_page(page_id, univ_page_size)) { + const ulint physical_size = zip_size ? zip_size : srv_page_size; + + if (ibuf_fixed_addr_page(page_id, physical_size) + || fsp_descr_page(page_id, physical_size)) { return; } fil_space_t* space; if (update_ibuf_bitmap) { - - ut_ad(page_size != NULL); - - if (ibuf_fixed_addr_page(page_id, *page_size) - || fsp_descr_page(page_id, *page_size)) { - return; - } - space = fil_space_acquire_silent(page_id.space()); if (UNIV_UNLIKELY(!space)) { /* Do not try to read the bitmap page from the non-existent tablespace, delete the ibuf records */ block = NULL; - update_ibuf_bitmap = FALSE; + update_ibuf_bitmap = false; } else { page_t* bitmap_page = NULL; ulint bitmap_bits = 0; @@ -4470,12 +4457,12 @@ ibuf_merge_or_delete_for_page( ibuf_mtr_start(&mtr); bitmap_page = ibuf_bitmap_get_map_page( - page_id, *page_size, &mtr); + page_id, zip_size, &mtr); if (bitmap_page && fil_page_get_type(bitmap_page) != FIL_PAGE_TYPE_ALLOCATED) { bitmap_bits = ibuf_bitmap_page_get_bits( - bitmap_page, page_id, *page_size, + bitmap_page, page_id, zip_size, IBUF_BITMAP_BUFFERED, &mtr); } @@ -4489,8 +4476,8 @@ ibuf_merge_or_delete_for_page( } } } else if (block != NULL - && (ibuf_fixed_addr_page(page_id, *page_size) - || fsp_descr_page(page_id, *page_size))) { + && (ibuf_fixed_addr_page(page_id, physical_size) + || fsp_descr_page(page_id, physical_size))) { return; } else { @@ -4723,23 +4710,23 @@ reset_bit: if (update_ibuf_bitmap) { page_t* bitmap_page; - bitmap_page = ibuf_bitmap_get_map_page(page_id, *page_size, + bitmap_page = ibuf_bitmap_get_map_page(page_id, zip_size, &mtr); ibuf_bitmap_page_set_bits( - bitmap_page, page_id, *page_size, + bitmap_page, page_id, physical_size, IBUF_BITMAP_BUFFERED, FALSE, &mtr); if (block != NULL) { ulint old_bits = ibuf_bitmap_page_get_bits( - bitmap_page, page_id, *page_size, + bitmap_page, page_id, zip_size, IBUF_BITMAP_FREE, &mtr); ulint new_bits = ibuf_index_page_calc_free(block); if (old_bits != new_bits) { ibuf_bitmap_page_set_bits( - bitmap_page, page_id, *page_size, + bitmap_page, page_id, physical_size, IBUF_BITMAP_FREE, new_bits, &mtr); } } @@ -4922,9 +4909,9 @@ ibuf_print( @param[in] read_buf database page @param[in] size page size @return whether the page is all zeroes */ -static bool buf_page_is_zeroes(const byte* read_buf, const page_size_t& size) +static bool buf_page_is_zeroes(const byte* read_buf, ulint size) { - for (ulint i = 0; i < size.physical(); i++) { + for (ulint i = 0; i < size; i++) { if (read_buf[i] != 0) { return false; } @@ -4941,7 +4928,9 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) ulint page_no; ut_ad(trx->mysql_thd); ut_ad(space->purpose == FIL_TYPE_IMPORT); - const page_size_t page_size(space->flags); + + const ulint zip_size = space->zip_size(); + const ulint physical_size = space->physical_size(); /* fil_space_t::size and fil_space_t::free_limit would still be 0 at this point. So, we will have to read page 0. */ ut_ad(!space->free_limit); @@ -4950,7 +4939,8 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) mtr_t mtr; ulint size; mtr.start(); - if (buf_block_t* sp = buf_page_get(page_id_t(space->id, 0), page_size, + if (buf_block_t* sp = buf_page_get(page_id_t(space->id, 0), + zip_size, RW_S_LATCH, &mtr)) { size = std::min( mach_read_from_4(FSP_HEADER_OFFSET + FSP_FREE_LIMIT @@ -4974,7 +4964,7 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) below page_no is measured in number of pages since the beginning of the space, as usual. */ - for (page_no = 0; page_no < size; page_no += page_size.physical()) { + for (page_no = 0; page_no < size; page_no += physical_size) { page_t* bitmap_page; ulint i; @@ -4990,21 +4980,21 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) ibuf_enter(&mtr); bitmap_page = ibuf_bitmap_get_map_page( - page_id_t(space->id, page_no), page_size, &mtr); + page_id_t(space->id, page_no), zip_size, &mtr); - if (buf_page_is_zeroes(bitmap_page, page_size)) { + if (buf_page_is_zeroes(bitmap_page, physical_size)) { /* This means we got all-zero page instead of ibuf bitmap page. The subsequent page should be all-zero pages. */ #ifdef UNIV_DEBUG for (ulint curr_page = page_no + 1; - curr_page < page_size.physical(); curr_page++) { + curr_page < physical_size; curr_page++) { buf_block_t* block = buf_page_get( page_id_t(space->id, curr_page), - page_size, RW_S_LATCH, &mtr); + zip_size, RW_S_LATCH, &mtr); page_t* page = buf_block_get_frame(block); - ut_ad(buf_page_is_zeroes(page, page_size)); + ut_ad(buf_page_is_zeroes(page, physical_size)); } #endif /* UNIV_DEBUG */ ibuf_exit(&mtr); @@ -5017,17 +5007,13 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) return DB_CORRUPTION; } - for (i = FSP_IBUF_BITMAP_OFFSET + 1; - i < page_size.physical(); - i++) { - + for (i = FSP_IBUF_BITMAP_OFFSET + 1; i < physical_size; i++) { const ulint offset = page_no + i; - const page_id_t cur_page_id(space->id, offset); if (ibuf_bitmap_page_get_bits( - bitmap_page, cur_page_id, page_size, - IBUF_BITMAP_IBUF, &mtr)) { + bitmap_page, cur_page_id, zip_size, + IBUF_BITMAP_IBUF, &mtr)) { mutex_exit(&ibuf_mutex); ibuf_exit(&mtr); @@ -5044,7 +5030,7 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) } if (ibuf_bitmap_page_get_bits( - bitmap_page, cur_page_id, page_size, + bitmap_page, cur_page_id, zip_size, IBUF_BITMAP_BUFFERED, &mtr)) { ib_errf(trx->mysql_thd, @@ -5059,7 +5045,8 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) slightly corrupted tables can be imported and dumped. Clear the bit. */ ibuf_bitmap_page_set_bits( - bitmap_page, cur_page_id, page_size, + bitmap_page, cur_page_id, + physical_size, IBUF_BITMAP_BUFFERED, FALSE, &mtr); } } @@ -5089,18 +5076,18 @@ ibuf_set_bitmap_for_bulk_load( free_val = ibuf_index_page_calc_free(block); mtr_start(&mtr); - mtr.set_named_space_id(block->page.id.space()); + fil_space_t* space = mtr.set_named_space_id(block->page.id.space()); bitmap_page = ibuf_bitmap_get_map_page(block->page.id, - block->page.size, &mtr); + space->zip_size(), &mtr); free_val = reset ? 0 : ibuf_index_page_calc_free(block); ibuf_bitmap_page_set_bits( - bitmap_page, block->page.id, block->page.size, + bitmap_page, block->page.id, block->physical_size(), IBUF_BITMAP_FREE, free_val, &mtr); ibuf_bitmap_page_set_bits( - bitmap_page, block->page.id, block->page.size, + bitmap_page, block->page.id, block->physical_size(), IBUF_BITMAP_BUFFERED, FALSE, &mtr); mtr_commit(&mtr); |