From 9a206835b903a3e76a19d251159542820cbdae6f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 5 Jul 2018 10:20:09 +0200 Subject: [SERVER] Always use fsync instead of fdatasync Now that we support sparse files, using just fdatasync isn't safe anymore. Instead of handling both cases differently just drop fdatasync, the difference has probably been marginal all along anyways. --- src/server/uplink.c | 10 ++-------- src/types.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/server/uplink.c b/src/server/uplink.c index 538f388..26e5d4e 100644 --- a/src/server/uplink.c +++ b/src/server/uplink.c @@ -14,12 +14,6 @@ #include #include -#ifdef HAVE_FDATASYNC -#define dnbd3_fdatasync fdatasync -#else -#define dnbd3_fdatasync fsync -#endif - static uint64_t totalBytesReceived = 0; static pthread_spinlock_t statisticsReceivedLock; @@ -851,7 +845,7 @@ static bool uplink_saveCacheMap(dnbd3_connection_t *link) assert( image != NULL ); if ( link->cacheFd != -1 ) { - if ( dnbd3_fdatasync( link->cacheFd ) == -1 ) { + if ( fsync( link->cacheFd ) == -1 ) { // A failing fsync means we have no guarantee that any data // since the last fsync (or open if none) has been saved. Apart // from keeping the cache_map from the last successful fsync @@ -905,7 +899,7 @@ static bool uplink_saveCacheMap(dnbd3_connection_t *link) } done += (size_t)ret; } - if ( dnbd3_fdatasync( fd ) == -1 ) { + if ( fsync( fd ) == -1 ) { logadd( LOG_WARNING, "fsync() on image map %s failed with errno %d", mapfile, errno ); } close( fd ); diff --git a/src/types.h b/src/types.h index 86b3469..ec37d9b 100644 --- a/src/types.h +++ b/src/types.h @@ -50,7 +50,6 @@ #ifdef __linux__ #define HAVE_THREAD_NAMES -#define HAVE_FDATASYNC #endif #ifdef __FreeBSD__ -- cgit v1.2.3-55-g7522