--------------------- PatchSet 332 Date: 2002/12/12 11:39:15 Author: rbcollins Branch: unify-io Tag: (none) Log: remove FD from ufsstate, and make common write() method Members: src/ufscommon.h:1.1.20.25->1.1.20.26 src/fs/diskd/store_diskd.h:1.1.20.32->1.1.20.33 src/fs/diskd/store_io_diskd.cc:1.1.20.38->1.1.20.39 src/fs/ufs/store_io_ufs.cc:1.3.10.35->1.3.10.36 src/fs/ufs/store_ufs.h:1.1.20.23->1.1.20.24 Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.25 retrieving revision 1.1.20.26 diff -u -r1.1.20.25 -r1.1.20.26 --- squid3/src/ufscommon.h 12 Dec 2002 10:37:01 -0000 1.1.20.25 +++ squid3/src/ufscommon.h 12 Dec 2002 11:39:15 -0000 1.1.20.26 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.25 2002/12/12 10:37:01 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.26 2002/12/12 11:39:15 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -138,7 +138,7 @@ bool reading; bool writing; void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data); - void write(char *buf, size_t size, off_t offset, FREE * free_func) = 0; + void write(char *buf, size_t size, off_t offset, FREE * free_func); protected: class _queued_read { public: Index: squid3/src/fs/diskd/store_diskd.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_diskd.h,v retrieving revision 1.1.20.32 retrieving revision 1.1.20.33 diff -u -r1.1.20.32 -r1.1.20.33 --- squid3/src/fs/diskd/store_diskd.h 12 Dec 2002 11:02:32 -0000 1.1.20.32 +++ squid3/src/fs/diskd/store_diskd.h 12 Dec 2002 11:39:15 -0000 1.1.20.33 @@ -77,7 +77,6 @@ void readCompleted(const char *buf, int len, int errflag); void writeCompleted(int errflag, size_t len); void closeCompleted(); - void write(char *buf, size_t size, off_t offset, FREE * free_func); private: CBDATA_CLASS(diskdstate_t); }; Index: squid3/src/fs/diskd/store_io_diskd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_io_diskd.cc,v retrieving revision 1.1.20.38 retrieving revision 1.1.20.39 diff -u -r1.1.20.38 -r1.1.20.39 --- squid3/src/fs/diskd/store_io_diskd.cc 12 Dec 2002 11:02:32 -0000 1.1.20.38 +++ squid3/src/fs/diskd/store_io_diskd.cc 12 Dec 2002 11:39:15 -0000 1.1.20.39 @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.1.20.38 2002/12/12 11:02:32 rbcollins Exp $ + * $Id: store_io_diskd.cc,v 1.1.20.39 2002/12/12 11:39:15 rbcollins Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -511,15 +511,6 @@ } void -diskdstate_t::write(char *buf, size_t size, off_t offset, FREE * free_func) -{ - debug(79, 3) ("storeDiskdWrite: dirno %d, fileno %08X\n", swap_dirn, swap_filen); - assert(!closing); - writing = true; - theFile->write(buf,size,offset,free_func); -} - -void storeDiskdUnlink(SwapDir * SD, StoreEntry * e) { int x; Index: squid3/src/fs/ufs/store_io_ufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/store_io_ufs.cc,v retrieving revision 1.3.10.35 retrieving revision 1.3.10.36 diff -u -r1.3.10.35 -r1.3.10.36 --- squid3/src/fs/ufs/store_io_ufs.cc 12 Dec 2002 10:37:03 -0000 1.3.10.35 +++ squid3/src/fs/ufs/store_io_ufs.cc 12 Dec 2002 11:39:15 -0000 1.3.10.36 @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.3.10.35 2002/12/12 10:37:03 rbcollins Exp $ + * $Id: store_io_ufs.cc,v 1.3.10.36 2002/12/12 11:39:15 rbcollins Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -40,7 +40,6 @@ #include "SwapDir.h" -static DWCB storeUfsWriteDone; static void storeUfsIOCallback(storeIOState * sio, int errflag); /* === PUBLIC =========================================================== */ @@ -198,20 +197,11 @@ { if (opening) { opening = false; - fd = theFile->getFD(); /* There is no 'opened' callback */ -#if 0 - /* We are not allowed to callback synchronously. We have to return NULL - * if a sync failure occured - */ - if (fd < 0) - storeUfsIOCallback (this, -1); -#endif return; } if (creating) { creating = false; - fd = theFile->getFD(); return; } assert(0); @@ -245,8 +235,8 @@ { ufsstate_t *ufsstate = dynamic_cast(sio); - debug(79, 3) ("storeUfsClose: dirno %d, fileno %08X, FD %d\n", - sio->swap_dirn, sio->swap_filen, ufsstate->fd); + debug(79, 3) ("storeUfsClose: dirno %d, fileno %08X\n", + sio->swap_dirn, sio->swap_filen); ufsstate->closing = true; if (ufsstate->reading || ufsstate->writing) { ((UFSFile *)ufsstate->theFile.getRaw())->close(); @@ -295,24 +285,26 @@ void UFSFile::write(char const *buf, size_t size, off_t offset, FREE *free_func) { - assert (0); -} - -void -ufsstate_t::write(char *buf, size_t size, off_t offset, FREE * free_func) -{ - debug(79, 3) ("storeUfsWrite: dirn %d, fileno %08X, FD %d\n", swap_dirn, swap_filen, fd); - writing = true; + debug(79, 3) ("storeUfsWrite: FD %d\n",fd); file_write(fd, offset, - buf, + (char *)buf, size, - storeUfsWriteDone, + WriteDone, this, free_func); } void +UFSStoreState::write(char *buf, size_t size, off_t offset, FREE * free_func) +{ + debug(79, 3) ("UFSStoreState::write: dirn %d, fileno %08X\n", swap_dirn, swap_filen); + writing = true; + assert (!closing); + theFile->write(buf,size,offset,free_func); +} + +void storeUfsUnlink(SwapDir * SD, StoreEntry * e) { debug(79, 3) ("storeUfsUnlink: fileno %08X\n", e->swap_filen); @@ -364,27 +356,39 @@ } void -ufsstate_t::writeCompleted(int errflag, size_t len) +UFSFile::WriteDone (int fd, int errflag, size_t len, void *me) { - assert (0); + UFSFile *aFile = static_cast(me); + aFile->writeDone (fd, errflag, len); } -static void -storeUfsWriteDone(int fd, int errflag, size_t len, void *my_data) +void +UFSFile::writeDone(int rvfd, int errflag, size_t len) { - storeIOState *sio = (storeIOState *)my_data; - ufsstate_t *ufsstate = dynamic_cast(sio); - debug(79, 3) ("storeUfsWriteDone: dirno %d, fileno %08X, FD %d, len %ld\n", - sio->swap_dirn, sio->swap_filen, fd, (long int) len); - ufsstate->writing = false; + assert (rvfd == fd); + debug(79, 3) ("storeUfsWriteDone: FD %d, len %ld\n", + fd, (long int) len); if (errflag) { debug(79, 0) ("storeUfsWriteDone: got failure (%d)\n", errflag); - storeUfsIOCallback(sio, errflag); + doClose(); + ioRequestor->writeCompleted (DISK_ERROR,0); return; } - sio->offset_ += len; - if (ufsstate->closing) - ((UFSFile *)ufsstate->theFile.getRaw())->close(); + ioRequestor->writeCompleted(DISK_OK, len); +} + +void +ufsstate_t::writeCompleted(int errflag, size_t len) +{ + assert (0); + debug(79, 3) ("storeUfsWriteDone: dirno %d, fileno %08X, len %ld\n", + swap_dirn, swap_filen, (long int) len); + writing = false; + if (theFile->error()) + storeUfsIOCallback (this, DISK_ERROR); + offset_ += len; + if (closing) + ((UFSFile *)theFile.getRaw())->close(); } static void Index: squid3/src/fs/ufs/store_ufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/Attic/store_ufs.h,v retrieving revision 1.1.20.23 retrieving revision 1.1.20.24 diff -u -r1.1.20.23 -r1.1.20.24 --- squid3/src/fs/ufs/store_ufs.h 12 Dec 2002 10:37:03 -0000 1.1.20.23 +++ squid3/src/fs/ufs/store_ufs.h 12 Dec 2002 11:39:15 -0000 1.1.20.24 @@ -25,12 +25,14 @@ virtual bool canRead() const; private: static DRCB ReadDone; + static DWCB WriteDone; CBDATA_CLASS(UFSFile); int fd; char const *path_; IORequestor::Pointer ioRequestor; void doClose(); void readDone(int fd, const char *buf, int len, int errflag); + void writeDone(int fd, int errflag, size_t len); }; class ufsstate_t : public UFSStoreState { @@ -40,8 +42,6 @@ void operator delete (void *); ufsstate_t(SwapDir *SD, StoreEntry *e, STIOCB * callback, void *callback_data); ~ufsstate_t(); - int fd; - void write(char *buf, size_t size, off_t offset, FREE * free_func); void ioCompletedNotification(); void readCompleted(const char *buf, int len, int errflag); void writeCompleted(int errflag, size_t len);