Skip to content

Commit

Permalink
MDEV-18493 Remove page_size_t
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Feb 7, 2019
1 parent 10dac42 commit 0a1c347
Show file tree
Hide file tree
Showing 85 changed files with 1,445 additions and 2,151 deletions.
138 changes: 58 additions & 80 deletions extra/innochecksum.cc

Large diffs are not rendered by default.

32 changes: 15 additions & 17 deletions extra/mariabackup/fil_cur.cc
Expand Up @@ -231,11 +231,11 @@ xb_fil_cur_open(

posix_fadvise(cursor->file, 0, 0, POSIX_FADV_SEQUENTIAL);

const page_size_t page_size(node->space->flags);
cursor->page_size = page_size;
cursor->page_size = node->space->physical_size();
cursor->zip_size = node->space->zip_size();

/* Allocate read buffer */
cursor->buf_size = XB_FIL_CUR_PAGES * page_size.physical();
cursor->buf_size = XB_FIL_CUR_PAGES * cursor->page_size;
cursor->orig_buf = static_cast<byte *>
(malloc(cursor->buf_size + srv_page_size));
cursor->buf = static_cast<byte *>
Expand All @@ -250,18 +250,17 @@ xb_fil_cur_open(
if (!node->space->crypt_data
&& os_file_read(IORequestRead,
node->handle, cursor->buf, 0,
page_size.physical())) {
cursor->page_size)) {
mutex_enter(&fil_system.mutex);
if (!node->space->crypt_data) {
node->space->crypt_data
= fil_space_read_crypt_data(page_size,
cursor->buf);
node->space->crypt_data = fil_space_read_crypt_data(
node->space->zip_size(), cursor->buf);
}
mutex_exit(&fil_system.mutex);
}

cursor->space_size = (ulint)(cursor->statinfo.st_size
/ page_size.physical());
/ cursor->page_size);

cursor->read_filter = read_filter;
cursor->read_filter->init(&cursor->read_filter_ctxt, cursor,
Expand All @@ -276,7 +275,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.physical();
const ulint page_size = cursor->page_size;
ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE);

