MDEV-21133 follow-up: Use fil_page_get_type()
Let us use the common accessor function fil_page_get_type() instead of accessing the page header field FIL_PAGE_TYPE directly.
This commit is contained in:
parent
ba573c4736
commit
18a62eb76d
@ -467,7 +467,7 @@ is_page_corrupted(
|
|||||||
/* use to store LSN values. */
|
/* use to store LSN values. */
|
||||||
ulint logseq;
|
ulint logseq;
|
||||||
ulint logseqfield;
|
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);
|
uint key_version = buf_page_get_key_version(buf, flags);
|
||||||
ulint space_id = mach_read_from_4(
|
ulint space_id = mach_read_from_4(
|
||||||
buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
||||||
@ -835,7 +835,7 @@ parse_page(
|
|||||||
strcpy(str, "-");
|
strcpy(str, "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mach_read_from_2(page + FIL_PAGE_TYPE)) {
|
switch (fil_page_get_type(page)) {
|
||||||
|
|
||||||
case FIL_PAGE_INDEX: {
|
case FIL_PAGE_INDEX: {
|
||||||
uint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
|
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;
|
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
|
/* FIXME: Page compressed or Page compressed and encrypted
|
||||||
pages do not contain checksum. */
|
pages do not contain checksum. */
|
||||||
|
@ -276,7 +276,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
|
|||||||
byte tmp_frame[UNIV_PAGE_SIZE_MAX];
|
byte tmp_frame[UNIV_PAGE_SIZE_MAX];
|
||||||
byte tmp_page[UNIV_PAGE_SIZE_MAX];
|
byte tmp_page[UNIV_PAGE_SIZE_MAX];
|
||||||
const ulint page_size = cursor->page_size;
|
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.*/
|
/* We ignore the doublewrite buffer pages.*/
|
||||||
if (cursor->space_id == TRX_SYS_SPACE
|
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) {
|
|| page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
|
||||||
ulint decomp = fil_page_decompress(tmp_frame, tmp_page,
|
ulint decomp = fil_page_decompress(tmp_frame, tmp_page,
|
||||||
space->flags);
|
space->flags);
|
||||||
page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE);
|
page_type = fil_page_get_type(tmp_page);
|
||||||
|
|
||||||
return (!decomp
|
return (!decomp
|
||||||
|| (decomp != srv_page_size
|
|| (decomp != srv_page_size
|
||||||
|
@ -794,7 +794,7 @@ buf_page_is_corrupted(
|
|||||||
bool crc32_inited = false;
|
bool crc32_inited = false;
|
||||||
bool crc32_chksum = false;
|
bool crc32_chksum = false;
|
||||||
const ulint zip_size = fil_space_t::zip_size(fsp_flags);
|
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
|
/* We can trust page type if page compression is set on tablespace
|
||||||
flags because page compression flag means file must have been
|
flags because page compression flag means file must have been
|
||||||
@ -3908,8 +3908,7 @@ evict_from_pool:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allow_ibuf_merge
|
if (allow_ibuf_merge
|
||||||
&& mach_read_from_2(fix_block->frame + FIL_PAGE_TYPE)
|
&& fil_page_get_type(fix_block->frame) == FIL_PAGE_INDEX
|
||||||
== FIL_PAGE_INDEX
|
|
||||||
&& page_is_leaf(fix_block->frame)) {
|
&& page_is_leaf(fix_block->frame)) {
|
||||||
rw_lock_x_lock_inline(&fix_block->lock, 0, file, line);
|
rw_lock_x_lock_inline(&fix_block->lock, 0, file, line);
|
||||||
|
|
||||||
|
@ -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(src_frame, 8));
|
||||||
ut_ad(!ut_align_offset(dst_frame, 8));
|
ut_ad(!ut_align_offset(dst_frame, 8));
|
||||||
|
|
||||||
ulint orig_page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE);
|
const bool page_compressed = fil_page_get_type(src_frame)
|
||||||
ibool page_compressed = (orig_page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
|
== FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED;
|
||||||
uint header_len = FIL_PAGE_DATA;
|
uint header_len = FIL_PAGE_DATA;
|
||||||
|
|
||||||
if (page_compressed) {
|
if (page_compressed) {
|
||||||
@ -609,9 +609,9 @@ byte* fil_encrypt_buf(
|
|||||||
@return true if it is valid page type */
|
@return true if it is valid page type */
|
||||||
static bool fil_space_encrypt_valid_page_type(
|
static bool fil_space_encrypt_valid_page_type(
|
||||||
const fil_space_t* space,
|
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:
|
case FIL_PAGE_RTREE:
|
||||||
return space->full_crc32();
|
return space->full_crc32();
|
||||||
case FIL_PAGE_TYPE_FSP_HDR:
|
case FIL_PAGE_TYPE_FSP_HDR:
|
||||||
@ -735,10 +735,9 @@ static bool fil_space_decrypt_for_non_full_checksum(
|
|||||||
byte* src_frame,
|
byte* src_frame,
|
||||||
dberr_t* err)
|
dberr_t* err)
|
||||||
{
|
{
|
||||||
ulint page_type = mach_read_from_2(src_frame+FIL_PAGE_TYPE);
|
|
||||||
uint key_version = mach_read_from_4(
|
uint key_version = mach_read_from_4(
|
||||||
src_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
|
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);
|
== FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
|
||||||
uint offset = mach_read_from_4(src_frame + FIL_PAGE_OFFSET);
|
uint offset = mach_read_from_4(src_frame + FIL_PAGE_OFFSET);
|
||||||
uint space = mach_read_from_4(
|
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
|
/* Compressed and encrypted pages do not have checksum. Assume not
|
||||||
corrupted. Page verification happens after decompression in
|
corrupted. Page verification happens after decompression in
|
||||||
buf_page_io_complete() using buf_page_is_corrupted(). */
|
buf_page_io_complete() using buf_page_is_corrupted(). */
|
||||||
if (mach_read_from_2(page + FIL_PAGE_TYPE)
|
if (fil_page_get_type(page) == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
|
||||||
== FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,10 +581,9 @@ ulint fil_page_decompress_for_non_full_crc32(
|
|||||||
byte* tmp_buf,
|
byte* tmp_buf,
|
||||||
byte* buf)
|
byte* buf)
|
||||||
{
|
{
|
||||||
const unsigned ptype = mach_read_from_2(buf+FIL_PAGE_TYPE);
|
|
||||||
ulint header_len;
|
ulint header_len;
|
||||||
uint comp_algo;
|
uint comp_algo;
|
||||||
switch (ptype) {
|
switch (fil_page_get_type(buf)) {
|
||||||
case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED:
|
case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED:
|
||||||
header_len= FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN;
|
header_len= FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN;
|
||||||
comp_algo = mach_read_from_2(
|
comp_algo = mach_read_from_2(
|
||||||
|
@ -1782,7 +1782,7 @@ fseg_create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ut_ad(rw_lock_get_sx_lock_count(&block->lock) == 1);
|
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,
|
mtr->write<1>(*block, FIL_PAGE_TYPE + 1 + block->frame,
|
||||||
FIL_PAGE_TYPE_SYS);
|
FIL_PAGE_TYPE_SYS);
|
||||||
}
|
}
|
||||||
|
@ -588,8 +588,7 @@ stored in page type.
|
|||||||
@return true if page is compressed. */
|
@return true if page is compressed. */
|
||||||
inline bool buf_page_is_compressed(const byte* read_buf, ulint fsp_flags)
|
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>
|
uint16_t page_type= fil_page_get_type(read_buf);
|
||||||
(read_buf + FIL_PAGE_TYPE));
|
|
||||||
return fil_space_t::full_crc32(fsp_flags)
|
return fil_space_t::full_crc32(fsp_flags)
|
||||||
? !!(page_type & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER)
|
? !!(page_type & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER)
|
||||||
: page_type == FIL_PAGE_PAGE_COMPRESSED;
|
: 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 */
|
@return the payload size in the file page */
|
||||||
inline uint buf_page_full_crc32_size(const byte* buf, bool* comp, bool* cr)
|
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);
|
uint page_size = uint(srv_page_size);
|
||||||
|
|
||||||
if (!(t & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER)) {
|
if (!(t & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER)) {
|
||||||
|
@ -28,6 +28,8 @@ Created 10/25/1995 Heikki Tuuri
|
|||||||
#define fil0fil_h
|
#define fil0fil_h
|
||||||
|
|
||||||
#include "fsp0types.h"
|
#include "fsp0types.h"
|
||||||
|
#include "mach0data.h"
|
||||||
|
#include "assume_aligned.h"
|
||||||
|
|
||||||
#ifndef UNIV_INNOCHECKSUM
|
#ifndef UNIV_INNOCHECKSUM
|
||||||
|
|
||||||
@ -827,6 +829,14 @@ enum fil_encryption_t {
|
|||||||
FIL_ENCRYPTION_OFF
|
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
|
#ifndef UNIV_INNOCHECKSUM
|
||||||
|
|
||||||
/** Number of pending tablespace flushes */
|
/** Number of pending tablespace flushes */
|
||||||
|
@ -86,7 +86,7 @@ fil_page_type_validate(
|
|||||||
fil_space_t* space,
|
fil_space_t* space,
|
||||||
const byte* page)
|
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)
|
if ((page_type & 1U << FIL_PAGE_COMPRESS_FCRC32_MARKER)
|
||||||
&& space->full_crc32()
|
&& space->full_crc32()
|
||||||
|
@ -568,14 +568,6 @@ Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
|
|||||||
ATTRIBUTE_COLD
|
ATTRIBUTE_COLD
|
||||||
void fil_block_reset_type(const buf_block_t& block, ulint type, mtr_t* mtr);
|
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.
|
/** Check (and if needed, reset) the page type.
|
||||||
Data files created before MySQL 5.1.48 may contain
|
Data files created before MySQL 5.1.48 may contain
|
||||||
garbage in the FIL_PAGE_TYPE field.
|
garbage in the FIL_PAGE_TYPE field.
|
||||||
|
@ -370,8 +370,8 @@ page_zip_dir_get(
|
|||||||
@param[in] len length of the data to write */
|
@param[in] len length of the data to write */
|
||||||
inline void mtr_t::zmemcpy(const buf_block_t &b, ulint offset, ulint len)
|
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 ||
|
ut_ad(fil_page_get_type(b.page.zip.data) == FIL_PAGE_INDEX ||
|
||||||
mach_read_from_2(b.page.zip.data + FIL_PAGE_TYPE) == FIL_PAGE_RTREE);
|
fil_page_get_type(b.page.zip.data) == FIL_PAGE_RTREE);
|
||||||
ut_ad(page_zip_simple_validate(&b.page.zip));
|
ut_ad(page_zip_simple_validate(&b.page.zip));
|
||||||
ut_ad(offset + len <= page_zip_get_size(&b.page.zip));
|
ut_ad(offset + len <= page_zip_get_size(&b.page.zip));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user