summaryrefslogtreecommitdiff
path: root/storage/xtradb/os
diff options
context:
space:
mode:
authorSeppo Jaakola <seppo.jaakola@codership.com>2012-08-09 01:47:21 +0300
committerSeppo Jaakola <seppo.jaakola@codership.com>2012-08-09 01:47:21 +0300
commitebfa24b1d24377a241b79883da96969a9150f22c (patch)
treeef1198f9dfb1838cbdbc5056f2b84e399b446bfd /storage/xtradb/os
parent1fd2e10736d6fd198e62054cb9006a3dc13fd55e (diff)
parenta7123f507598690ef0fce68b5d8dc58e63635024 (diff)
downloadmariadb-git-ebfa24b1d24377a241b79883da96969a9150f22c.tar.gz
References lp:1034621 - Merge up to mysql-5.5.25 level
merged codership-mysql/5.5 revisions: bzr diff -r3759..3767 merged codership-mysql/5.5 revisions: bzr diff -r3768..3771
Diffstat (limited to 'storage/xtradb/os')
-rw-r--r--storage/xtradb/os/os0file.c122
-rw-r--r--storage/xtradb/os/os0proc.c3
-rw-r--r--storage/xtradb/os/os0thread.c6
3 files changed, 119 insertions, 12 deletions
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c
index 875aea7878d..075a2ac4a12 100644
--- a/storage/xtradb/os/os0file.c
+++ b/storage/xtradb/os/os0file.c
@@ -3339,7 +3339,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 */
@@ -3400,12 +3484,23 @@ os_aio_array_create(
if (!os_aio_linux_create_io_ctx(n/n_segments,
&array->aio_ctx[i])) {
/* If something bad happened during aio setup
- we should call it a day and return right away.
- We don't care about any leaks because a failure
- to initialize the io subsystem means that the
- server (or atleast the innodb storage engine)
- is not going to startup. */
- return(NULL);
+ we disable linux native aio.
+ The disadvantage will be a small memory leak
+ at shutdown but that's ok compared to a crash
+ or a not working server.
+ This frequently happens when running the test suite
+ with many threads on a system with low fs.aio-max-nr!
+ */
+
+ fprintf(stderr,
+ " InnoDB: Warning: Linux Native AIO disabled "
+ "because os_aio_linux_create_io_ctx() "
+ "failed. To get rid of this warning you can "
+ "try increasing system "
+ "fs.aio-max-nr to 1048576 or larger or "
+ "setting innodb_use_native_aio = 0 in my.cnf\n");
+ srv_use_native_aio = FALSE;
+ goto skip_native_aio;
}
}
@@ -3479,6 +3574,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");
}
diff --git a/storage/xtradb/os/os0proc.c b/storage/xtradb/os/os0proc.c
index 0f56a608f38..68321e1aaf9 100644
--- a/storage/xtradb/os/os0proc.c
+++ b/storage/xtradb/os/os0proc.c
@@ -111,9 +111,6 @@ os_mem_alloc_large(
os_fast_mutex_lock(&ut_list_mutex);
ut_total_allocated_memory += size;
os_fast_mutex_unlock(&ut_list_mutex);
-# ifdef UNIV_SET_MEM_TO_ZERO
- memset(ptr, '\0', size);
-# endif
UNIV_MEM_ALLOC(ptr, size);
return(ptr);
}
diff --git a/storage/xtradb/os/os0thread.c b/storage/xtradb/os/os0thread.c
index 12b6805d98e..b19b5378fcd 100644
--- a/storage/xtradb/os/os0thread.c
+++ b/storage/xtradb/os/os0thread.c
@@ -136,8 +136,10 @@ os_thread_create(
if (thread_id) {
*thread_id = win_thread_id;
}
-
- return(thread);
+ if (thread) {
+ CloseHandle(thread);
+ }
+ return((os_thread_t)win_thread_id);
#else
int ret;
os_thread_t pthread;