Write cache bugfix from Rasmus Borup Hansen, system adm. Email: rbh@math.ku.dk
authorJeremy Allison <jra@samba.org>
Thu, 3 Oct 2002 18:11:12 +0000 (18:11 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 3 Oct 2002 18:11:12 +0000 (18:11 +0000)
Jeremy.
(This used to be commit 971b82beb7b99a3ae692ca147cce9ce4b5bce39c)

source3/smbd/fileio.c

index 89f05092b45e140828175af2025300be6c358388..a29336d3a2f373ef5751c69002b2f4c970db0970 100644 (file)
@@ -440,6 +440,19 @@ len = %u\n",fsp->fd, (double)pos, (unsigned int)n, (double)wcp->offset, (unsigne
                        } else {
                                ssize_t ret = real_write_file(fsp, data, pos, n);
 
+                               /*
+                                * If the write overlaps the entire cache, then
+                                * discard the current contents of the cache.
+                                * Fix from Rasmus Borup Hansen rbh@math.ku.dk.
+                                */
+
+                               if ((pos <= wcp->offset) &&
+                                               (pos + n >= wcp->offset + wcp->data_size) ) {
+                                       DEBUG(9,("write_file: discarding overwritten write \
+cache: fd = %d, off=%.0f, size=%u\n", fsp->fd, (double)wcp->offset, (unsigned int)wcp->data_size ));
+                                       wcp->data_size = 0;
+                               }
+
                                DO_PROFILE_INC(writecache_direct_writes);
                                if (ret == -1)
                                        return ret;