Skip to content

Commit 52dad6f

Browse files
committed
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.
1 parent 222e1b8 commit 52dad6f

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,14 @@ static bool fil_node_open_file(fil_node_t* node)
605605

606606
const bool first_time_open = node->size == 0;
607607

608+
bool o_direct_possible = !FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags);
609+
if (const ulint ssize = FSP_FLAGS_GET_ZIP_SSIZE(space->flags)) {
610+
compile_time_assert(((UNIV_ZIP_SIZE_MIN >> 1) << 3) == 4096);
611+
if (ssize < 3) {
612+
o_direct_possible = false;
613+
}
614+
}
615+
608616
if (first_time_open
609617
|| (space->purpose == FIL_TYPE_TABLESPACE
610618
&& node == UT_LIST_GET_FIRST(space->chain)
@@ -623,7 +631,12 @@ static bool fil_node_open_file(fil_node_t* node)
623631
node->is_raw_disk
624632
? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT
625633
: OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
626-
OS_FILE_AIO, OS_DATA_FILE, read_only_mode, &success);
634+
OS_FILE_AIO,
635+
o_direct_possible
636+
? OS_DATA_FILE
637+
: OS_DATA_FILE_NO_O_DIRECT,
638+
read_only_mode,
639+
&success);
627640

628641
if (!success) {
629642
/* The following call prints an error message */
@@ -654,7 +667,12 @@ static bool fil_node_open_file(fil_node_t* node)
654667
node->is_raw_disk
655668
? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT
656669
: OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
657-
OS_FILE_AIO, OS_DATA_FILE, read_only_mode, &success);
670+
OS_FILE_AIO,
671+
o_direct_possible
672+
? OS_DATA_FILE
673+
: OS_DATA_FILE_NO_O_DIRECT,
674+
read_only_mode,
675+
&success);
658676
}
659677

660678
if (space->purpose != FIL_TYPE_LOG) {

storage/innobase/include/os0file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2009, Percona Inc.
5-
Copyright (c) 2013, 2019, MariaDB Corporation.
5+
Copyright (c) 2013, 2020, MariaDB Corporation.
66
77
Portions of this file contain modifications contributed and copyrighted
88
by Percona Inc.. Those modifications are
@@ -161,6 +161,7 @@ static const ulint OS_FILE_NORMAL = 62;
161161
static const ulint OS_DATA_FILE = 100;
162162
static const ulint OS_LOG_FILE = 101;
163163
static const ulint OS_DATA_TEMP_FILE = 102;
164+
static const ulint OS_DATA_FILE_NO_O_DIRECT = 103;
164165
/* @} */
165166

166167
/** Error codes from os_file_get_last_error @{ */

storage/innobase/os/os0file.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,8 +2360,8 @@ AIO::is_linux_native_aio_supported()
23602360
io_prep_pwrite(p_iocb, fd, ptr, UNIV_PAGE_SIZE, 0);
23612361

23622362
} else {
2363-
ut_a(UNIV_PAGE_SIZE >= 512);
2364-
io_prep_pread(p_iocb, fd, ptr, 512, 0);
2363+
ut_a(srv_page_size >= 4096);
2364+
io_prep_pread(p_iocb, fd, ptr, srv_page_size, 0);
23652365
}
23662366

23672367
ut_a(reinterpret_cast<size_t>(p_iocb->u.c.buf) % OS_FILE_LOG_BLOCK_SIZE
@@ -3007,7 +3007,8 @@ os_file_create_func(
30073007

30083008
ut_a(type == OS_LOG_FILE
30093009
|| type == OS_DATA_FILE
3010-
|| type == OS_DATA_TEMP_FILE);
3010+
|| type == OS_DATA_TEMP_FILE
3011+
|| type == OS_DATA_FILE_NO_O_DIRECT);
30113012

30123013
ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
30133014

@@ -3054,7 +3055,8 @@ os_file_create_func(
30543055
/* We disable OS caching (O_DIRECT) only on data files */
30553056
if (!read_only
30563057
&& *success
3057-
&& (type != OS_LOG_FILE && type != OS_DATA_TEMP_FILE)
3058+
&& (type != OS_LOG_FILE && type != OS_DATA_TEMP_FILE
3059+
&& type != OS_DATA_FILE_NO_O_DIRECT)
30583060
&& (srv_file_flush_method == SRV_O_DIRECT
30593061
|| srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC)) {
30603062

0 commit comments

Comments
 (0)