diff -u -r -p mythtv.100/libs/libmythtv/fileringbuffer.cpp mythtv/libs/libmythtv/fileringbuffer.cpp
--- mythtv.100/libs/libmythtv/fileringbuffer.cpp	2011-01-05 15:29:11.000000000 +0100
+++ mythtv/libs/libmythtv/fileringbuffer.cpp	2011-01-07 17:59:21.650286708 +0100
@@ -100,6 +100,7 @@ FileRingBuffer::~FileRingBuffer()
 
     if (fd2 >= 0)
     {
+	posix_fadvise(fd2, 0, 0, POSIX_FADV_DONTNEED);
         close(fd2);
         fd2 = -1;
     }
@@ -252,8 +253,7 @@ bool FileRingBuffer::OpenFile(const QStr
                 {
                     if (0 == lseek(fd2, 0, SEEK_SET))
                     {
-                        posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL);
-                        posix_fadvise(fd2, 0, 1*1024*1024, POSIX_FADV_WILLNEED);
+                	posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL);
                         lasterror = 0;
                         break;
                     }
@@ -601,10 +601,6 @@ long long FileRingBuffer::Seek(long long
                 else
                 {
                     ret = lseek64(fd2, internalreadpos, SEEK_SET);
-                    posix_fadvise(fd2, 0,
-                                  internalreadpos, POSIX_FADV_DONTNEED);
-                    posix_fadvise(fd2, internalreadpos,
-                                  1*1024*1024, POSIX_FADV_WILLNEED);
                 }
                 VERBOSE(VB_FILE, LOC +
                         QString("Seek to %1 from ignore pos %2 returned %3")
@@ -687,7 +683,6 @@ long long FileRingBuffer::Seek(long long
             else
             {
                 ret = lseek64(fd2, ignorereadpos, SEEK_SET);
-                posix_fadvise(fd2, ignorereadpos, 250000, POSIX_FADV_WILLNEED);
             }
 
             if (ret < 0)
@@ -752,17 +747,12 @@ long long FileRingBuffer::Seek(long long
     else
     {
         ret = lseek64(fd2, pos, whence);
-        if (ret >= 0)
-        {
-            posix_fadvise(fd2, 0,   ret,         POSIX_FADV_DONTNEED);
-            posix_fadvise(fd2, ret, 1*1024*1024, POSIX_FADV_WILLNEED);
-        }
     }
 
     if (ret >= 0)
     {
         readpos = ret;
-        
+
         ignorereadpos = -1;
 
         if (readaheadrunning)
diff -u -r -p mythtv.100/libs/libmythtv/ringbuffer.cpp mythtv/libs/libmythtv/ringbuffer.cpp
--- mythtv.100/libs/libmythtv/ringbuffer.cpp	2011-01-05 15:29:11.000000000 +0100
+++ mythtv/libs/libmythtv/ringbuffer.cpp	2011-01-07 16:03:31.915285749 +0100
@@ -783,8 +783,8 @@ void RingBuffer::run(void)
         {
             poslock.lockForWrite();
             rbwlock.lockForWrite();
+            off_t read_position = internalreadpos;
             internalreadpos += read_return;
-            off_t donotneed = internalreadpos;
             rbwpos = (rbwpos + read_return) % kBufferSize;
             VERBOSE(VB_FILE|VB_EXTRA,
                     LOC + QString("rbwpos += %1K requested %2K in read")
@@ -792,8 +792,10 @@ void RingBuffer::run(void)
             rbwlock.unlock();
             poslock.unlock();
 
-            if (fd2 >=0 && donotneed > 0)
-                posix_fadvise(fd2, 0, donotneed, POSIX_FADV_DONTNEED);
+            if (fd2 >=0)
+    	    {
+        	posix_fadvise(fd2, read_position, read_return, POSIX_FADV_DONTNEED);
+    	    }
         }
 
         int used = kBufferSize - ReadBufFree();
@@ -1017,7 +1019,6 @@ int RingBuffer::ReadDirect(void *buf, in
             else
             {
                 lseek64(fd2, old_pos, SEEK_SET);
-                posix_fadvise(fd2, old_pos, 1*1024*1024, POSIX_FADV_WILLNEED);
             }
         }
         else
@@ -1106,6 +1107,12 @@ int RingBuffer::ReadPriv(void *buf, int 
             VERBOSE(VB_FILE|VB_EXTRA, LOC + loc_desc +
                     QString(": ReadDirect checksum %1")
                     .arg(qChecksum((char*)buf,count)));
+
+            if (fd2 >=0 && ret > 0)
+	    {
+		posix_fadvise(fd2, rbrpos, ret, POSIX_FADV_DONTNEED);
+    	    }
+
             rwlock.unlock();
             return ret;
         }
diff -u -r -p mythtv.100/libs/libmythtv/ThreadedFileWriter.cpp mythtv/libs/libmythtv/ThreadedFileWriter.cpp
--- mythtv.100/libs/libmythtv/ThreadedFileWriter.cpp	2011-01-05 15:29:11.000000000 +0100
+++ mythtv/libs/libmythtv/ThreadedFileWriter.cpp	2011-01-07 14:25:43.398289920 +0100
@@ -217,11 +217,12 @@ ThreadedFileWriter::~ThreadedFileWriter(
         Flush();
         in_dtor = true; /* tells child thread to exit */
 
+        bufferHasData.wakeAll();
+        pthread_join(writer, NULL);
+
         bufferSyncWait.wakeAll();
         pthread_join(syncer, NULL);
 
-        bufferHasData.wakeAll();
-        pthread_join(writer, NULL);
         close(fd);
         fd = -1;
     }
@@ -385,11 +386,6 @@ void ThreadedFileWriter::Sync(void)
 {
     if (fd >= 0)
     {
-        /// Toss any data the kernel wrote to disk on it's own from
-        /// the cache, so we don't get penalized for preserving it
-        /// during the sync.
-        (void) posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
-
 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
         // fdatasync tries to avoid updating metadata, but will in
         // practice always update metadata if any data is written
@@ -398,10 +394,14 @@ void ThreadedFileWriter::Sync(void)
 #else
         fsync(fd);
 #endif
+	// Toss writen data from the page cache
+	buflock.lock();
+	off_t write_position = m_file_wpos;
+        buflock.unlock();
 
-        // Toss any data we just synced from cache, so we don't
-        // get penalized for it between now and the next sync.
-        (void) posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
+        posix_fadvise(fd, m_file_sync, write_position - m_file_sync,
+        		POSIX_FADV_DONTNEED);
+        m_file_sync = write_position;
     }
 }
 