/* We ignore the doublewrite buffer pages.*/
Expand Down Expand Up @@ -325,7 +324,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
|| (space->crypt_data
&& space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED))) {

if (!fil_space_verify_crypt_checksum(page, cursor->page_size))
if (!fil_space_verify_crypt_checksum(page, space->zip_size()))
return true;

/* Compressed encrypted need to be decrypted
Expand All @@ -345,8 +344,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
}

if (page_type != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
return buf_page_is_corrupted(true, tmp_page,
cursor->page_size, space);
return buf_page_is_corrupted(true, tmp_page, 0, space);
}
}

Expand All @@ -361,14 +359,14 @@ static bool page_is_corrupted(const byte *page, ulint page_no,

return (!decomp
|| (decomp != srv_page_size
&& cursor->page_size.is_compressed())
&& cursor->zip_size)
|| page_type == FIL_PAGE_PAGE_COMPRESSED
|| page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
|| buf_page_is_corrupted(true, tmp_page,
cursor->page_size, space));
space->zip_size(), space));
}

return buf_page_is_corrupted(true, page, cursor->page_size, space);
return buf_page_is_corrupted(true, page, space->zip_size(), space);
}

/************************************************************************
Expand All @@ -389,7 +387,7 @@ xb_fil_cur_read(
xb_fil_cur_result_t ret;
ib_int64_t offset;
ib_int64_t to_read;
const ulint page_size = cursor->page_size.physical();
const ulint page_size = cursor->page_size;
xb_ad(!cursor->is_system() || page_size == srv_page_size);

cursor->read_filter->get_next_batch(&cursor->read_filter_ctxt,
Expand Down Expand Up @@ -459,7 +457,7 @@ xb_fil_cur_read(
"10 retries. File %s seems to be "
"corrupted.", cursor->abs_path);
ret = XB_FIL_CUR_ERROR;
buf_page_print(page, cursor->page_size);
ut_print_buf(stderr, page, page_size);
break;
}
msg(cursor->thread_n, "Database page corruption detected at page "
Expand Down
7 changes: 3 additions & 4 deletions extra/mariabackup/fil_cur.h
Expand Up @@ -38,7 +38,9 @@ struct xb_fil_cur_t {
char abs_path[FN_REFLEN];
/*!< absolute file path */
MY_STAT statinfo; /*!< information about the file */
page_size_t page_size; /*!< page size */
ulint zip_size; /*!< compressed page size in bytes or 0
for uncompressed pages */
ulint page_size; /*!< physical page size */
xb_read_filt_t* read_filter; /*!< read filter */
xb_read_filt_ctxt_t read_filter_ctxt;
/*!< read filter context */
Expand All @@ -57,9 +59,6 @@ struct xb_fil_cur_t {
ulint space_id; /*!< ID of tablespace */
ulint space_size; /*!< space size in pages */

/** TODO: remove this default constructor */
xb_fil_cur_t() : page_size(0), read_filter(0), read_filter_ctxt() {}

/** @return whether this is not a file-per-table tablespace */
bool is_system() const
{
Expand Down
2 changes: 1 addition & 1 deletion extra/mariabackup/read_filt.cc
Expand Up @@ -127,7 +127,7 @@ rf_bitmap_get_next_batch(
of pages */
{
ulint start_page_id;
const ulint page_size = ctxt->page_size.physical();
const ulint page_size = ctxt->page_size;

start_page_id = (ulint)(ctxt->offset / page_size);

Expand Down
2 changes: 1 addition & 1 deletion extra/mariabackup/read_filt.h
Expand Up @@ -41,7 +41,7 @@ struct xb_read_filt_ctxt_t {
/* Move these to union if any other filters are added in future */
xb_page_bitmap_range *bitmap_range; /*!< changed page bitmap range
iterator for space_id */
page_size_t page_size; /*!< page size */
ulint page_size; /*!< page size */
ulint filter_batch_end;/*!< the ending page id of the
current changed page block in
the bitmap */
Expand Down
12 changes: 5 additions & 7 deletions extra/mariabackup/write_filt.cc
Expand Up @@ -75,8 +75,7 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
ctxt->cursor = cursor;

/* allocate buffer for incremental backup (4096 pages) */
cp->delta_buf_size = (cursor->page_size.physical() / 4)
* cursor->page_size.physical();
cp->delta_buf_size = (cursor->page_size / 4) * cursor->page_size;
cp->delta_buf = (unsigned char *)os_mem_alloc_large(&cp->delta_buf_size);

if (!cp->delta_buf) {
Expand All @@ -88,7 +87,8 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
/* write delta meta info */
snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,
XB_DELTA_INFO_SUFFIX);
const xb_delta_info_t info(cursor->page_size, cursor->space_id);
const xb_delta_info_t info(cursor->page_size, cursor->zip_size,
cursor->space_id);
if (!xb_write_delta_metadata(meta_name, &info)) {
msg(cursor->thread_n,"Error: "
"failed to write meta info for %s",
Expand Down Expand Up @@ -116,8 +116,7 @@ wf_incremental_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
ulint i;
xb_fil_cur_t *cursor = ctxt->cursor;
byte *page;
const ulint page_size
= cursor->page_size.physical();
const ulint page_size = cursor->page_size;
xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt);

for (i = 0, page = cursor->buf; i < cursor->buf_npages;
Expand Down Expand Up @@ -162,8 +161,7 @@ static my_bool
wf_incremental_finalize(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
{
xb_fil_cur_t *cursor = ctxt->cursor;
const ulint page_size
= cursor->page_size.physical();
const ulint page_size = cursor->page_size;
xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt);

if (cp->npages != page_size / 4) {
Expand Down
37 changes: 15 additions & 22 deletions extra/mariabackup/xtrabackup.cc
Expand Up @@ -1861,11 +1861,6 @@ static bool innodb_init_param()
msg("innodb_data_file_path = %s",
innobase_data_file_path);

/* This is the first time univ_page_size is used.
It was initialized to 16k pages before srv_page_size was set */
univ_page_size.copy_from(
page_size_t(srv_page_size, srv_page_size, false));

srv_sys_space.set_space_id(TRX_SYS_SPACE);
srv_sys_space.set_name("innodb_system");
srv_sys_space.set_path(srv_data_home);
Expand Down Expand Up @@ -2173,8 +2168,7 @@ xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
msg("page_size is required in %s", filepath);
r = FALSE;
} else {
info->page_size = page_size_t(zip_size ? zip_size : page_size,
page_size, zip_size != 0);
info->page_size = zip_size ? zip_size : page_size;
}

if (info->space_id == ULINT_UNDEFINED) {
Expand Down Expand Up @@ -2202,9 +2196,8 @@ xb_write_delta_metadata(const char *filename, const xb_delta_info_t *info)
"page_size = " ULINTPF "\n"
"zip_size = " ULINTPF " \n"
"space_id = " ULINTPF "\n",
info->page_size.logical(),
info->page_size.is_compressed()
? info->page_size.physical() : 0,
info->page_size,
info->zip_size,
info->space_id);
len = strlen(buf);

Expand Down Expand Up @@ -3107,7 +3100,7 @@ xb_load_single_table_tablespace(

ut_a(node_size != (os_offset_t) -1);

n_pages = node_size / page_size_t(file->flags()).physical();
n_pages = node_size / fil_space_t::physical_size(file->flags());

space = fil_space_create(
name, file->space_id(), file->flags(),
Expand Down Expand Up @@ -3312,7 +3305,7 @@ static dberr_t xb_assign_undo_space_start()
}

/* TRX_SYS page can't be compressed or encrypted. */
if (buf_page_is_corrupted(false, page, univ_page_size)) {
if (buf_page_is_corrupted(false, page, 0)) {
if (n_retries--) {
os_thread_sleep(1000);
goto retry;
Expand Down Expand Up @@ -4590,16 +4583,15 @@ xb_space_create_file(
fsp_header_init_fields(page, space_id, flags);
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);

const page_size_t page_size(flags);
const ulint zip_size = fil_space_t::zip_size(flags);

if (!page_size.is_compressed()) {
if (!zip_size) {
buf_flush_init_for_writing(NULL, page, NULL, 0);

ret = os_file_write(IORequestWrite, path, *file, page, 0,
srv_page_size);
} else {
page_zip_des_t page_zip;
ulint zip_size = page_size.physical();
page_zip_set_size(&page_zip, zip_size);
page_zip.data = page + srv_page_size;
fprintf(stderr, "zip_size = " ULINTPF "\n", zip_size);
Expand Down Expand Up @@ -4776,19 +4768,20 @@ xb_delta_open_matching_space(
}

/* No matching space found. create the new one. */
const ulint flags = info.page_size.is_compressed()
? get_bit_shift(info.page_size.physical()
const ulint flags = info.zip_size
? get_bit_shift(info.page_size
>> (UNIV_ZIP_SIZE_SHIFT_MIN - 1))
<< FSP_FLAGS_POS_ZIP_SSIZE
| FSP_FLAGS_MASK_POST_ANTELOPE
| FSP_FLAGS_MASK_ATOMIC_BLOBS
| (info.page_size.logical() == UNIV_PAGE_SIZE_ORIG
| (srv_page_size == UNIV_PAGE_SIZE_ORIG
? 0
: get_bit_shift(info.page_size.logical()
: get_bit_shift(srv_page_size
>> (UNIV_ZIP_SIZE_SHIFT_MIN - 1))
<< FSP_FLAGS_POS_PAGE_SSIZE)
: FSP_FLAGS_PAGE_SSIZE();
ut_ad(page_size_t(flags).equals_to(info.page_size));
ut_ad(fil_space_t::zip_size(flags) == info.zip_size);
ut_ad(fil_space_t::physical_size(flags) == info.page_size);

if (fil_space_create(dest_space_name, info.space_id, flags,
FIL_TYPE_TABLESPACE, 0)) {
Expand Down Expand Up @@ -4825,7 +4818,7 @@ xtrabackup_apply_delta(
ulint page_in_buffer;
ulint incremental_buffers = 0;

xb_delta_info_t info(univ_page_size, SRV_TMP_SPACE_ID);
xb_delta_info_t info(srv_page_size, 0, SRV_TMP_SPACE_ID);
ulint page_size;
ulint page_size_shift;
byte* incremental_buffer_base = NULL;
Expand Down Expand Up @@ -4863,7 +4856,7 @@ xtrabackup_apply_delta(
goto error;
}

page_size = info.page_size.physical();
page_size = info.page_size;
page_size_shift = get_bit_shift(page_size);
msg("page size for %s is %zu bytes",
src_path, page_size);
Expand Down
9 changes: 5 additions & 4 deletions extra/mariabackup/xtrabackup.h
Expand Up @@ -28,11 +28,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

struct xb_delta_info_t
{
xb_delta_info_t(page_size_t page_size, ulint space_id)
: page_size(page_size), space_id(space_id) {}
xb_delta_info_t(ulint page_size, ulint zip_size, ulint space_id)
: page_size(page_size), zip_size(zip_size), space_id(space_id) {}

page_size_t page_size;
ulint space_id;
ulint page_size;
ulint zip_size;
ulint space_id;
};

/* value of the --incremental option */
Expand Down

0 comments on commit 0a1c347

Please sign in to comment.