diff options
Diffstat (limited to 'storage/xtradb/os/os0file.c')
-rw-r--r-- | storage/xtradb/os/os0file.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index f4a6c33655f..8f1b3e46bb2 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -1454,6 +1454,43 @@ os_file_set_nocache( #endif } + +#ifdef __linux__ +#include <sys/ioctl.h> +#ifndef DFS_IOCTL_ATOMIC_WRITE_SET +#define DFS_IOCTL_ATOMIC_WRITE_SET _IOW(0x95, 2, uint) +#endif +static int os_file_set_atomic_writes(os_file_t file, const char *name) +{ + static int first_time = 1; + int atomic_option = 1; + + int ret = ioctl (file, DFS_IOCTL_ATOMIC_WRITE_SET, &atomic_option); + + if (ret) { + fprintf(stderr, + "InnoDB : can't use atomic write on %s, errno %d\n", + name, errno); + return ret; + } + return ret; +} +#else +static int os_file_set_atomic_writes(os_file_t file, const char *name) +{ + fprintf(stderr, + "InnoDB : can't use atomic writes on %s - not implemented on this platform." + "innodb_use_atomic_writes needs to be 0.\n", + name); +#ifdef _WIN32 + SetLastError(ERROR_INVALID_FUNCTION); +#else + errno = EINVAL; +#endif + return -1; +} +#endif + /****************************************************************//** NOTE! Use the corresponding macro os_file_create(), not directly this function! @@ -1618,6 +1655,13 @@ try_again: } } + if (srv_use_atomic_writes && type == OS_DATA_FILE && + os_file_set_atomic_writes(file, name)) { + CloseHandle(file); + *success = FALSE; + file = INVALID_HANDLE_VALUE; + } + return(file); #else /* __WIN__ */ os_file_t file; @@ -1737,6 +1781,12 @@ try_again: file = -1; } #endif /* USE_FILE_LOCK */ + if (srv_use_atomic_writes && type == OS_DATA_FILE + && os_file_set_atomic_writes(file, name)) { + close(file); + *success = FALSE; + file = -1; + } return(file); #endif /* __WIN__ */ @@ -2081,6 +2131,28 @@ os_file_set_size( current_size = 0; desired_size = (ib_int64_t)size + (((ib_int64_t)size_high) << 32); +#ifdef HAVE_POSIX_FALLOCATE + if (srv_use_posix_fallocate) { + if (posix_fallocate(file, current_size, desired_size) == -1) { + fprintf(stderr, + "InnoDB: Error: preallocating data for" + " file %s failed at\n" + "InnoDB: offset 0 size %lld %lld. Operating system" + " error number %llu.\n" + "InnoDB: Check that the disk is not full" + " or a disk quota exceeded.\n" + "InnoDB: Some operating system error numbers" + " are described at\n" + "InnoDB: " + REFMAN "operating-system-error-codes.html\n", + name, (long long)size_high, (long long)size, errno); + + return (FALSE); + } + return (TRUE); + } +#endif + /* Write up to 1 megabyte at a time. */ buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE)) * UNIV_PAGE_SIZE; |