diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-08-31 14:15:52 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-08-31 14:15:52 +0200 |
commit | 59408093d1add69dd4cd3d1674a73712528aed92 (patch) | |
tree | 85e7d74ddb7c0a74c6c434b9c3dacfe9b7ebe2a3 /mysys | |
parent | a1fd37b1fd5803188d3f8b44914cca459f6e622f (diff) | |
parent | 51e14492e9410718056b0c6d9d4dabd4a96e8070 (diff) | |
download | mariadb-git-59408093d1add69dd4cd3d1674a73712528aed92.tar.gz |
5.3 merge
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_sync.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/mysys/my_sync.c b/mysys/my_sync.c index 3853d30632e..88bcb685271 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -49,6 +49,13 @@ void thr_set_sync_wait_callback(void (*before_wait)(void), (which is correct behaviour, if we know that the other thread synced the file before closing) + MY_SYNC_FILESIZE is useful when syncing a file after it has been extended. + On Linux, fdatasync() on ext3/ext4 file systems does not properly flush + to disk the inode data required to preserve the added data across a crash + (this looks to be a bug). But when a file is extended, inode data will most + likely need flushing in any case, so passing MY_SYNC_FILESIZE as flags + is not likely to be any slower, and will be crash safe on Linux ext3/ext4. + RETURN 0 ok -1 error @@ -84,8 +91,12 @@ int my_sync(File fd, myf my_flags) DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back")); #endif #if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC - res= fdatasync(fd); -#elif defined(HAVE_FSYNC) + if (!(my_flags & MY_SYNC_FILESIZE)) + res= fdatasync(fd); + else + { +#endif +#if defined(HAVE_FSYNC) res= fsync(fd); if (res == -1 && errno == ENOLCK) res= 0; /* Result Bug in Old FreeBSD */ @@ -95,6 +106,9 @@ int my_sync(File fd, myf my_flags) #error Cannot find a way to sync a file, durability in danger res= 0; /* No sync (strange OS) */ #endif +#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC + } +#endif } while (res == -1 && errno == EINTR); if (res) |