MDEV-21225 Remove ut_align() and use aligned_malloc()

Before commit 90c52e5291b3ad0935df7da56ec0fcbf530733b4 introduced
aligned_malloc(), InnoDB always used a pattern of over-allocating
memory and invoking ut_align() to guarantee the desired alignment.

It is cleaner to invoke aligned_malloc() and aligned_free() directly.

ut_align(): Remove. In assertions, ut_align_down() can be used instead.
This commit is contained in:
Marko Mäkelä 2019-12-05 06:42:31 +02:00
parent 504202bd7f
commit 42a4ae54c2
21 changed files with 97 additions and 236 deletions

View File

@ -1551,8 +1551,6 @@ int main(
/* our input filename. */
char* filename;
/* Buffer to store pages read. */
byte* buf_ptr = NULL;
byte* xdes_ptr = NULL;
byte* buf = NULL;
byte* xdes = NULL;
/* bytes read count */
@ -1632,10 +1630,10 @@ int main(
}
buf_ptr = (byte*) malloc(UNIV_PAGE_SIZE_MAX * 2);
xdes_ptr = (byte*)malloc(UNIV_PAGE_SIZE_MAX * 2);
buf = (byte *) ut_align(buf_ptr, UNIV_PAGE_SIZE_MAX);
xdes = (byte *) ut_align(xdes_ptr, UNIV_PAGE_SIZE_MAX);
buf = static_cast<byte*>(aligned_malloc(UNIV_PAGE_SIZE_MAX,
UNIV_PAGE_SIZE_MAX));
xdes = static_cast<byte*>(aligned_malloc(UNIV_PAGE_SIZE_MAX,
UNIV_PAGE_SIZE_MAX));
/* The file name is not optional. */
for (int i = 0; i < argc; ++i) {
@ -2014,21 +2012,9 @@ first_non_zero:
fclose(log_file);
}
free(buf_ptr);
free(xdes_ptr);
my_end(exit_status);
DBUG_RETURN(exit_status);
goto common_exit;
my_exit:
if (buf_ptr) {
free(buf_ptr);
}
if (xdes_ptr) {
free(xdes_ptr);
}
if (!read_from_stdin && fil_in) {
fclose(fil_in);
}
@ -2037,6 +2023,9 @@ my_exit:
fclose(log_file);
}
common_exit:
aligned_free(buf);
aligned_free(xdes);
my_end(exit_status);
DBUG_RETURN(exit_status);
}

View File

