Commit 52dad6fd authored by Eugene Kosov's avatar Eugene Kosov

MDEV-21584 Linux aio returned OS error 22

Sometimes blockdev --getss returns 4096.
In that case ROW_FORMAT=COMPRESSED tables might violate
that 4096 bytes alignment.

This patch disables O_DIRECT for COMPRESSED tables.

OS_DATA_FILE_NO_O_DIRECT: new possible value for os_file_create() argument

fil_node_open_file(): do not O_DIRECT
ROW_FORMAT=COMPRESSED tables

AIO::is_linux_native_aio_supported(): minimal alignment in a general case
is 4096 and not 512.
parent 222e1b80
...@@ -605,6 +605,14 @@ static bool fil_node_open_file(fil_node_t* node) ...@@ -605,6 +605,14 @@ static bool fil_node_open_file(fil_node_t* node)
const bool first_time_open = node->size == 0; const bool first_time_open = node->size == 0;
bool o_direct_possible = !FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags);
if (const ulint ssize = FSP_FLAGS_GET_ZIP_SSIZE(space->flags)) {
compile_time_assert(((UNIV_ZIP_SIZE_MIN >> 1) << 3) == 4096);
if (ssize < 3) {
o_direct_possible = false;
}
}
if (first_time_open if (first_time_open
|| (space->purpose == FIL_TYPE_TABLESPACE || (space->purpose == FIL_TYPE_TABLESPACE
&& node == UT_LIST_GET_FIRST(space->chain) && node == UT_LIST_GET_FIRST(space->chain)
...@@ -623,7 +631,12 @@ static bool fil_node_open_file(fil_node_t* node) ...@@ -623,7 +631,12 @@ static bool fil_node_open_file(fil_node_t* node)
node->is_raw_disk node->is_raw_disk
? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT ? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT
: OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT, : OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_AIO, OS_DATA_FILE, read_only_mode, &success); OS_FILE_AIO,
o_direct_possible
? OS_DATA_FILE
: OS_DATA_FILE_NO_O_DIRECT,
read_only_mode,
&success);
if (!success) { if (!success) {
/* The following call prints an error message */ /* The following call prints an error message */
...@@ -654,7 +667,12 @@ static bool fil_node_open_file(fil_node_t* node) ...@@ -654,7 +667,12 @@ static bool fil_node_open_file(fil_node_t* node)
node->is_raw_disk node->is_raw_disk
? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT ? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT
: OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT, : OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_AIO, OS_DATA_FILE, read_only_mode, &success); OS_FILE_AIO,
o_direct_possible
? OS_DATA_FILE
: OS_DATA_FILE_NO_O_DIRECT,
read_only_mode,
&success);
} }
if (space->purpose != FIL_TYPE_LOG) { if (space->purpose != FIL_TYPE_LOG) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2019, MariaDB Corporation. Copyright (c) 2013, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are by Percona Inc.. Those modifications are
...@@ -161,6 +161,7 @@ static const ulint OS_FILE_NORMAL = 62; ...@@ -161,6 +161,7 @@ static const ulint OS_FILE_NORMAL = 62;
static const ulint OS_DATA_FILE = 100; static const ulint OS_DATA_FILE = 100;
static const ulint OS_LOG_FILE = 101; static const ulint OS_LOG_FILE = 101;
static const ulint OS_DATA_TEMP_FILE = 102; static const ulint OS_DATA_TEMP_FILE = 102;
static const ulint OS_DATA_FILE_NO_O_DIRECT = 103;
/* @} */ /* @} */
/** Error codes from os_file_get_last_error @{ */ /** Error codes from os_file_get_last_error @{ */
......
...@@ -2360,8 +2360,8 @@ AIO::is_linux_native_aio_supported() ...@@ -2360,8 +2360,8 @@ AIO::is_linux_native_aio_supported()
io_prep_pwrite(p_iocb, fd, ptr, UNIV_PAGE_SIZE, 0); io_prep_pwrite(p_iocb, fd, ptr, UNIV_PAGE_SIZE, 0);
} else { } else {
ut_a(UNIV_PAGE_SIZE >= 512); ut_a(srv_page_size >= 4096);
io_prep_pread(p_iocb, fd, ptr, 512, 0); io_prep_pread(p_iocb, fd, ptr, srv_page_size, 0);
} }
ut_a(reinterpret_cast<size_t>(p_iocb->u.c.buf) % OS_FILE_LOG_BLOCK_SIZE ut_a(reinterpret_cast<size_t>(p_iocb->u.c.buf) % OS_FILE_LOG_BLOCK_SIZE
...@@ -3007,7 +3007,8 @@ os_file_create_func( ...@@ -3007,7 +3007,8 @@ os_file_create_func(
ut_a(type == OS_LOG_FILE ut_a(type == OS_LOG_FILE
|| type == OS_DATA_FILE || type == OS_DATA_FILE
|| type == OS_DATA_TEMP_FILE); || type == OS_DATA_TEMP_FILE
|| type == OS_DATA_FILE_NO_O_DIRECT);
ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL); ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
...@@ -3054,7 +3055,8 @@ os_file_create_func( ...@@ -3054,7 +3055,8 @@ os_file_create_func(
/* We disable OS caching (O_DIRECT) only on data files */ /* We disable OS caching (O_DIRECT) only on data files */
if (!read_only if (!read_only
&& *success && *success
&& (type != OS_LOG_FILE && type != OS_DATA_TEMP_FILE) && (type != OS_LOG_FILE && type != OS_DATA_TEMP_FILE
&& type != OS_DATA_FILE_NO_O_DIRECT)
&& (srv_file_flush_method == SRV_O_DIRECT && (srv_file_flush_method == SRV_O_DIRECT
|| srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC)) { || srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment