osd: Use syncfs when available

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
This commit is contained in:
Colin Patrick McCabe 2011-04-13 13:28:52 -07:00
parent 5c06fc1c8b
commit e341fe0b18
4 changed files with 39 additions and 2 deletions

View File

@ -37,6 +37,7 @@ AC_PROG_LIBTOOL
AC_CHECK_LIB([m], [pow], [true], AC_MSG_FAILURE([libm not found]))
AC_CHECK_LIB([pthread], [pthread_create], [true], AC_MSG_FAILURE([libpthread not found]))
AC_CHECK_LIB([keyutils], [add_key], [true], AC_MSG_FAILURE([libkeyutils not found]))
AC_CHECK_FUNCS([syncfs], AC_DEFINE([HAVE_SYS_SYNCFS], [1], [we have syncfs]), [])
# Find some crypto library for us to use, while letting user to decide which one to use.
AC_ARG_WITH([cryptopp],

View File

@ -1072,7 +1072,8 @@ noinst_HEADERS = \
tools/gui.h\
tools/gui_resources.h\
test/osd/RadosModel.h\
common/pidfile.h
common/pidfile.h\
common/sync_filesystem.h
all_sources = $(cmon_SOURCES) $(ceph_SOURCES) $(cephfs_SOURCES) $(librados_config_SOURCES) $(cauthtool_SOURCES) $(monmaptool_SOURCES) \
$(crushtool_SOURCES) $(osdmaptool_SOURCES) $(cconf_SOURCES) $(mount_ceph_SOURCES) $(cmds_SOURCES) \

View File

@ -0,0 +1,34 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_SYNC_FILESYSTEM_H
#define CEPH_SYNC_FILESYSTEM_H
#include <unistd.h>
inline int sync_filesystem(int fd)
{
/* On Linux, newer versions of glibc have a function called syncfs that
* performs a sync on only one filesystem. If we don't have this call, we
* have to fall back on sync(), which synchronizes every filesystem on the
* computer. */
#ifdef HAVE_SYS_SYNCFS
return syncfs(fd);
#else
sync();
return 0;
#endif
}
#endif

View File

@ -29,6 +29,7 @@
#include "common/run_cmd.h"
#include "common/safe_io.h"
#include "common/ProfLogger.h"
#include "common/sync_filesystem.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
@ -2706,7 +2707,7 @@ void FileStore::sync_entry()
::fsync(op_fd);
} else {
dout(15) << "sync_entry doing a full sync (!)" << dendl;
::sync();
sync_filesystem(basedir_fd);
}
}