1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Disabled the use of posix_fadvise() when reading

This commit is contained in:
Klaus Schmidinger 2018-03-03 19:35:31 +01:00
parent adc7056c9e
commit 8a7540321d
3 changed files with 22 additions and 12 deletions

View File

@ -9162,7 +9162,7 @@ Video Disk Recorder Revision History
a subdirectory. a subdirectory.
- SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details). - 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 Italian OSD texts (thanks to Diego Pierotto).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - 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 - 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. them, but rather compare them and make only the minimum necessary changes.
- Fixed the CompareInts() function. - 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.

View File

@ -1,6 +1,3 @@
PRELIMINARY VERSION!
====================
This is a summary of the changes in VDR 2.4.0 since the last stable 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 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 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 'DEPRECATED_VDR_CHARSET_OVERRIDE=1' when compiling in order to restore this
functionality. However, it is recommended to use the command line option --chartab functionality. However, it is recommended to use the command line option --chartab
instead. 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.

21
tools.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "tools.h"
@ -1774,7 +1774,12 @@ bool cSafeFile::Close(void)
// --- cUnbufferedFile ------------------------------------------------------- // --- 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) #define WRITE_BUFFER KILOBYTE(800)
@ -1793,7 +1798,7 @@ int cUnbufferedFile::Open(const char *FileName, int Flags, mode_t Mode)
Close(); Close();
fd = open(FileName, Flags, Mode); fd = open(FileName, Flags, Mode);
curpos = 0; curpos = 0;
#ifdef USE_FADVISE #if USE_FADVISE_READ || USE_FADVISE_WRITE
begin = lastpos = ahead = 0; begin = lastpos = ahead = 0;
cachedstart = 0; cachedstart = 0;
cachedend = 0; cachedend = 0;
@ -1809,7 +1814,7 @@ int cUnbufferedFile::Open(const char *FileName, int Flags, mode_t Mode)
int cUnbufferedFile::Close(void) int cUnbufferedFile::Close(void)
{ {
if (fd >= 0) { 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 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. fdatasync(fd); // calling fadvise, as this is our last chance to un-cache it.
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); 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) ssize_t cUnbufferedFile::Read(void *Data, size_t Size)
{ {
if (fd >= 0) { if (fd >= 0) {
#ifdef USE_FADVISE #if USE_FADVISE_READ
off_t jumped = curpos-lastpos; // nonzero means we're not at the last offset off_t jumped = curpos-lastpos; // nonzero means we're not at the last offset
if ((cachedstart < cachedend) && (curpos < cachedstart || curpos > cachedend)) { if ((cachedstart < cachedend) && (curpos < cachedstart || curpos > cachedend)) {
// current position is outside the cached window -- invalidate it. // 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); ssize_t bytesRead = safe_read(fd, Data, Size);
if (bytesRead > 0) { if (bytesRead > 0) {
curpos += bytesRead; curpos += bytesRead;
#ifdef USE_FADVISE #if USE_FADVISE_READ
cachedend = max(cachedend, curpos); cachedend = max(cachedend, curpos);
// Read ahead: // 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. ahead = curpos; // jumped -> we really don't want any readahead, otherwise e.g. fast-rewind gets in trouble.
#endif #endif
} }
#ifdef USE_FADVISE #if USE_FADVISE_READ
if (cachedstart < cachedend) { if (cachedstart < cachedend) {
if (curpos - cachedstart > READCHUNK * 2) { if (curpos - cachedstart > READCHUNK * 2) {
// current position has moved forward enough, shrink tail window. // 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) { if (fd >=0) {
ssize_t bytesWritten = safe_write(fd, Data, Size); ssize_t bytesWritten = safe_write(fd, Data, Size);
#ifdef USE_FADVISE #if USE_FADVISE_WRITE
if (bytesWritten > 0) { if (bytesWritten > 0) {
begin = min(begin, curpos); begin = min(begin, curpos);
curpos += bytesWritten; curpos += bytesWritten;