From a4c0890bf022384f2013be4648e09684fc22edab Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Tue, 9 Jan 2024 22:03:48 +0000 Subject: [PATCH 1/3] avoid fifo fsync --- VERSION | 2 +- src/eckit/io/FDataSync.cc | 6 ++++++ src/eckit/io/FileHandle.cc | 4 ---- src/eckit/serialisation/FileStream.cc | 6 ++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index ad2191947..d905a6d1d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.25.0 +1.25.1 diff --git a/src/eckit/io/FDataSync.cc b/src/eckit/io/FDataSync.cc index de8527883..c6a9b8e64 100644 --- a/src/eckit/io/FDataSync.cc +++ b/src/eckit/io/FDataSync.cc @@ -14,11 +14,17 @@ #include #include "eckit/eckit.h" +#include "eckit/os/Stat.h" namespace eckit { int fsync(int fd) { + Stat::Struct info; + if (Stat::fstat(fd, &info) == 0 && (info.st_mode & S_IFIFO)) { + return 0; + } + int ret = ::fsync(fd); while (ret < 0 && errno == EINTR) { ret = ::fsync(fd); diff --git a/src/eckit/io/FileHandle.cc b/src/eckit/io/FileHandle.cc index 259160a61..5dc2ea30a 100644 --- a/src/eckit/io/FileHandle.cc +++ b/src/eckit/io/FileHandle.cc @@ -151,10 +151,6 @@ void FileHandle::flush() { int ret = eckit::fsync(fileno(file_)); - while (ret < 0 && errno == EINTR) { - ret = eckit::fsync(fileno(file_)); - } - if (ret < 0) { std::ostringstream oss; oss << "Cannot fsync(" << name_ << ") " << fileno(file_); diff --git a/src/eckit/serialisation/FileStream.cc b/src/eckit/serialisation/FileStream.cc index 6c81348e8..b894bc455 100644 --- a/src/eckit/serialisation/FileStream.cc +++ b/src/eckit/serialisation/FileStream.cc @@ -13,6 +13,7 @@ #include "eckit/eckit.h" +#include "eckit/io/FDataSync.h" #include "eckit/exception/Exceptions.h" #include "eckit/log/Log.h" #include "eckit/serialisation/FileStream.h" @@ -39,11 +40,8 @@ void FileStream::close() { // a power failure, we lose some data. So we // need to fsync - int ret = fsync(fileno(file_)); + int ret = eckit::fsync(fileno(file_)); - while (ret < 0 && errno == EINTR) { - ret = fsync(fileno(file_)); - } if (ret < 0) { Log::error() << "Cannot fsync(" << name_ << ") " << fileno(file_) << Log::syserr << std::endl; } From f371bc2654e796a733d1e6428ee22b3d379645f8 Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Wed, 10 Jan 2024 09:38:10 +0000 Subject: [PATCH 2/3] version bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d905a6d1d..61b813d5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.25.1 +1.25.2 From c13ab8969e27279a54fbbd9037e1b87cce9e4f5d Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Wed, 10 Jan 2024 13:28:29 +0000 Subject: [PATCH 3/3] apply fsync only to regular and symlink files --- src/eckit/io/FDataSync.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eckit/io/FDataSync.cc b/src/eckit/io/FDataSync.cc index c6a9b8e64..07cef4176 100644 --- a/src/eckit/io/FDataSync.cc +++ b/src/eckit/io/FDataSync.cc @@ -21,7 +21,7 @@ namespace eckit { int fsync(int fd) { Stat::Struct info; - if (Stat::fstat(fd, &info) == 0 && (info.st_mode & S_IFIFO)) { + if (Stat::fstat(fd, &info) == 0 && !S_ISREG(info.st_mode) && !S_ISLNK(info.st_mode)) { return 0; }