]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed blocking reads that were sometimes reading from random file offsets. take04
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 22 Feb 2011 23:13:13 +0000 (16:13 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 22 Feb 2011 23:13:13 +0000 (16:13 -0700)
Core "disk file" reading code assumed that if the globally stored disk.offset
matches the desired offset, there is no reason to seek. This was probably done
to reduce seek overhead between consecutive reads. Unfortunately, the disk
writing code did not know about that optimization and left F->disk.offset
unchanged after writing.

This may have worked OK for UFS if it never writes to the file it reads from,
but it does not work for store modules that do both kinds of I/O at different
offsets of the same disk file.

TODO: Implement this optimization correctly or remove disk.offset.

src/disk.cc

index beed745da1396bc45a3ff7ae0f2007ed9886e55d..967a870c68e84da91cb858f7e40a7b7bdfd678e5 100644 (file)
@@ -442,7 +442,11 @@ diskHandleRead(int fd, void *data)
 
     PROF_start(diskHandleRead);
 
+#if WRITES_MAINTAIN_DISK_OFFSET
     if (F->disk.offset != ctrl_dat->offset) {
+#else
+    {
+#endif
         debugs(6, 3, "diskHandleRead: FD " << fd << " seeking to offset " << ctrl_dat->offset);
         lseek(fd, ctrl_dat->offset, SEEK_SET); /* XXX ignore return? */
         statCounter.syscalls.disk.seeks++;