bugs..

From: Michael O'Reilly <michael@dont-contact.us>
Date: 24 Feb 1998 15:12:06 +0800

Squid.1.2b15 + patches:

#1. disk.c: diskHandleWriteComplete
[ .. ]
    fd_bytes(fd, len, FD_WRITE);
    if (len < 0) {
        if (!ignoreErrno(errno)) {
            status = errno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR;
            debug(50, 1) ("diskHandleWrite: FD %d: disk write error: %s\n",
                fd, xstrerror());
            /*

All occurences of errno in that function should actually be 'errcode'
because with the async-IO, the errno is passed across from a different
thread.

#2. store.c: storeAbort
[ .. ]
#if USE_ASYNC_IO
    /* Need to cancel any pending ASYNC writes right now */
    if (mem->swapout.fd >= 0)
        aioCancel(mem->swapout.fd, NULL);
#endif
    /* but dont close if a disk write is queued, the handler will close up */
    if (mem->swapout.queue_offset > mem->swapout.done_offset)
        return;
    /* we do */
    storeSwapOutFileClose(e);
}

But disk.c:diskHandleWriteComplete() simply frees the write_q blocks
and returns without actually closing the file handle.

#3. Is a small patch to improve the AIO sanity. I'm still seeing:

grep diskHandleWriteComplete /var/log/s/cache.log
1998/02/23 20:17:31| diskHandleWriteComplete: q->buf_offset > q->len (0xec31228,410, 108, 410 FD 183)
1998/02/23 20:17:31| diskHandleWriteComplete: desc /w1/s/03/12/0000C907, type 2, open 1, flags 0x2
1998/02/23 20:34:49| diskHandleWriteComplete: q->buf_offset > q->len (0xc8fd940,132, 98, 132 FD 127)
1998/02/23 20:34:49| diskHandleWriteComplete: desc /w6/s/00/6A/0000351F, type 2, open 1, flags 0x2
1998/02/24 12:22:20| diskHandleWriteComplete: q->buf_offset > q->len (0x1216c8d8,864, 48, 864 FD 36)
1998/02/24 12:22:20| diskHandleWriteComplete: desc /w2/s/swap.state, type 2, open 1, flags 0x2

so I've added the patch below, which checks the make sure the write
request really does match the data passed back from the async IO
call.

note that I haven't actually rebooted with this patch yet, so
'provisional' is an understatement.

--- t/squid-1.2.beta15/src/disk.c Tue Feb 10 08:55:03 1998
+++ squid-1.2.beta15/src/disk.c Tue Feb 24 14:55:03 1998
@@ -262,6 +262,7 @@
     }
     ctrlp = xcalloc(1, sizeof(disk_ctrl_t));
     ctrlp->fd = fd;
+ ctrlp->data = fdd->write_q;
     assert(fdd->write_q != NULL);
     assert(fdd->write_q->len > fdd->write_q->buf_offset);
 #if USE_ASYNC_IO
@@ -285,10 +286,23 @@
     int fd = ctrlp->fd;
     fde *F = &fd_table[fd];
     struct _fde_disk *fdd = &F->disk;
- dwrite_q *q = fdd->write_q;
+ dwrite_q *q = fdd->write_q, *p;
     int status = DISK_OK;
     errno = errcode;

+ if (q && q != ctrlp->data) {
+ p = ctrlp->data;
+ debug(50,0) ("KARMA: q != data (%p, %p)\n", q, p);
+ debug(50,0) ("KARMA: (%d, %d, %d FD %d)\n",
+ q->buf_offset, q->len, len, fd);
+ debug(50,0) ("KARMA: desc %s, type %d, open %d, flags 0x%x\n",
+ F->desc, F->type, F->open, F->flags);
+
+ debug(50,0) ("KARMA: (%d, %d)\n", p->buf_offset, p->len);
+
+ len = -1;
+ errcode = EFAULT;
+ }
     safe_free(data);
     if (q == NULL) /* Someone aborted then write completed */
        return;
@@ -302,10 +316,12 @@
        } while ((q = fdd->write_q));
        return;
     }
Received on Tue Jul 29 2003 - 13:15:46 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:43 MST