]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/sync_filesystem.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_SYNC_FILESYSTEM_H
16 #define CEPH_SYNC_FILESYSTEM_H
20 #if defined(__linux__)
21 #include <sys/ioctl.h>
23 #include "os/fs/btrfs_ioctl.h"
26 inline int sync_filesystem(int fd
)
28 /* On Linux, newer versions of glibc have a function called syncfs that
29 * performs a sync on only one filesystem. If we don't have this call, we
30 * have to fall back on sync(), which synchronizes every filesystem on the
32 #ifdef HAVE_SYS_SYNCFS
35 #elif defined(SYS_syncfs)
36 if (syscall(SYS_syncfs
, fd
) == 0)
38 #elif defined(__NR_syncfs)
39 if (syscall(__NR_syncfs
, fd
) == 0)
43 #if defined(HAVE_SYS_SYNCFS) || defined(SYS_syncfs) || defined(__NR_syncfs)
44 else if (errno
== ENOSYS
) {