From: Noah Watkins Date: Sun, 29 Sep 2013 18:32:29 +0000 (-0700) Subject: wbthrottle: use feature check for fdatasync X-Git-Tag: v0.74~18^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F919%2Fhead;p=ceph.git wbthrottle: use feature check for fdatasync 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 --- diff --git a/configure.ac b/configure.ac index 7236e447ea45..31a1ecae4e53 100644 --- a/configure.ac +++ b/configure.ac @@ -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 +]], [[ +#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 diff --git a/src/os/WBThrottle.cc b/src/os/WBThrottle.cc index d71583958c65..c5fb49505c55 100644 --- a/src/os/WBThrottle.cc +++ b/src/os/WBThrottle.cc @@ -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);