--------------------- PatchSet 1418 Date: 2001/01/29 14:09:30 Author: darius Branch: sfs Tag: (none) Log: Fixes for the problem that was causing it to freeze up on ./squid -N - a thinko in terms of ordering for dealing with multiple requests at once. That throws the failure back up into the squid-sfs interface, which puts the ball back in Adrian's court ;) Meanwhile, I'm off to read the programmer's guide... Members: src/fs/sfs/sfs_interface.c:1.1.2.12->1.1.2.13 src/fs/sfs/sfs_llo.c:1.1.2.7->1.1.2.8 src/fs/sfs/sfs_util.c:1.1.2.10->1.1.2.11 Index: squid/src/fs/sfs/sfs_interface.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/sfs/Attic/sfs_interface.c,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -r1.1.2.12 -r1.1.2.13 --- squid/src/fs/sfs/sfs_interface.c 28 Jan 2001 18:48:48 -0000 1.1.2.12 +++ squid/src/fs/sfs/sfs_interface.c 29 Jan 2001 14:09:30 -0000 1.1.2.13 @@ -37,7 +37,7 @@ rt = _SFS_OP_OPEN_READ; /* If we're trying to open something that's not an inode, return. */ if (!(CBIT_TEST(_sfs_mounted[sfsid].ibm, sfsinode))) { - printf("DEBUG: sfs_open opening non-inode\n"); + printf("ERR: sfs_open opening non-inode\n"); return -1; } } @@ -45,12 +45,15 @@ return -1; req->sfsinode = sfsinode; req->dataptr = dataptr; + _sfs_print_request(req); _sfs_submit_request(req); - printf("DEBUG: open request submitted...\n"); + printf("DEBUG: open request submitted (req %p)\n",req); + _sfs_print_request(req); if (io_type != _SFS_IO_SYNC) return 0; _sfs_waitfor_request(req); - printf("DEBUG: response received\n"); + printf("DEBUG: response received (req %p)\n",req); + _sfs_print_request(req); ret = req->ret; _sfs_remove_request(req); return ret; @@ -134,7 +137,6 @@ req->buflen = buflen; req->dataptr = dataptr; _sfs_submit_request(req); - printf("DEBUG: sfs_write id=%d, fd=%d\n",sfsid,sfsfd); if (io_type != _SFS_IO_SYNC) return 0; _sfs_waitfor_request(req); @@ -259,7 +261,7 @@ if ((_sfs_mounted[i].fd = open(rawdevpath, O_RDWR)) < 0) return -1; if (lseek(_sfs_mounted[i].fd, (uint64_t)0, SEEK_SET) < (uint64_t)0) { - printf("Didn't manage to lseek in mount :(\n"); + printf("ERR: Didn't manage to lseek in mount :(\n"); close(_sfs_mounted[i].fd); return -1; } @@ -363,7 +365,6 @@ sfs_openfile_t *tmp; unsigned char sfsid; - printf("DEBUG: sfs_seek fd %d, offset %d\n", sfsfd, (int)pos); sfsid = sfsfd >> 24; pthread_mutex_lock(&(_sfs_mounted[sfsid].openfiles_lock)); tmp = _sfs_openfiles[sfsid]; Index: squid/src/fs/sfs/sfs_llo.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/sfs/Attic/sfs_llo.c,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid/src/fs/sfs/sfs_llo.c 27 Jan 2001 10:19:23 -0000 1.1.2.7 +++ squid/src/fs/sfs/sfs_llo.c 29 Jan 2001 14:09:30 -0000 1.1.2.8 @@ -77,11 +77,12 @@ i = 0; while (1) { pthread_cond_wait(&(mount_point->req_signal), &(mount_point->req_signal_lock)); - tnode = mount_point->request_queue.head; /* Should I lock the request queue while I cycle through these? * Probably wise, but slow... */ - while ((mount_point->pending_requests > 0) && (tnode != NULL)) { + while (mount_point->pending_requests > 0) { + tnode = mount_point->request_queue.head; + assert(tnode); req = tnode->data; if (req->request_state == _SFS_PENDING) { /* If we're not accepting requests, return fail for each @@ -119,6 +120,7 @@ } } } + printf("%p %p\n",tnode->prev,tnode->next); tnode = tnode->next; } /* Flush the bitmaps every 10 seconds */ Index: squid/src/fs/sfs/sfs_util.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/sfs/Attic/sfs_util.c,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid/src/fs/sfs/sfs_util.c 27 Jan 2001 10:20:44 -0000 1.1.2.10 +++ squid/src/fs/sfs/sfs_util.c 29 Jan 2001 14:09:30 -0000 1.1.2.11 @@ -13,7 +13,8 @@ { assert(req->io_type == _SFS_IO_SYNC); pthread_mutex_lock(&(req->done_signal_lock)); - pthread_cond_wait(&(req->done_signal),&(req->done_signal_lock)); + if (!(req->request_state == _SFS_DONE)) + pthread_cond_wait(&(req->done_signal),&(req->done_signal_lock)); pthread_mutex_unlock(&(req->done_signal_lock)); } @@ -107,7 +108,7 @@ pthread_cond_signal(&(_sfs_mounted[req->sfsid].req_signal)); pthread_mutex_unlock(&(_sfs_mounted[req->sfsid].req_signal_lock)); - printf("DEBUG: request %u submitted\n",req->sfsid); + printf("DEBUG: request %p submitted\n",req); return(0); } @@ -225,7 +226,6 @@ { sfs_blockbuf_t *new; sfs_blockbuf_t *old; - sfs_inode_t temp_inode; printf("DEBUG: sfsid = %d, diskpos = %d, buflen = %d\n",sfsid,diskpos,buflen); new = old = NULL; @@ -396,3 +396,11 @@ /* Change function to void? */ return (0); } + +/* This function prints out the contents of a request - debug function. */ +void +_sfs_print_request(sfs_requestor *req) { + printf(" fd %d: %d/%d - type %d, state %d, buflen %d\n", + req->sfsfd,req->sfsid,req->sfsinode,req->request_type, + req->request_state,req->buflen); +}