]> git.sur5r.net Git - openldap/commitdiff
Tweak conditionals for fdatasync hack
authorHoward Chu <hyc@openldap.org>
Sun, 11 Jan 2015 11:37:37 +0000 (11:37 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 11 Jan 2015 11:37:37 +0000 (11:37 +0000)
libraries/liblmdb/Makefile
libraries/liblmdb/mdb.c

index bca5cd3819c2f7d60426fa6f8eb48dab2dcbd740..2d0983eff04457c8f0e8d2cf785f23de46ca6606 100644 (file)
@@ -11,6 +11,7 @@
 # - MDB_USE_POSIX_SEM
 # - MDB_DSYNC
 # - MDB_FDATASYNC
+# - MDB_FDATASYNC_WORKS
 # - MDB_USE_PWRITEV
 #
 # There may be other macros in mdb.c of interest. You should
index 121c53c3d9bf443a85dbf2129f86700bfe2c3a1a..d82c3f022bf76b5816a04ee008c698fa062dacdc 100644 (file)
@@ -79,6 +79,12 @@ extern int cacheflush(char *addr, int nbytes, int cache);
 #define CACHEFLUSH(addr, bytes, cache)
 #endif
 
+#if defined(__linux) && !defined(MDB_FDATASYNC_WORKS)
+/** fdatasync is broken on ext3/ext4fs on older kernels, see
+ *     description in #mdb_env_open2 comments
+ */
+#define        BROKEN_FDATASYNC
+#endif
 
 #include <errno.h>
 #include <limits.h>
@@ -1180,7 +1186,7 @@ struct MDB_env {
 #ifdef _WIN32
        int             me_pidquery;            /**< Used in OpenProcess */
 #endif
-#ifdef __linux
+#ifdef BROKEN_FDATASYNC
        int             me_fsynconly;           /**< fdatasync is unreliable */
 #endif
 #if defined(_WIN32) || defined(MDB_USE_SYSV_SEM)
@@ -2361,7 +2367,7 @@ mdb_env_sync(MDB_env *env, int force)
                                rc = ErrCode();
 #endif
                } else {
-#ifdef __linux
+#ifdef BROKEN_FDATASYNC
                        if (env->me_fsynconly) {
                                if (fsync(env->me_fd))
                                        rc = ErrCode();
@@ -3929,7 +3935,7 @@ mdb_fsize(HANDLE fd, size_t *size)
        return MDB_SUCCESS;
 }
 
-#ifdef __linux
+#ifdef BROKEN_FDATASYNC
 #include <sys/utsname.h>
 #include <sys/vfs.h>
 #endif
@@ -3952,7 +3958,7 @@ mdb_env_open2(MDB_env *env)
                env->me_pidquery = PROCESS_QUERY_INFORMATION;
 #endif /* _WIN32 */
 
-#ifdef __linux
+#ifdef BROKEN_FDATASYNC
        /* ext3/ext4 fdatasync is broken on some older Linux kernels.
         * https://lkml.org/lkml/2012/9/3/83
         * Kernels after 3.6-rc6 are known good.