diff options
-rw-r--r-- | extra/innochecksum.cc | 6 | ||||
-rw-r--r-- | extra/mariabackup/fil_cur.cc | 4 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 5 | ||||
-rw-r--r-- | storage/innobase/fil/fil0crypt.cc | 14 | ||||
-rw-r--r-- | storage/innobase/fil/fil0pagecompress.cc | 3 | ||||
-rw-r--r-- | storage/innobase/fsp/fsp0fsp.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/buf0buf.h | 5 | ||||
-rw-r--r-- | storage/innobase/include/fil0fil.h | 10 | ||||
-rw-r--r-- | storage/innobase/include/fil0fil.ic | 2 | ||||
-rw-r--r-- | storage/innobase/include/fsp0fsp.h | 8 | ||||
-rw-r--r-- | storage/innobase/page/page0zip.cc | 4 |
11 files changed, 30 insertions, 33 deletions
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 81deba4c390..d8d043d89b9 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -467,7 +467,7 @@ is_page_corrupted( /* use to store LSN values. */ ulint logseq; ulint logseqfield; - ulint page_type = mach_read_from_2(buf+FIL_PAGE_TYPE); + const uint16_t page_type = fil_page_get_type(buf); uint key_version = buf_page_get_key_version(buf, flags); ulint space_id = mach_read_from_4( buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); @@ -835,7 +835,7 @@ parse_page( strcpy(str, "-"); } - switch (mach_read_from_2(page + FIL_PAGE_TYPE)) { + switch (fil_page_get_type(page)) { case FIL_PAGE_INDEX: { uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); @@ -1933,7 +1933,7 @@ first_non_zero: skip_page = false; } - ulint cur_page_type = mach_read_from_2(buf+FIL_PAGE_TYPE); + const uint16_t cur_page_type = fil_page_get_type(buf); /* FIXME: Page compressed or Page compressed and encrypted pages do not contain checksum. */ diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index d1b2275a845..8f06005a9e4 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -276,7 +276,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no, byte tmp_frame[UNIV_PAGE_SIZE_MAX]; byte tmp_page[UNIV_PAGE_SIZE_MAX]; const ulint page_size = cursor->page_size; - ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); + uint16_t page_type = fil_page_get_type(page); /* We ignore the doublewrite buffer pages.*/ if (cursor->space_id == TRX_SYS_SPACE @@ -359,7 +359,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no, || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { ulint decomp = fil_page_decompress(tmp_frame, tmp_page, space->flags); - page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE); + page_type = fil_page_get_type(tmp_page); return (!decomp || (decomp != srv_page_size diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index bc092ef5381..118083db5a8 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -794,7 +794,7 @@ buf_page_is_corrupted( bool crc32_inited = false; bool crc32_chksum = false; const ulint zip_size = fil_space_t::zip_size(fsp_flags); - ulint page_type = mach_read_from_2(read_buf + FIL_PAGE_TYPE); + const uint16_t page_type = fil_page_get_type(read_buf); /* We can trust page type if page compression is set on tablespace flags because page compression flag means file must have been @@ -3908,8 +3908,7 @@ evict_from_pool: } if (allow_ibuf_merge - && mach_read_from_2(fix_block->frame + FIL_PAGE_TYPE) - == FIL_PAGE_INDEX + && fil_page_get_type(fix_block->frame) == FIL_PAGE_INDEX && page_is_leaf(fix_block->frame)) { rw_lock_x_lock_inline(&fix_block->lock, 0, file, line); diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index fa643e88a68..e253b692778 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -455,8 +455,8 @@ static byte* fil_encrypt_buf_for_non_full_checksum( ut_ad(!ut_align_offset(src_frame, 8)); ut_ad(!ut_align_offset(dst_frame, 8)); - ulint orig_page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE); - ibool page_compressed = (orig_page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); + const bool page_compressed = fil_page_get_type(src_frame) + == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED; uint header_len = FIL_PAGE_DATA; if (page_compressed) { @@ -609,9 +609,9 @@ byte* fil_encrypt_buf( @return true if it is valid page type */ static bool fil_space_encrypt_valid_page_type( const fil_space_t* space, - byte* src_frame) + const byte* src_frame) { - switch (mach_read_from_2(src_frame+FIL_PAGE_TYPE)) { + switch (fil_page_get_type(src_frame)) { case FIL_PAGE_RTREE: return space->full_crc32(); case FIL_PAGE_TYPE_FSP_HDR: @@ -735,10 +735,9 @@ static bool fil_space_decrypt_for_non_full_checksum( byte* src_frame, dberr_t* err) { - ulint page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE); uint key_version = mach_read_from_4( src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - bool page_compressed = (page_type + bool page_compressed = (fil_page_get_type(src_frame) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED); uint offset = mach_read_from_4(src_frame + FIL_PAGE_OFFSET); uint space = mach_read_from_4( @@ -2439,8 +2438,7 @@ bool fil_space_verify_crypt_checksum(const byte* page, ulint zip_size) /* Compressed and encrypted pages do not have checksum. Assume not corrupted. Page verification happens after decompression in buf_page_io_complete() using buf_page_is_corrupted(). */ - if (mach_read_from_2(page + FIL_PAGE_TYPE) - == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { + if (fil_page_get_type(page) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { return true; } diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index b800f12d6c7..d3cdacf5125 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -581,10 +581,9 @@ ulint fil_page_decompress_for_non_full_crc32( byte* tmp_buf, byte* buf) { - const unsigned ptype = mach_read_from_2(buf+FIL_PAGE_TYPE); ulint header_len; uint comp_algo; - switch (ptype) { + switch (fil_page_get_type(buf)) { case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED: header_len= FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN; comp_algo = mach_read_from_2( diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 839c5e3250b..ef162abf39a 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1782,7 +1782,7 @@ fseg_create( } ut_ad(rw_lock_get_sx_lock_count(&block->lock) == 1); - ut_ad(!mach_read_from_2(FIL_PAGE_TYPE + block->frame)); + ut_ad(!fil_page_get_type(block->frame)); mtr->write<1>(*block, FIL_PAGE_TYPE + 1 + block->frame, FIL_PAGE_TYPE_SYS); } diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index f0a894e700f..1c75f7a6231 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -588,8 +588,7 @@ stored in page type. @return true if page is compressed. */ inline bool buf_page_is_compressed(const byte* read_buf, ulint fsp_flags) { - uint16_t page_type= mach_read_from_2(my_assume_aligned<2> - (read_buf + FIL_PAGE_TYPE)); + uint16_t page_type= fil_page_get_type(read_buf); return fil_space_t::full_crc32(fsp_flags) ? !!(page_type & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER) : page_type == FIL_PAGE_PAGE_COMPRESSED; @@ -602,7 +601,7 @@ inline bool buf_page_is_compressed(const byte* read_buf, ulint fsp_flags) @return the payload size in the file page */ inline uint buf_page_full_crc32_size(const byte* buf, bool* comp, bool* cr) { - uint t = mach_read_from_2(my_assume_aligned<2>(buf + FIL_PAGE_TYPE)); + uint t = fil_page_get_type(buf); uint page_size = uint(srv_page_size); if (!(t & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER)) { diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index e476a1e75cb..858abaab368 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -28,6 +28,8 @@ Created 10/25/1995 Heikki Tuuri #define fil0fil_h #include "fsp0types.h" +#include "mach0data.h" +#include "assume_aligned.h" #ifndef UNIV_INNOCHECKSUM @@ -827,6 +829,14 @@ enum fil_encryption_t { FIL_ENCRYPTION_OFF }; +/** Get the file page type. +@param[in] page file page +@return page type */ +inline uint16_t fil_page_get_type(const byte *page) +{ + return mach_read_from_2(my_assume_aligned<2>(page + FIL_PAGE_TYPE)); +} + #ifndef UNIV_INNOCHECKSUM /** Number of pending tablespace flushes */ diff --git a/storage/innobase/include/fil0fil.ic b/storage/innobase/include/fil0fil.ic index 24e4157d1f3..fd5f5bc1db9 100644 --- a/storage/innobase/include/fil0fil.ic +++ b/storage/innobase/include/fil0fil.ic @@ -86,7 +86,7 @@ fil_page_type_validate( fil_space_t* space, const byte* page) { - ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); + const uint16_t page_type = fil_page_get_type(page); if ((page_type & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER) && space->full_crc32() diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index 073854b31bd..7a945f3a59e 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -568,14 +568,6 @@ Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE. ATTRIBUTE_COLD void fil_block_reset_type(const buf_block_t& block, ulint type, mtr_t* mtr); -/** Get the file page type. -@param[in] page file page -@return page type */ -inline uint16_t fil_page_get_type(const byte* page) -{ - return mach_read_from_2(my_assume_aligned<2>(page + FIL_PAGE_TYPE)); -} - /** Check (and if needed, reset) the page type. Data files created before MySQL 5.1.48 may contain garbage in the FIL_PAGE_TYPE field. diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 788f63bc9e9..dd34628df08 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -370,8 +370,8 @@ page_zip_dir_get( @param[in] len length of the data to write */ inline void mtr_t::zmemcpy(const buf_block_t &b, ulint offset, ulint len) { - ut_ad(mach_read_from_2(b.page.zip.data + FIL_PAGE_TYPE) == FIL_PAGE_INDEX || - mach_read_from_2(b.page.zip.data + FIL_PAGE_TYPE) == FIL_PAGE_RTREE); + ut_ad(fil_page_get_type(b.page.zip.data) == FIL_PAGE_INDEX || + fil_page_get_type(b.page.zip.data) == FIL_PAGE_RTREE); ut_ad(page_zip_simple_validate(&b.page.zip)); ut_ad(offset + len <= page_zip_get_size(&b.page.zip)); |