Skip to content
Permalink
Browse files
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.
  • Loading branch information
kevgs committed Oct 14, 2020
1 parent 222e1b8 commit 52dad6f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
@@ -605,6 +605,14 @@ static bool fil_node_open_file(fil_node_t* node)

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
|| (space->purpose == FIL_TYPE_TABLESPACE
&& node == UT_LIST_GET_FIRST(space->chain)
@@ -623,7 +631,12 @@ static bool fil_node_open_file(fil_node_t* node)
node->is_raw_disk
? OS_FILE_OPEN_RAW | 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) {
/* The following call prints an error message */
@@ -654,7 +667,12 @@ static bool fil_node_open_file(fil_node_t* node)
node->is_raw_disk
? OS_FILE_OPEN_RAW | 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) {
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
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
by Percona Inc.. Those modifications are
@@ -161,6 +161,7 @@ static const ulint OS_FILE_NORMAL = 62;
static const ulint OS_DATA_FILE = 100;
static const ulint OS_LOG_FILE = 101;
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 @{ */
@@ -2360,8 +2360,8 @@ AIO::is_linux_native_aio_supported()
io_prep_pwrite(p_iocb, fd, ptr, UNIV_PAGE_SIZE, 0);

} else {
ut_a(UNIV_PAGE_SIZE >= 512);
io_prep_pread(p_iocb, fd, ptr, 512, 0);
ut_a(srv_page_size >= 4096);
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
@@ -3007,7 +3007,8 @@ os_file_create_func(

ut_a(type == OS_LOG_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);

@@ -3054,7 +3055,8 @@ os_file_create_func(
/* We disable OS caching (O_DIRECT) only on data files */
if (!read_only
&& *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_NO_FSYNC)) {

0 comments on commit 52dad6f

Please sign in to comment.