From: Alex Rousskov Date: Tue, 22 Feb 2011 23:13:13 +0000 (-0700) Subject: Fixed blocking reads that were sometimes reading from random file offsets. X-Git-Tag: take04 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=034b5ea4e50c77e0e390a4f379cc16b1ac5ab4d6;p=thirdparty%2Fsquid.git Fixed blocking reads that were sometimes reading from random file offsets. 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. --- diff --git a/src/disk.cc b/src/disk.cc index beed745da1..967a870c68 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -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++;