]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/syncfs: fall back to sync(2) if syncfs(2) not available 5395/head
authorKefu Chai <kchai@redhat.com>
Wed, 29 Jul 2015 07:52:19 +0000 (15:52 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 29 Jul 2015 08:42:55 +0000 (16:42 +0800)
Fixes: #12512
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/sync_filesystem.h

index ecfc77a39333b8d91545fa500c4742647ba3d021..8f45d04b3f6bad2fe4700e645317cfa5a627f721 100644 (file)
@@ -34,18 +34,21 @@ inline int sync_filesystem(int fd)
 #ifdef HAVE_SYS_SYNCFS
   if (syncfs(fd) == 0)
     return 0;
-  else
-    return -errno;
 #elif defined(SYS_syncfs)
   if (syscall(SYS_syncfs, fd) == 0)
     return 0;
-  else
-    return -errno;
 #elif defined(__NR_syncfs)
   if (syscall(__NR_syncfs, fd) == 0)
     return 0;
-  else
+#endif
+
+#if defined(HAVE_SYS_SYNCFS) || defined(SYS_syncfs) || defined(__NR_syncfs)
+  else if (errno == ENOSYS) {
+    sync();
+    return 0;
+  } else {
     return -errno;
+  }
 #else
   sync();
   return 0;