From 8a7540321d01a11f461b99fc313e463ba58a5f65 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 3 Mar 2018 19:35:31 +0100 Subject: Disabled the use of posix_fadvise() when reading --- HISTORY | 6 +++++- UPDATE-2.4.0 | 7 ++++--- tools.c | 21 +++++++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/HISTORY b/HISTORY index 92e9c941..7a0e034d 100644 --- a/HISTORY +++ b/HISTORY @@ -9162,7 +9162,7 @@ Video Disk Recorder Revision History a subdirectory. - SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details). -2018-02-28: Version 2.3.9 +2018-03-03: Version 2.3.9 - Updated the Italian OSD texts (thanks to Diego Pierotto). - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). @@ -9289,3 +9289,7 @@ Video Disk Recorder Revision History - When remote timers are fetched from a peer VDR, we no longer blindly delete and re-add them, but rather compare them and make only the minimum necessary changes. - Fixed the CompareInts() function. +- Disabled the use of posix_fadvise() when reading (i.e. replaying), since it caused + stuttering replay in fast forward and fast rewind mode in case the video directory + is mounted via NFS. You can re-enable it by setting the macro USE_FADVISE_READ to 1 + in tools.c. diff --git a/UPDATE-2.4.0 b/UPDATE-2.4.0 index beacc8fc..4da81ba3 100644 --- a/UPDATE-2.4.0 +++ b/UPDATE-2.4.0 @@ -1,6 +1,3 @@ -PRELIMINARY VERSION! -==================== - This is a summary of the changes in VDR 2.4.0 since the last stable version 2.2.0. It only contains things that are of actual importance to the user and doesn't mention the many fixes and improvements that @@ -440,3 +437,7 @@ Misc: 'DEPRECATED_VDR_CHARSET_OVERRIDE=1' when compiling in order to restore this functionality. However, it is recommended to use the command line option --chartab instead. +- Disabled the use of posix_fadvise() when reading (i.e. replaying), since it caused + stuttering replay in fast forward and fast rewind mode in case the video directory + is mounted via NFS. You can re-enable it by setting the macro USE_FADVISE_READ to 1 + in tools.c. diff --git a/tools.c b/tools.c index 28e03cdc..4d3489af 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 4.9 2018/02/27 10:09:21 kls Exp $ + * $Id: tools.c 4.10 2018/03/03 19:35:31 kls Exp $ */ #include "tools.h" @@ -1774,7 +1774,12 @@ bool cSafeFile::Close(void) // --- cUnbufferedFile ------------------------------------------------------- -#define USE_FADVISE +#ifndef USE_FADVISE_READ +#define USE_FADVISE_READ 0 +#endif +#ifndef USE_FADVISE_WRITE +#define USE_FADVISE_WRITE 1 +#endif #define WRITE_BUFFER KILOBYTE(800) @@ -1793,7 +1798,7 @@ int cUnbufferedFile::Open(const char *FileName, int Flags, mode_t Mode) Close(); fd = open(FileName, Flags, Mode); curpos = 0; -#ifdef USE_FADVISE +#if USE_FADVISE_READ || USE_FADVISE_WRITE begin = lastpos = ahead = 0; cachedstart = 0; cachedend = 0; @@ -1809,7 +1814,7 @@ int cUnbufferedFile::Open(const char *FileName, int Flags, mode_t Mode) int cUnbufferedFile::Close(void) { if (fd >= 0) { -#ifdef USE_FADVISE +#if USE_FADVISE_READ || USE_FADVISE_WRITE if (totwritten) // if we wrote anything make sure the data has hit the disk before fdatasync(fd); // calling fadvise, as this is our last chance to un-cache it. posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); @@ -1852,7 +1857,7 @@ off_t cUnbufferedFile::Seek(off_t Offset, int Whence) ssize_t cUnbufferedFile::Read(void *Data, size_t Size) { if (fd >= 0) { -#ifdef USE_FADVISE +#if USE_FADVISE_READ off_t jumped = curpos-lastpos; // nonzero means we're not at the last offset if ((cachedstart < cachedend) && (curpos < cachedstart || curpos > cachedend)) { // current position is outside the cached window -- invalidate it. @@ -1865,7 +1870,7 @@ ssize_t cUnbufferedFile::Read(void *Data, size_t Size) ssize_t bytesRead = safe_read(fd, Data, Size); if (bytesRead > 0) { curpos += bytesRead; -#ifdef USE_FADVISE +#if USE_FADVISE_READ cachedend = max(cachedend, curpos); // Read ahead: @@ -1887,7 +1892,7 @@ ssize_t cUnbufferedFile::Read(void *Data, size_t Size) ahead = curpos; // jumped -> we really don't want any readahead, otherwise e.g. fast-rewind gets in trouble. #endif } -#ifdef USE_FADVISE +#if USE_FADVISE_READ if (cachedstart < cachedend) { if (curpos - cachedstart > READCHUNK * 2) { // current position has moved forward enough, shrink tail window. @@ -1911,7 +1916,7 @@ ssize_t cUnbufferedFile::Write(const void *Data, size_t Size) { if (fd >=0) { ssize_t bytesWritten = safe_write(fd, Data, Size); -#ifdef USE_FADVISE +#if USE_FADVISE_WRITE if (bytesWritten > 0) { begin = min(begin, curpos); curpos += bytesWritten; -- cgit v1.2.3