]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
wbthrottle: use feature check for fdatasync 919/head
authorNoah Watkins <noahwatkins@gmail.com>
Sun, 29 Sep 2013 18:32:29 +0000 (11:32 -0700)
committerNoah Watkins <noahwatkins@gmail.com>
Sat, 7 Dec 2013 18:37:00 +0000 (10:37 -0800)
Checking for fdatasync uses the same approach as the qemu configure
script. The relevant commit is d1722a27f552a22561104210e0afad4577878e53.
Here is a copy of the commit message which explains the check:

Under Darwin, a symbol exists for the fdatasync() function, so that our
link test succeeds. However _POSIX_SYNCHRONIZED_IO is set to '-1'.

According to POSIX:2008, a value of -1 means the feature is not
supported.
A value of 0 means supported at compilation time, and a value greater 0
means supported at both compilation and run time.

Enable fdatasync() only if _POSIX_SYNCHRONIZED_IO is '>0'.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
configure.ac
src/os/WBThrottle.cc

index 7236e447ea456b5aa3dbc8830689632601f50715..31a1ecae4e53d06cf16b2a5145a55797753f1ab6 100644 (file)
@@ -626,6 +626,22 @@ AC_CHECK_FUNCS([prctl])
 AC_CHECK_FUNCS([pipe2])
 AC_CHECK_FUNCS([posix_fadvise])
 
+AC_MSG_CHECKING([for fdatasync])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <unistd.h>
+]], [[
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+return fdatasync(0);
+#else
+#error Not supported
+#endif
+]])], [
+AC_MSG_RESULT([yes])
+AC_DEFINE([HAVE_FDATASYNC], 1, [Define to 1 if you have fdatasync.])
+], [
+AC_MSG_RESULT([no])
+])
+
 # Checks for typedefs, structures, and compiler characteristics.
 #AC_HEADER_STDBOOL
 #AC_C_CONST
index d71583958c658dbe1838cea77e53ad0fc4b37f30..c5fb49505c55ffbf06c3360c4bd75754045e412b 100644 (file)
@@ -147,7 +147,11 @@ void *WBThrottle::entry()
   while (get_next_should_flush(&wb)) {
     clearing = wb.get<0>();
     lock.Unlock();
+#ifdef HAVE_FDATASYNC
     ::fdatasync(**wb.get<1>());
+#else
+    ::fsync(**wb.get<1>());
+#endif
 #ifdef HAVE_POSIX_FADVISE
     if (wb.get<2>().nocache) {
       int fa_r = posix_fadvise(**wb.get<1>(), 0, 0, POSIX_FADV_DONTNEED);