]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Try using syscall() for syncfs if not supported directly by glibc
authorDan Mick <dan.mick@inktank.com>
Tue, 20 Nov 2012 01:31:55 +0000 (17:31 -0800)
committerSage Weil <sage@inktank.com>
Thu, 22 Nov 2012 16:50:44 +0000 (08:50 -0800)
Signed-off-by: Dan Mick <dan.mick@inktank.com>
src/common/sync_filesystem.h
src/os/FileStore.cc

index 3ad8c9e928d1afec4944267b4bf1b11a67fe2d99..dc90b890c93c65c5c5ad4253f82a723c71277877 100644 (file)
@@ -16,6 +16,7 @@
 #define CEPH_SYNC_FILESYSTEM_H
 
 #include <unistd.h>
+#include <syscall.h>
 
 #ifndef __CYGWIN__
 # ifndef DARWIN
@@ -35,6 +36,11 @@ inline int sync_filesystem(int fd)
     return 0;
 #endif
 
+#ifdef SYS_syncfs
+  if (syscall(SYS_syncfs, fd) == 0)
+    return 0;
+#endif
+
 #ifdef BTRFS_IOC_SYNC
   if (::ioctl(fd, BTRFS_IOC_SYNC) == 0)
     return 0;
index b8f01c2e1ac6d0b84f4654d40776c9ec6c4a9931..1d6797c2b32148ea66ecedfb9e0af1b8eaf3bdd1 100644 (file)
@@ -25,6 +25,7 @@
 
 #if defined(__linux__)
 #include <linux/fs.h>
+#include <syscall.h>
 #endif
 
 #include <iostream>
@@ -1226,8 +1227,17 @@ int FileStore::_detect_fs()
   } else {
     dout(0) << "mount syncfs(2) syscall supported by glibc BUT NOT the kernel" << dendl;
   }
+#else
+#ifdef SYS_syncfs
+  if (syscall(SYS_syncfs, fd) == 0) {
+    dout(0) << "mount syscall(SYS_syncfs, fd) fully supported" << dendl;
+    have_syncfs = true;
+  } else {
+    dout(0) << "mount syscall(SYS_syncfs, fd) supported by libc BUT NOT the kernel" << dendl;
+  }
 #else
   dout(0) << "mount syncfs(2) syscall not support by glibc" << dendl;
+#endif
 #endif
   if (!have_syncfs) {
     if (btrfs) {