--------------------- PatchSet 1450 Date: 2001/01/31 05:49:37 Author: darius Branch: sfs Tag: (none) Log: Part-way through fixes for rebuilding from dir - committing in case Adrian gets to it before I'm back. Members: src/fs/sfs/sfs_interface.c:1.1.2.14->1.1.2.15 src/fs/sfs/sfs_llo.c:1.1.2.9->1.1.2.10 src/fs/sfs/store_dir_sfs.c:1.1.2.5->1.1.2.6 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.14 retrieving revision 1.1.2.15 diff -u -r1.1.2.14 -r1.1.2.15 --- squid/src/fs/sfs/sfs_interface.c 30 Jan 2001 14:35:20 -0000 1.1.2.14 +++ squid/src/fs/sfs/sfs_interface.c 31 Jan 2001 05:49:37 -0000 1.1.2.15 @@ -44,7 +44,9 @@ if (!(req = _sfs_create_requestor(sfsid,rt, io_type))) { return -1; } - cbdataLock(dataptr); + assert((io_type == _SFS_SYNC) || dataptr); + if (dataptr) + cbdataLock(dataptr); req->sfsinode = sfsinode; req->dataptr = dataptr; _sfs_submit_request(req); @@ -53,7 +55,8 @@ return 0; } _sfs_waitfor_request(req); - cbdataUnlock(dataptr); + if (dataptr) + cbdataUnlock(dataptr); ret = req->ret; _sfs_remove_request(req); return ret; @@ -68,7 +71,9 @@ if(!(req = _sfs_create_requestor(sfsfd >> 24, _SFS_OP_CLOSE, io_type))) return -1; - cbdataLock(dataptr); + assert((io_type == _SFS_SYNC) || dataptr); + if (dataptr) + cbdataLock(dataptr); req->sfsfd = sfsfd; req->dataptr = dataptr; _sfs_submit_request(req); @@ -76,7 +81,8 @@ return 0; } _sfs_waitfor_request(req); - cbdataUnlock(dataptr); + if (dataptr) + cbdataUnlock(dataptr); ret = req->ret; _sfs_remove_request(req); return ret; @@ -99,7 +105,9 @@ if(!(req = _sfs_create_requestor(sfsid, _SFS_OP_READ, io_type))) { return -1; } - cbdataLock(dataptr); + assert((io_type == _SFS_SYNC) || dataptr); + if (dataptr) + cbdataLock(dataptr); req->sfsfd = sfsfd; req->offset = -1; req->buflen = buflen; @@ -108,7 +116,8 @@ if (io_type != _SFS_IO_SYNC) return 0; _sfs_waitfor_request(req); - cbdataUnlock(dataptr); + if (dataptr) + cbdataUnlock(dataptr); if ((!buf) || (req->ret == 0)) return 0; if (req->ret < 0) @@ -134,10 +143,13 @@ if (!(req = _sfs_create_requestor(sfsid,_SFS_OP_WRITE, io_type))) { return -1; } - cbdataLock(dataptr); + assert((io_type == _SFS_SYNC) || dataptr); + if (dataptr) + cbdataLock(dataptr); req->sfsfd = sfsfd; if (!(req->buf = xstrdup(buf))) { - cbdataUnlock(dataptr); + if (dataptr) + cbdataUnlock(dataptr); return -1; } req->buflen = buflen; @@ -146,7 +158,8 @@ if (io_type != _SFS_IO_SYNC) return 0; _sfs_waitfor_request(req); - cbdataUnlock(dataptr); + if (dataptr) + cbdataUnlock(dataptr); ret = req->ret; if (req->buf) xfree(req->buf); @@ -168,14 +181,17 @@ if (!(req = _sfs_create_requestor(sfsid, _SFS_OP_UNLINK, io_type))) { return -1; } - cbdataLock(dataptr); + assert((io_type == _SFS_SYNC) || dataptr); + if (dataptr) + cbdataLock(dataptr); req->sfsinode = sfsinode; req->dataptr = dataptr; _sfs_submit_request(req); if (io_type != _SFS_IO_SYNC) return 0; _sfs_waitfor_request(req); - cbdataUnlock(dataptr); + if (dataptr) + cbdataUnlock(dataptr); ret = req->ret; _sfs_remove_request(req); return ret; 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.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid/src/fs/sfs/sfs_llo.c 31 Jan 2001 04:17:18 -0000 1.1.2.9 +++ squid/src/fs/sfs/sfs_llo.c 31 Jan 2001 05:49:37 -0000 1.1.2.10 @@ -369,6 +369,24 @@ pthread_exit(NULL); } +int +sfs_openNextInode(sfsid_t sfsid, sfsblock_t *cur) +{ + sfsblock_t i; + int found; + /* This function walks through a mounted filesystem, returning the + * next inode that's in-use. Used by rebuildDir stuff */ + for(i=*cur, found=0; i<_sfs_mounted[sfsid].rootblock->numfrags; i += 2) { + if (CBIT_TEST(_sfs_mounted[sfsid].mhb, i)) { + *cur = i; + /* Note, should make an sio, but I'm too lazy - SYNC doesn't + * _really_ need one... */ + return sfs_open(sfsid,i,0,_SFS_OP_OPEN_READ,_SFS_SYNC,NULL); + } + } + *cur = 0; +} + void sfs_do_open(sfs_requestor *req) { Index: squid/src/fs/sfs/store_dir_sfs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/sfs/Attic/store_dir_sfs.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/src/fs/sfs/store_dir_sfs.c 30 Jan 2001 14:35:20 -0000 1.1.2.5 +++ squid/src/fs/sfs/store_dir_sfs.c 31 Jan 2001 05:49:37 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_sfs.c,v 1.1.2.5 2001/01/30 14:35:20 darius Exp $ + * $Id: store_dir_sfs.c,v 1.1.2.6 2001/01/31 05:49:37 darius Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -355,15 +355,20 @@ assert(rb != NULL); debug(20, 3) ("storeSfsDirRebuildFromDirectory: DIR #%d\n", rb->sd->index); + sfsblock_t currentEntry; + sfsinfo_t *sfsinfo = rb->sd->fsdata; + /* We don't do anything right now */ storeRebuildComplete(&rb->counts); return; + currentEntry = 0; + for (count = 0; count < rb->speed; count++) { assert(fd == -1); - fd = storeSfsDirGetNextFile(rb, &sfileno, &size); + fd = sfs_openNextInode(sfsinfo->sfsid,¤tEntry); if (fd == -2) { - debug(20, 1) ("Done scanning %s swaplog (%d entries)\n", + debug(20, 1) ("Done scanning %s dir (%d entries)\n", rb->sd->path, rb->n_read); store_dirs_rebuilding--; storeSfsDirCloseTmpSwapLog(rb->sd); @@ -374,6 +379,9 @@ continue; } assert(fd > -1); + + /* XXX Darius up to here on converting this function */ + /* lets get file stats here */ if (fstat(fd, &sb) < 0) { debug(20, 1) ("storeSfsDirRebuildFromDirectory: fstat(FD %d): %s\n",