diff options
author | Eugene Kosov <claprix@yandex.ru> | 2020-10-13 03:23:46 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2020-10-14 14:42:54 +0300 |
commit | 52dad6fd264425ef37c5e7ecf0dd904b3f50b7bf (patch) | |
tree | 3dd53b3c397301e5d37d323d9fa77aff106f8a84 /storage | |
parent | 222e1b806ff93083a62f740f6d247f8081983592 (diff) | |
download | mariadb-git-52dad6fd264425ef37c5e7ecf0dd904b3f50b7bf.tar.gz |
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.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 22 | ||||
-rw-r--r-- | storage/innobase/include/os0file.h | 3 | ||||
-rw-r--r-- | storage/innobase/os/os0file.cc | 10 |
3 files changed, 28 insertions, 7 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 384937063eb..328cd104e5d 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -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 @@ retry: 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 @@ retry: 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) { diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index e85bf74201a..82d1551de6c 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -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 @{ */ diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 94552383c48..5c6da7ad51c 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -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)) { |