summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
Diffstat (limited to 'innobase')
-rw-r--r--innobase/include/srv0start.h4
-rw-r--r--innobase/os/os0file.c24
-rw-r--r--innobase/srv/srv0start.c27
3 files changed, 49 insertions, 6 deletions
diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h
index 75af1a212b4..8df0f97c4ff 100644
--- a/innobase/include/srv0start.h
+++ b/innobase/include/srv0start.h
@@ -75,6 +75,10 @@ extern dulint srv_start_lsn;
void set_panic_flag_for_netware(void);
#endif
+#ifdef HAVE_DARWIN_THREADS
+extern ibool srv_have_fullfsync;
+#endif
+
extern ulint srv_sizeof_trx_t_in_ha_innodb_cc;
extern ibool srv_is_being_started;
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 60760d1f8b8..6fb27346a37 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -1763,19 +1763,31 @@ os_file_flush(
#else
int ret;
-#if defined(HAVE_DARWIN_THREADS) && defined(F_FULLFSYNC)
+#if defined(HAVE_DARWIN_THREADS)
+# ifndef F_FULLFSYNC
+ /* The following definition is from the Mac OS X 10.3 <sys/fcntl.h> */
+# define F_FULLFSYNC 51 /* fsync + ask the drive to flush to the media */
+# elif F_FULLFSYNC != 51
+# error "F_FULLFSYNC != 51: ABI incompatibility with Mac OS X 10.3"
+# endif
/* Apple has disabled fsync() for internal disk drives in OS X. That
caused corruption for a user when he tested a power outage. Let us in
OS X use a nonstandard flush method recommended by an Apple
engineer. */
- ret = fcntl(file, F_FULLFSYNC, NULL);
-
- if (ret) {
- /* If we are not on a file system that supports this, then
- fall back to a plain fsync. */
+ if (!srv_have_fullfsync) {
+ /* If we are not on an operating system that supports this,
+ then fall back to a plain fsync. */
ret = fsync(file);
+ } else {
+ ret = fcntl(file, F_FULLFSYNC, NULL);
+
+ if (ret) {
+ /* If we are not on a file system that supports this,
+ then fall back to a plain fsync. */
+ ret = fsync(file);
+ }
}
#elif HAVE_FDATASYNC
ret = fdatasync(file);
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 7a61a885ef9..fe05f07df21 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -61,6 +61,11 @@ dulint srv_start_lsn;
/* Log sequence number at shutdown */
dulint srv_shutdown_lsn;
+#ifdef HAVE_DARWIN_THREADS
+# include <sys/utsname.h>
+ibool srv_have_fullfsync = FALSE;
+#endif
+
ibool srv_start_raw_disk_in_use = FALSE;
static ibool srv_start_has_been_called = FALSE;
@@ -935,6 +940,28 @@ innobase_start_or_create_for_mysql(void)
ulint i;
ibool srv_file_per_table_original_value = srv_file_per_table;
mtr_t mtr;
+#ifdef HAVE_DARWIN_THREADS
+# ifdef F_FULLFSYNC
+ /* This executable has been compiled on Mac OS X 10.3 or later.
+ Assume that F_FULLFSYNC is available at run-time. */
+ srv_have_fullfsync = TRUE;
+# else /* F_FULLFSYNC */
+ /* This executable has been compiled on Mac OS X 10.2
+ or earlier. Determine if the executable is running
+ on Mac OS X 10.3 or later. */
+ struct utsname utsname;
+ if (uname(&utsname)) {
+ fputs("InnoDB: cannot determine Mac OS X version!\n", stderr);
+ } else {
+ srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0;
+ }
+ if (!srv_have_fullfsync) {
+ fputs(
+"InnoDB: On Mac OS X, fsync() may be broken on internal drives,\n"
+"InnoDB: making transactions unsafe!\n", stderr);
+ }
+# endif /* F_FULLFSYNC */
+#endif /* HAVE_DARWIN_THREADS */
if (sizeof(ulint) != sizeof(void*)) {
fprintf(stderr,