summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2012-11-19 17:31:55 -0800
committerSage Weil <sage@inktank.com>2012-11-22 08:50:44 -0800
commitb706945ae9a985761d2aa355307a14b23ea0a3f7 (patch)
treec725fbdf9965cdbd2b9e38e932a3378bff2d4f13
parent189d073b2554ce32de7d6c759f03e08b25b3512e (diff)
downloadceph-b706945ae9a985761d2aa355307a14b23ea0a3f7.tar.gz
Try using syscall() for syncfs if not supported directly by glibc
Signed-off-by: Dan Mick <dan.mick@inktank.com>
-rw-r--r--src/common/sync_filesystem.h6
-rw-r--r--src/os/FileStore.cc10
2 files changed, 16 insertions, 0 deletions
diff --git a/src/common/sync_filesystem.h b/src/common/sync_filesystem.h
index 3ad8c9e928d..dc90b890c93 100644
--- a/src/common/sync_filesystem.h
+++ b/src/common/sync_filesystem.h
@@ -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;
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index b8f01c2e1ac..1d6797c2b32 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -25,6 +25,7 @@
#if defined(__linux__)
#include <linux/fs.h>
+#include <syscall.h>
#endif
#include <iostream>
@@ -1227,8 +1228,17 @@ int FileStore::_detect_fs()
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) {
dout(0) << "mount no syncfs(2), but the btrfs SYNC ioctl will suffice" << dendl;