From 70e4bcd52bad29c0f35d258c07129637dc3a7756 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Fri, 18 Oct 2024 13:39:24 +0100 Subject: [PATCH] HPCC-32828 Add filename to fsync warnings Signed-off-by: Jake Smith --- system/jlib/jfile.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/system/jlib/jfile.cpp b/system/jlib/jfile.cpp index cce5b1b54a2..67b15ca9aa4 100644 --- a/system/jlib/jfile.cpp +++ b/system/jlib/jfile.cpp @@ -2055,7 +2055,7 @@ void CFileIO::setSize(offset_t pos) //-- Unix implementation ---------------------------------------------------- -static void doSync(int fd, bool dataOnly) +static void doSync(const CFileIO &fileIO, int fd, bool dataOnly) { #ifdef F_FULLFSYNC // No EIO type retry available @@ -2066,25 +2066,25 @@ static void doSync(int fd, bool dataOnly) if (ret == 0) { if (timer.elapsedMs() >= 10000) - IWARNLOG("doSync: slow success: took %u ms", timer.elapsedMs()); + IWARNLOG("doSync(%s): slow success: took %u ms", fileIO.querySafeFilename(), timer.elapsedMs()); } else { int err = errno; printStackReport(); - Owned e = makeErrnoExceptionV(err, "doSync: failed after %u ms", timer.elapsedMs()); + Owned e = makeErrnoExceptionV(err, "doSync(%s): failed after %u ms", fileIO.querySafeFilename(), timer.elapsedMs()); OWARNLOG(e); throw e.getClear(); } #endif } -static void syncFileData(int fd, bool notReadOnly, IFEflags extraFlags, bool wait_previous=false) +static void syncFileData(const CFileIO &fileIO, int fd, bool notReadOnly, IFEflags extraFlags, bool wait_previous=false) { if (notReadOnly) { if (extraFlags & IFEsync) - doSync(fd, true); + doSync(fileIO, fd, true); #if defined(__linux__) else if (extraFlags & IFEnocache) { @@ -2176,9 +2176,9 @@ void CFileIO::close() DBGLOG("CFileIO::close(%d), extraFlags = %d", tmpHandle, extraFlags); #endif if (extraFlags & (IFEnocache | IFEsync)) - syncFileData(tmpHandle, openmode!=IFOread, extraFlags, false); + syncFileData(*this, tmpHandle, openmode!=IFOread, extraFlags, false); else if (extraFlags & IFEsyncAtClose) - doSync(tmpHandle, false); + doSync(*this, tmpHandle, false); if (::close(tmpHandle) < 0) throw makeErrnoExceptionV(errno, "CFileIO::close for file '%s'", querySafeFilename()); @@ -2192,7 +2192,7 @@ void CFileIO::flush() CriticalBlock procedure(cs); - syncFileData(file, true, extraFlags, false); + syncFileData(*this, file, true, extraFlags, false); } @@ -2229,7 +2229,7 @@ size32_t CFileIO::read(offset_t pos, size32_t len, void * data) if (unflushedReadBytes.add_fetch(ret) >= PGCFLUSH_BLKSIZE) { unflushedReadBytes.store(0); - syncFileData(file, false, extraFlags, false); + syncFileData(*this, file, false, extraFlags, false); } } return ret; @@ -2259,7 +2259,7 @@ size32_t CFileIO::write(offset_t pos, size32_t len, const void * data) { unflushedWriteBytes.store(0); // request to write-out dirty pages - syncFileData(file, true, extraFlags, true); + syncFileData(*this, file, true, extraFlags, true); } } return ret;