summaryrefslogtreecommitdiff
path: root/storage/xtradb/os
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-07-18 19:47:01 +0200
committerSergei Golubchik <serg@mariadb.org>2017-07-18 19:47:01 +0200
commit46977e0a01ae2118df08c3cccaf2f0eaaabd2715 (patch)
tree9aa25e1ef1507906728dab306ba534505f775a69 /storage/xtradb/os
parentcba2ac6ef10304047f7a7941e6c8912573ebc3c6 (diff)
downloadmariadb-git-46977e0a01ae2118df08c3cccaf2f0eaaabd2715.tar.gz
5.5.55-38.8
Diffstat (limited to 'storage/xtradb/os')
-rw-r--r--storage/xtradb/os/os0file.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c
index 21f8c3eed11..25692e73db1 100644
--- a/storage/xtradb/os/os0file.c
+++ b/storage/xtradb/os/os0file.c
@@ -961,50 +961,15 @@ next_file:
char* full_path;
int ret;
struct stat statinfo;
-#ifdef HAVE_READDIR_R
- char dirent_buf[sizeof(struct dirent)
- + _POSIX_PATH_MAX + 100];
- /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as
- the max file name len; but in most standards, the
- length is NAME_MAX; we add 100 to be even safer */
-#endif
next_file:
-#ifdef HAVE_READDIR_R
- ret = readdir_r(dir, (struct dirent*)dirent_buf, &ent);
-
- if (ret != 0
-#ifdef UNIV_AIX
- /* On AIX, only if we got non-NULL 'ent' (result) value and
- a non-zero 'ret' (return) value, it indicates a failed
- readdir_r() call. An NULL 'ent' with an non-zero 'ret'
- would indicate the "end of the directory" is reached. */
- && ent != NULL
-#endif
- ) {
- fprintf(stderr,
- "InnoDB: cannot read directory %s, error %lu\n",
- dirname, (ulong)ret);
-
- return(-1);
- }
-
- if (ent == NULL) {
- /* End of directory */
-
- return(1);
- }
-
- ut_a(strlen(ent->d_name) < _POSIX_PATH_MAX + 100 - 1);
-#else
ent = readdir(dir);
if (ent == NULL) {
return(1);
}
-#endif
ut_a(strlen(ent->d_name) < OS_FILE_MAX_PATH);
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
@@ -1382,9 +1347,10 @@ os_file_create_simple_no_error_handling_func(
}
/****************************************************************//**
-Tries to disable OS caching on an opened file descriptor. */
+Tries to disable OS caching on an opened file descriptor.
+@return TRUE if operation is success and FALSE otherwise */
UNIV_INTERN
-void
+ibool
os_file_set_nocache(
/*================*/
int fd /*!< in: file descriptor to alter */
@@ -1405,6 +1371,7 @@ os_file_set_nocache(
" InnoDB: Failed to set DIRECTIO_ON "
"on file %s: %s: %s, continuing anyway\n",
file_name, operation_name, strerror(errno_save));
+ return FALSE;
}
#elif defined(O_DIRECT)
if (fcntl(fd, F_SETFL, O_DIRECT) == -1) {
@@ -1422,8 +1389,10 @@ os_file_set_nocache(
"'Invalid argument' on Linux on tmpfs, "
"see MySQL Bug#26662\n");
}
+ return FALSE;
}
#endif
+ return TRUE;
}
/****************************************************************//**
@@ -1699,7 +1668,11 @@ try_again:
/* ALL_O_DIRECT: O_DIRECT also for transaction log file */
if (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT) {
- os_file_set_nocache(file, name, mode_str);
+ /* Do fsync() on log files when setting O_DIRECT fails.
+ See log_io_complete() */
+ if (!os_file_set_nocache(file, name, mode_str)) {
+ srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
+ }
}
#ifdef USE_FILE_LOCK