@ -466,14 +466,13 @@ struct datafile_cur_t {
char abs_path[FN_REFLEN];
MY_STAT statinfo;
uint thread_n;
byte* orig_buf;
byte* buf;
size_t buf_size;
size_t buf_read;
size_t buf_offset;
explicit datafile_cur_t(const char* filename = NULL) :
file(), thread_n(0), orig_buf(NULL), buf(NULL), buf_size(0),
file(), thread_n(0), buf(NULL), buf_size(0),
buf_read(0), buf_offset(0)
{
memset(rel_path, 0, sizeof rel_path);

View File

@ -142,7 +142,7 @@ xb_fil_cur_open(
int err;
/* Initialize these first so xb_fil_cur_close() handles them correctly
in case of error */
cursor->orig_buf = NULL;
cursor->buf = NULL;
cursor->node = NULL;
cursor->space_id = node->space->id;
@ -238,10 +238,8 @@ xb_fil_cur_open(
/* Allocate read buffer */
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 *>
(ut_align(cursor->orig_buf, srv_page_size));
cursor->buf = static_cast<byte*>(aligned_malloc(cursor->buf_size,
srv_page_size));
cursor->buf_read = 0;
cursor->buf_npages = 0;
@ -494,7 +492,8 @@ xb_fil_cur_close(
cursor->read_filter->deinit(&cursor->read_filter_ctxt);
}
free(cursor->orig_buf);
aligned_free(cursor->buf);
cursor->buf = NULL;
if (cursor->node != NULL) {
xb_fil_node_close_file(cursor->node);

View File

@ -44,8 +44,7 @@ struct xb_fil_cur_t {
xb_read_filt_t* read_filter; /*!< read filter */
xb_read_filt_ctxt_t read_filter_ctxt;
/*!< read filter context */
byte* orig_buf; /*!< read buffer */
byte* buf; /*!< aligned pointer for orig_buf */
byte* buf; /*!< read buffer */
size_t buf_size; /*!< buffer size in bytes */
size_t buf_read; /*!< number of read bytes in buffer
after the last cursor read */

View File

@ -3269,8 +3269,6 @@ static dberr_t xb_assign_undo_space_start()
{
pfs_os_file_t file;
byte* buf;
byte* page;
bool ret;
dberr_t error = DB_SUCCESS;
ulint space;
@ -3289,8 +3287,8 @@ static dberr_t xb_assign_undo_space_start()
return DB_ERROR;
}
buf = static_cast<byte*>(ut_malloc_nokey(2U << srv_page_size_shift));
page = static_cast<byte*>(ut_align(buf, srv_page_size));
byte* page = static_cast<byte*>
(aligned_malloc(srv_page_size, srv_page_size));
if (os_file_read(IORequestRead, file, page, 0, srv_page_size)
!= DB_SUCCESS) {
@ -3337,7 +3335,7 @@ retry:
srv_undo_space_id_start = space;
func_exit:
ut_free(buf);
aligned_free(page);
ret = os_file_close(file);
ut_a(ret);
@ -4552,8 +4550,6 @@ xb_space_create_file(
pfs_os_file_t* file) /*!<out: file handle */
{
bool ret;
byte* buf;
byte* page;
*file = os_file_create_simple_no_error_handling(
0, path, OS_FILE_CREATE, OS_FILE_READ_WRITE, false, &ret);
@ -4572,9 +4568,9 @@ xb_space_create_file(
return ret;
}
buf = static_cast<byte *>(malloc(3U << srv_page_size_shift));
/* Align the memory for file i/o if we might have O_DIRECT set */
page = static_cast<byte *>(ut_align(buf, srv_page_size));
byte* page = static_cast<byte*>(aligned_malloc(2 * srv_page_size,
srv_page_size));
memset(page, '\0', srv_page_size);
@ -4608,7 +4604,7 @@ xb_space_create_file(
page_zip.data, 0, zip_size);
}
free(buf);
aligned_free(page);
if (ret != DB_SUCCESS) {
msg("mariabackup: could not write the first page to %s",
@ -4821,8 +4817,7 @@ xtrabackup_apply_delta(
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;
byte* incremental_buffer;
byte* incremental_buffer = NULL;
size_t offset;
@ -4890,11 +4885,8 @@ xtrabackup_apply_delta(
posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
/* allocate buffer for incremental backup (4096 pages) */
incremental_buffer_base = static_cast<byte *>
(malloc((page_size / 4 + 1) * page_size));
incremental_buffer = static_cast<byte *>
(ut_align(incremental_buffer_base,
page_size));
(aligned_malloc(page_size / 4 * page_size, page_size));
msg("Applying %s to %s...", src_path, dst_path);
@ -5003,7 +4995,7 @@ xtrabackup_apply_delta(
incremental_buffers++;
}
free(incremental_buffer_base);
aligned_free(incremental_buffer);
if (src_file != OS_FILE_CLOSED) {
os_file_close(src_file);
os_file_delete(0,src_path);
@ -5013,7 +5005,7 @@ xtrabackup_apply_delta(
return TRUE;
error:
free(incremental_buffer_base);
aligned_free(incremental_buffer);
if (src_file != OS_FILE_CLOSED)
os_file_close(src_file);
if (dst_file != OS_FILE_CLOSED)

View File

@ -1601,8 +1601,11 @@ buf_chunk_init(
opt_large_page_size is smaller than srv_page_size,
we may allocate one fewer block than requested. When
it is bigger, we may allocate more blocks than requested. */
static_assert(sizeof(byte*) == sizeof(ulint), "pointer size");
frame = (byte*) ut_align(chunk->mem, srv_page_size);
frame = reinterpret_cast<byte*>((reinterpret_cast<ulint>(chunk->mem)
+ srv_page_size - 1)
& ~(srv_page_size - 1));
chunk->size = (chunk->mem_pfx.m_size >> srv_page_size_shift)
- (frame != chunk->mem);

View File

@ -126,12 +126,9 @@ static void buf_dblwr_init(const byte *doublewrite)
buf_dblwr->in_use = static_cast<bool*>(
ut_zalloc_nokey(buf_size * sizeof(bool)));
buf_dblwr->write_buf_unaligned = static_cast<byte*>(
ut_malloc_nokey((1 + buf_size) << srv_page_size_shift));
buf_dblwr->write_buf = static_cast<byte*>(
ut_align(buf_dblwr->write_buf_unaligned,
srv_page_size));
aligned_malloc(buf_size << srv_page_size_shift,
srv_page_size));
buf_dblwr->buf_block_arr = static_cast<buf_page_t**>(
ut_zalloc_nokey(buf_size * sizeof(void*)));
@ -355,23 +352,18 @@ buf_dblwr_init_or_load_pages(
ulint space_id;
byte* read_buf;
byte* doublewrite;
byte* unaligned_read_buf;
ibool reset_space_ids = FALSE;
recv_dblwr_t& recv_dblwr = recv_sys.dblwr;
/* We do the file i/o past the buffer pool */
unaligned_read_buf = static_cast<byte*>(
ut_malloc_nokey(3U << srv_page_size_shift));
read_buf = static_cast<byte*>(
ut_align(unaligned_read_buf, srv_page_size));
aligned_malloc(2 * srv_page_size, srv_page_size));
/* Read the trx sys header to check if we are using the doublewrite
buffer */
dberr_t err;
IORequest read_request(IORequest::READ);
IORequest read_request(IORequest::READ);
err = os_file_read(
read_request,
@ -382,9 +374,8 @@ buf_dblwr_init_or_load_pages(
ib::error()
<< "Failed to read the system tablespace header page";
ut_free(unaligned_read_buf);
func_exit:
aligned_free(read_buf);
return(err);
}
@ -403,8 +394,8 @@ buf_dblwr_init_or_load_pages(
buf = buf_dblwr->write_buf;
} else {
ut_free(unaligned_read_buf);
return(DB_SUCCESS);
err = DB_SUCCESS;
goto func_exit;
}
if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED)
@ -432,10 +423,7 @@ buf_dblwr_init_or_load_pages(
ib::error()
<< "Failed to read the first double write buffer "
"extent";
ut_free(unaligned_read_buf);
return(err);
goto func_exit;
}
err = os_file_read(
@ -450,10 +438,7 @@ buf_dblwr_init_or_load_pages(
ib::error()
<< "Failed to read the second double write buffer "
"extent";
ut_free(unaligned_read_buf);
return(err);
goto func_exit;
}
/* Check if any of these pages is half-written in data files, in the
@ -480,10 +465,8 @@ buf_dblwr_init_or_load_pages(
+ i - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE;
}
IORequest write_request(IORequest::WRITE);
err = os_file_write(
write_request, path, file, page,
IORequestWrite, path, file, page,
source_page_no << srv_page_size_shift,
srv_page_size);
if (err != DB_SUCCESS) {
@ -491,10 +474,7 @@ buf_dblwr_init_or_load_pages(
ib::error()
<< "Failed to write to the double write"
" buffer";
ut_free(unaligned_read_buf);
return(err);
goto func_exit;
}
} else if (mach_read_from_8(page + FIL_PAGE_LSN)) {
/* Each valid page header must contain
@ -509,9 +489,8 @@ buf_dblwr_init_or_load_pages(
os_file_flush(file);
}
ut_free(unaligned_read_buf);
return(DB_SUCCESS);
err = DB_SUCCESS;
goto func_exit;
}
/** Process and remove the double write buffer pages for all tablespaces. */
@ -520,18 +499,14 @@ buf_dblwr_process()
{
ulint page_no_dblwr = 0;
byte* read_buf;
byte* unaligned_read_buf;
recv_dblwr_t& recv_dblwr = recv_sys.dblwr;
if (!buf_dblwr) {
return;
}
unaligned_read_buf = static_cast<byte*>(
ut_malloc_nokey(3U << srv_page_size_shift));
read_buf = static_cast<byte*>(
ut_align(unaligned_read_buf, srv_page_size));
aligned_malloc(2 * srv_page_size, srv_page_size));
byte* const buf = read_buf + srv_page_size;
for (recv_dblwr_t::list::iterator i = recv_dblwr.pages.begin();
@ -687,7 +662,7 @@ bad:
recv_dblwr.pages.clear();
fil_flush_file_spaces(FIL_TYPE_TABLESPACE);
ut_free(unaligned_read_buf);
aligned_free(read_buf);
}
/****************************************************************//**
@ -702,15 +677,9 @@ buf_dblwr_free()
os_event_destroy(buf_dblwr->b_event);
os_event_destroy(buf_dblwr->s_event);
ut_free(buf_dblwr->write_buf_unaligned);
buf_dblwr->write_buf_unaligned = NULL;
aligned_free(buf_dblwr->write_buf);
ut_free(buf_dblwr->buf_block_arr);
buf_dblwr->buf_block_arr = NULL;
ut_free(buf_dblwr->in_use);
buf_dblwr->in_use = NULL;
mutex_free(&buf_dblwr->mutex);
ut_free(buf_dblwr);
buf_dblwr = NULL;

View File

@ -1837,12 +1837,10 @@ dberr_t
fil_write_flushed_lsn(
lsn_t lsn)
{
byte* buf1;
byte* buf;
dberr_t err = DB_TABLESPACE_NOT_FOUND;
buf1 = static_cast<byte*>(ut_malloc_nokey(2U << srv_page_size_shift));
buf = static_cast<byte*>(ut_align(buf1, srv_page_size));
buf = static_cast<byte*>(aligned_malloc(srv_page_size, srv_page_size));
const page_id_t page_id(TRX_SYS_SPACE, 0);
@ -1862,7 +1860,7 @@ fil_write_flushed_lsn(
fil_flush_file_spaces(FIL_TYPE_TABLESPACE);
}
ut_free(buf1);
aligned_free(buf);
return(err);
}
@ -2919,7 +2917,6 @@ fil_ibd_create(
dberr_t* err)
{
pfs_os_file_t file;
byte* buf2;
byte* page;
bool success;
bool has_data_dir = FSP_FLAGS_HAS_DATA_DIR(flags) != 0;
@ -2998,9 +2995,9 @@ err_exit:
with zeros from the call of os_file_set_size(), until a buffer pool
flush would write to it. */
buf2 = static_cast<byte*>(ut_malloc_nokey(3U << srv_page_size_shift));
/* Align the memory for file i/o if we might have O_DIRECT set */
page = static_cast<byte*>(ut_align(buf2, srv_page_size));
page = static_cast<byte*>(aligned_malloc(2 * srv_page_size,
srv_page_size));
memset(page, '\0', srv_page_size);
@ -3048,7 +3045,7 @@ err_exit:
IORequestWrite, path, file, page, 0, srv_page_size);
}
ut_free(buf2);
aligned_free(page);
if (*err != DB_SUCCESS) {
ib::error()

View File

@ -291,13 +291,10 @@ Datafile::read_first_page(bool read_only_mode)
}
}
m_first_page_buf = static_cast<byte*>(
ut_malloc_nokey(2 * UNIV_PAGE_SIZE_MAX));
/* Align the memory for a possible read from a raw device */
m_first_page = static_cast<byte*>(
ut_align(m_first_page_buf, srv_page_size));
aligned_malloc(UNIV_PAGE_SIZE_MAX, srv_page_size));
IORequest request;
dberr_t err = DB_ERROR;
@ -379,14 +376,10 @@ Datafile::read_first_page(bool read_only_mode)
}
/** Free the first page from memory when it is no longer needed. */
void
Datafile::free_first_page()
void Datafile::free_first_page()
{
if (m_first_page_buf) {
ut_free(m_first_page_buf);
m_first_page_buf = NULL;
m_first_page = NULL;
}
aligned_free(m_first_page);
m_first_page= nullptr;
}
/** Validates the datafile and checks that it conforms with the expected
@ -514,7 +507,6 @@ Datafile::validate_first_page(lsn_t* flush_lsn)
error_txt = "Cannot read first page";
} else {
ut_ad(m_first_page_buf);
ut_ad(m_first_page);
if (flush_lsn != NULL) {
@ -663,11 +655,8 @@ Datafile::find_space_id()
<< "Page size:" << page_size
<< ". Pages to analyze:" << page_count;
byte* buf = static_cast<byte*>(
ut_malloc_nokey(2 * UNIV_PAGE_SIZE_MAX));
byte* page = static_cast<byte*>(
ut_align(buf, UNIV_SECTOR_SIZE));
aligned_malloc(page_size, page_size));
ulint fsp_flags;
/* provide dummy value if the first os_file_read() fails */
@ -684,19 +673,11 @@ Datafile::find_space_id()
}
for (ulint j = 0; j < page_count; ++j) {
dberr_t err;
ulint n_bytes = j * page_size;
IORequest request(IORequest::READ);
err = os_file_read(
request, m_handle, page, n_bytes, page_size);
if (err != DB_SUCCESS) {
if (dberr_t err = os_file_read(
IORequestRead, m_handle, page,
j * page_size, page_size)) {
ib::info()
<< "READ FAIL: page_no:" << j;
continue;
}
@ -742,7 +723,7 @@ Datafile::find_space_id()
}
}
ut_free(buf);
aligned_free(page);
ib::info()
<< "Page size: " << page_size

View File

@ -687,7 +687,6 @@ inline uint buf_page_full_crc32_size(const byte* buf, bool* comp, bool* cr)
return page_size;
}
#ifndef UNIV_INNOCHECKSUM
# ifdef UNIV_LINUX
# include <stdlib.h>
# endif
@ -716,6 +715,7 @@ inline void aligned_free(void *ptr)
#endif
}
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
Gets the hash value of a block. This can be used in searches in the
lock hash table.

View File

@ -150,8 +150,6 @@ struct buf_dblwr_t{
doublewrite buffer, aligned to an
address divisible by srv_page_size
(which is required by Windows aio) */
byte* write_buf_unaligned;/*!< pointer to write_buf,
but unaligned */
buf_page_t** buf_block_arr;/*!< array to store pointers to
the buffer blocks which have been
cached to write_buf */

View File

@ -61,7 +61,6 @@ public:
m_flags(),
m_exists(),
m_is_valid(),
m_first_page_buf(),
m_first_page(),
m_last_os_error(),
m_file_info()
@ -83,7 +82,6 @@ public:
m_flags(flags),
m_exists(),
m_is_valid(),
m_first_page_buf(),
m_first_page(),
m_last_os_error(),
m_file_info()
@ -103,7 +101,6 @@ public:
m_flags(file.m_flags),
m_exists(file.m_exists),
m_is_valid(file.m_is_valid),
m_first_page_buf(),
m_first_page(),
m_last_os_error(),
m_file_info()
@ -162,7 +159,6 @@ public:
/* Do not make a copy of the first page,
it should be reread if needed */
m_first_page_buf = NULL;
m_first_page = NULL;
return(*this);
@ -459,10 +455,7 @@ private:
/* true if the tablespace is valid */
bool m_is_valid;
/** Buffer to hold first page */
byte* m_first_page_buf;
/** Pointer to the first page held in the buffer above */
/** Aligned buffer to hold first page */
byte* m_first_page;
protected:

View File

@ -80,12 +80,8 @@ struct fts_psort_t {
/*!< sort file */
row_merge_block_t* merge_block[FTS_NUM_AUX_INDEX];
/*!< buffer to write to file */
row_merge_block_t* block_alloc[FTS_NUM_AUX_INDEX];
/*!< buffer to allocated */
row_merge_block_t* crypt_block[FTS_NUM_AUX_INDEX];
/*!< buffer to crypt data */
row_merge_block_t* crypt_alloc[FTS_NUM_AUX_INDEX];
/*!< buffer to allocated */
ulint child_status; /*!< child task status */
ulint state; /*!< parent state */
fts_doc_list_t fts_doc_list; /*!< doc list to process */

View File

@ -633,8 +633,6 @@ typedef void* os_thread_ret_t;
extern ulong srv_page_size_shift;
extern ulong srv_page_size;
static const size_t UNIV_SECTOR_SIZE = 512;
/* Dimension of spatial object we support so far. It has its root in
myisam/sp_defs.h. We only support 2 dimension data */
#define SPDIMS 2

View File

@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 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
@ -62,15 +63,6 @@ ut_uint64_align_up(
ulint align_no); /*!< in: align by this number
which must be a power of 2 */
/*********************************************************//**
The following function rounds up a pointer to the nearest aligned address.
@return aligned pointer */
UNIV_INLINE
void*
ut_align(
/*=====*/
const void* ptr, /*!< in: pointer */
ulint align_no); /*!< in: align by this number */
/*********************************************************//**
The following function rounds down a pointer to the nearest
aligned address.
@return aligned pointer */

View File

@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 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
@ -74,25 +75,6 @@ ut_uint64_align_up(
return((n + align_1) & ~align_1);
}
/*********************************************************//**
The following function rounds up a pointer to the nearest aligned address.
@return aligned pointer */
UNIV_INLINE
void*
ut_align(
/*=====*/
const void* ptr, /*!< in: pointer */
ulint align_no) /*!< in: align by this number */
{
ut_ad(align_no > 0);
ut_ad(((align_no - 1) & align_no) == 0);
ut_ad(ptr);
ut_ad(sizeof(void*) == sizeof(ulint));
return((void*)((((ulint) ptr) + align_no - 1) & ~(align_no - 1)));
}
/*********************************************************//**
The following function rounds down a pointer to the nearest
aligned address.

View File

@ -822,14 +822,14 @@ log_buffer_switch()
if (log_sys.first_in_use) {
log_sys.first_in_use = false;
ut_ad(log_sys.buf == ut_align(log_sys.buf,
OS_FILE_LOG_BLOCK_SIZE));
ut_ad(log_sys.buf == ut_align_down(log_sys.buf,
OS_FILE_LOG_BLOCK_SIZE));
log_sys.buf += srv_log_buffer_size;
} else {
log_sys.first_in_use = true;
log_sys.buf -= srv_log_buffer_size;
ut_ad(log_sys.buf == ut_align(log_sys.buf,
OS_FILE_LOG_BLOCK_SIZE));
ut_ad(log_sys.buf == ut_align_down(log_sys.buf,
OS_FILE_LOG_BLOCK_SIZE));
}
/* Copy the last block to new buf */

View File

@ -3627,12 +3627,8 @@ fallback:
<< srv_page_size_shift;
/* Align the buffer for possible raw i/o */
byte* buf2;
buf2 = static_cast<byte*>(ut_malloc_nokey(buf_size + srv_page_size));
byte* buf = static_cast<byte*>(ut_align(buf2, srv_page_size));
byte* buf = static_cast<byte*>(aligned_malloc(buf_size,
srv_page_size));
/* Write buffer full of zeros */
memset(buf, 0, buf_size);
@ -3661,7 +3657,7 @@ fallback:
current_size += n_bytes;
}
ut_free(buf2);
aligned_free(buf);
return(current_size >= size && os_file_flush(file));
}
@ -3959,13 +3955,13 @@ static bool is_linux_native_aio_supported()
memset(&io_event, 0x0, sizeof(io_event));
byte* buf = static_cast<byte*>(ut_malloc_nokey(srv_page_size * 2));
byte* ptr = static_cast<byte*>(ut_align(buf, srv_page_size));
byte* ptr = static_cast<byte*>(aligned_malloc(srv_page_size,
srv_page_size));
struct iocb iocb;
/* Suppress valgrind warning. */
memset(buf, 0x00, srv_page_size * 2);
memset(ptr, 0, srv_page_size);
memset(&iocb, 0x0, sizeof(iocb));
struct iocb* p_iocb = &iocb;
@ -3988,7 +3984,7 @@ static bool is_linux_native_aio_supported()
err = io_getevents(io_ctx, 1, 1, &io_event, NULL);
}
ut_free(buf);
aligned_free(ptr);
my_close(fd, MYF(MY_WME));
switch (err) {

View File

@ -3285,8 +3285,6 @@ page_zip_validate_low(
TRUE=ignore the MIN_REC_FLAG */
{
page_zip_des_t temp_page_zip;
byte* temp_page_buf;
page_t* temp_page;
ibool valid;
if (memcmp(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV,
@ -3309,9 +3307,8 @@ page_zip_validate_low(
/* page_zip_decompress() expects the uncompressed page to be
srv_page_size aligned. */
temp_page_buf = static_cast<byte*>(
ut_malloc_nokey(2 << srv_page_size_shift));
temp_page = static_cast<byte*>(ut_align(temp_page_buf, srv_page_size));
page_t* temp_page = static_cast<byte*>(aligned_malloc(srv_page_size,
srv_page_size));
UNIV_MEM_ASSERT_RW(page, srv_page_size);
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
@ -3467,7 +3464,7 @@ func_exit:
page_zip_hexdump(page, srv_page_size);
page_zip_hexdump(temp_page, srv_page_size);
}
ut_free(temp_page_buf);
aligned_free(temp_page);
return(valid);
}

View File

@ -252,14 +252,9 @@ row_fts_psort_info_init(
}
/* Need to align memory for O_DIRECT write */
psort_info[j].block_alloc[i] =
static_cast<row_merge_block_t*>(ut_malloc_nokey(
block_size + 1024));
psort_info[j].merge_block[i] =
static_cast<row_merge_block_t*>(
ut_align(
psort_info[j].block_alloc[i], 1024));
aligned_malloc(block_size, 1024));
if (!psort_info[j].merge_block[i]) {
ret = FALSE;
@ -269,23 +264,17 @@ row_fts_psort_info_init(
/* If tablespace is encrypted, allocate additional buffer for
encryption/decryption. */
if (encrypted) {
/* Need to align memory for O_DIRECT write */
psort_info[j].crypt_alloc[i] =
static_cast<row_merge_block_t*>(ut_malloc_nokey(
block_size + 1024));
psort_info[j].crypt_block[i] =
static_cast<row_merge_block_t*>(
ut_align(
psort_info[j].crypt_alloc[i], 1024));
aligned_malloc(block_size,
1024));
if (!psort_info[j].crypt_block[i]) {
ret = FALSE;
goto func_exit;
}
} else {
psort_info[j].crypt_alloc[i] = NULL;
psort_info[j].crypt_block[i] = NULL;
}
}
@ -337,12 +326,9 @@ row_fts_psort_info_destroy(
psort_info[j].merge_file[i]);
}
ut_free(psort_info[j].block_alloc[i]);
aligned_free(psort_info[j].merge_block[i]);
ut_free(psort_info[j].merge_file[i]);
if (psort_info[j].crypt_alloc[i]) {
ut_free(psort_info[j].crypt_alloc[i]);
}
aligned_free(psort_info[j].crypt_block[i]);
}
mutex_free(&psort_info[j].mutex);

View File

@ -3656,11 +3656,10 @@ fil_tablespace_iterate(
/* Allocate a page to read in the tablespace header, so that we
can determine the page size and zip_size (if it is compressed).
We allocate an extra page in case it is a compressed table. One
page is to ensure alignement. */
We allocate an extra page in case it is a compressed table. */
void* page_ptr = ut_malloc_nokey(3U << srv_page_size_shift);
byte* page = static_cast<byte*>(ut_align(page_ptr, srv_page_size));
byte* page = static_cast<byte*>(aligned_malloc(2 * srv_page_size,
srv_page_size));
buf_block_t* block = reinterpret_cast<buf_block_t*>
(ut_zalloc_nokey(sizeof *block));
@ -3712,20 +3711,16 @@ fil_tablespace_iterate(
iter.n_io_buffers = n_io_buffers;
/* Add an extra page for compressed page scratch area. */
void* io_buffer = ut_malloc_nokey(
(2 + iter.n_io_buffers) << srv_page_size_shift);
iter.io_buffer = static_cast<byte*>(
ut_align(io_buffer, srv_page_size));
aligned_malloc((1 + iter.n_io_buffers)
<< srv_page_size_shift, srv_page_size));
void* crypt_io_buffer = NULL;
if (iter.crypt_data) {
crypt_io_buffer = ut_malloc_nokey(
(2 + iter.n_io_buffers)
<< srv_page_size_shift);
iter.crypt_io_buffer = static_cast<byte*>(
ut_align(crypt_io_buffer, srv_page_size));
}
iter.crypt_io_buffer = iter.crypt_data
? static_cast<byte*>(
aligned_malloc((1 + iter.n_io_buffers)
<< srv_page_size_shift,
srv_page_size))
: NULL;
if (block->page.zip.ssize) {
ut_ad(iter.n_io_buffers == 1);
@ -3739,8 +3734,8 @@ fil_tablespace_iterate(
fil_space_destroy_crypt_data(&iter.crypt_data);
}
ut_free(crypt_io_buffer);
ut_free(io_buffer);
aligned_free(iter.crypt_io_buffer);
aligned_free(iter.io_buffer);
}
if (err == DB_SUCCESS) {
@ -3756,7 +3751,7 @@ fil_tablespace_iterate(
os_file_close(file);
ut_free(page_ptr);
aligned_free(page);
ut_free(filepath);
ut_free(block);