From d2ca6d2e7ff028f6abbab52e36530046b3f84a49 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 8 Jun 2012 14:50:50 +0200 Subject: [PATCH] apply mysql fix for bug#58421 to XtraDB --- mysql-test/mysql-test-run.pl | 14 +---- storage/xtradb/os/os0file.c | 99 +++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 14 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0f9006cad69..2e02ab759ee 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3464,12 +3464,6 @@ sub mysql_install_db { mtr_add_arg($args, "--lc-messages-dir=%s", $install_lang); mtr_add_arg($args, "--character-sets-dir=%s", $install_chsdir); - # On some old linux kernels, aio on tmpfs is not supported - # Remove this if/when Bug #58421 fixes this in the server - if ($^O eq "linux" && $opt_mem) { - mtr_add_arg($args, "--loose-skip-innodb-use-native-aio"); - } - # InnoDB arguments that affect file location and sizes may # need to be given to the bootstrap process as well as the # server process. @@ -4743,6 +4737,7 @@ sub extract_warning_lines ($$) { qr|Access denied for user|, qr|Aborted connection|, qr|table.*is full|, + qr|Linux Native AIO|, # warning that aio does not work on /dev/shm ); my $matched_lines= []; @@ -5246,13 +5241,6 @@ sub mysqld_arguments ($$$) { mtr_add_arg($args, "--user=root"); } - # On some old linux kernels, aio on tmpfs is not supported - # Remove this if/when Bug #58421 fixes this in the server - if ($^O eq "linux" && $opt_mem) - { - mtr_add_arg($args, "--loose-skip-innodb-use-native-aio"); - } - if (!using_extern() and !$opt_user_args) { # Turn on logging to file diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index 0c9b116b932..eefe17df740 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -3318,7 +3318,91 @@ retry: fprintf(stderr, "InnoDB: You can disable Linux Native AIO by" - " setting innodb_native_aio = off in my.cnf\n"); + " setting innodb_use_native_aio = 0 in my.cnf\n"); + return(FALSE); +} + +/******************************************************************//** +Checks if the system supports native linux aio. On some kernel +versions where native aio is supported it won't work on tmpfs. In such +cases we can't use native aio as it is not possible to mix simulated +and native aio. +@return: TRUE if supported, FALSE otherwise. */ +static +ibool +os_aio_native_aio_supported(void) +/*=============================*/ +{ + int fd; + byte* buf; + byte* ptr; + struct io_event io_event; + io_context_t io_ctx; + struct iocb iocb; + struct iocb* p_iocb; + int err; + + if (!os_aio_linux_create_io_ctx(1, &io_ctx)) { + /* The platform does not support native aio. */ + return(FALSE); + } + + /* Now check if tmpdir supports native aio ops. */ + fd = innobase_mysql_tmpfile(); + + if (fd < 0) { + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: unable to create " + "temp file to check native AIO support.\n"); + + return(FALSE); + } + + memset(&io_event, 0x0, sizeof(io_event)); + + buf = (byte*) ut_malloc(UNIV_PAGE_SIZE * 2); + ptr = (byte*) ut_align(buf, UNIV_PAGE_SIZE); + + /* Suppress valgrind warning. */ + memset(buf, 0x00, UNIV_PAGE_SIZE * 2); + + memset(&iocb, 0x0, sizeof(iocb)); + p_iocb = &iocb; + io_prep_pwrite(p_iocb, fd, ptr, UNIV_PAGE_SIZE, 0); + + err = io_submit(io_ctx, 1, &p_iocb); + if (err >= 1) { + /* Now collect the submitted IO request. */ + err = io_getevents(io_ctx, 1, 1, &io_event, NULL); + } + + ut_free(buf); + close(fd); + + switch (err) { + case 1: + return(TRUE); + + case -EINVAL: + case -ENOSYS: + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: Linux Native AIO is not" + " supported on tmpdir.\n" + "InnoDB: You can either move tmpdir to a" + " file system that supports native AIO\n" + "InnoDB: or you can set" + " innodb_use_native_aio to FALSE to avoid" + " this message.\n"); + + /* fall through. */ + default: + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Error: Linux Native AIO check" + " on tmpdir returned error[%d]\n", -err); + } + return(FALSE); } #endif /* LINUX_NATIVE_AIO */ @@ -3458,6 +3542,19 @@ os_aio_init( os_io_init_simple(); +#if defined(LINUX_NATIVE_AIO) + /* Check if native aio is supported on this system and tmpfs */ + if (srv_use_native_aio + && !os_aio_native_aio_supported()) { + + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Warning: Linux Native AIO" + " disabled.\n"); + srv_use_native_aio = FALSE; + } +#endif /* LINUX_NATIVE_AIO */ + for (i = 0; i < n_segments; i++) { srv_set_io_thread_op_info(i, "not started yet"); }