Subject: [vdr] [PATCH] Getting rid of redundand resume.vdr files.
From: Carsten Koch <[email-masked]>
To: Video Disk Recorder Mailing List <[email-masked]>
Date: Sun, 30 Jan 2005 14:58:10 +0100
List-Id: vdr <vdr.mail>

Hi,

I noticed that updating the recordings menu is still very slow.
Caching the data of course did speed up things, but vdr still
has to scan when /video/.update was touched (after an external
change), when it starts up, etc. Also, this has been a workaround
at best against the two basic flaws:

1) when replaying or recording, VDR floods the linux file system
    cache somewhat needlessly with data that do not need to be
    cached since they typically do not get read again while they
    reside in the cache, thus slowing down the intire system and
    not leaving room in the cache for even the directory entries,
    which makes all directoy accesses - including vdr's own recordings
    scan - rather slow.
    I know this problem is not trivial to fix, but using O_DIRECT
    on nnn.vdr files whenever possible should cure it.

2) vdr's recordings scan is slowed down further by the fact that
    VDR opens all resume.vdr files to see if the recording is rewound.
    This problem can be greatly reduced by two steps:
    a) Remove the resume.vdr file if it points to (almost) the
       beginning of the file.
       Patch included.
    b) Never try to read it. If the directory entry is there,
       with the above patch it can be assumed that the recording
       is not rewound.

Carsten.
--- /tmp/vdr-1.3.17/recording.c	2004-11-01 15:04:47.000000000 +0100
+++ recording.c	2005-01-30 13:30:03.383815096 +0100
@@ -193,15 +193,25 @@
 
 bool cResumeFile::Save(int Index)
 {
-  if (fileName) {
-     int f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-     if (f >= 0) {
-        if (safe_write(f, &Index, sizeof(Index)) < 0)
-           LOG_ERROR_STR(fileName);
-        close(f);
+  if (fileName) 
+  {
+     if ((Index / FRAMESPERSEC) < 60)
+     {
+        Delete();
         return true;
-        }
      }
+     else
+     {
+     	int f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+     	if (f >= 0) 
+	{
+     	   if (safe_write(f, &Index, sizeof(Index)) < 0)
+     	      LOG_ERROR_STR(fileName);
+     	   close(f);
+     	   return true;
+     	}
+     }
+  }
   return false;
 }