--------------------- PatchSet 337 Date: 2002/12/13 00:54:48 Author: rbcollins Branch: unify-io Tag: (none) Log: introduce canWrite() check Members: src/ufscommon.h:1.1.20.28->1.1.20.29 src/fs/aufs/store_asyncufs.h:1.2.12.31->1.2.12.32 src/fs/aufs/store_io_aufs.cc:1.3.12.31->1.3.12.32 Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.28 retrieving revision 1.1.20.29 diff -u -r1.1.20.28 -r1.1.20.29 --- squid3/src/ufscommon.h 12 Dec 2002 23:42:23 -0000 1.1.20.28 +++ squid3/src/ufscommon.h 13 Dec 2002 00:54:48 -0000 1.1.20.29 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.28 2002/12/12 23:42:23 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.29 2002/12/13 00:54:48 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -101,6 +101,7 @@ virtual void read(char *, off_t, size_t) = 0; virtual void write(char const *buf, size_t size, off_t offset, FREE *free_func) = 0; virtual bool canRead() const = 0; + virtual bool canWrite() const {return true;} /* During miogration only */ virtual int getFD() const {return -1;} virtual bool error() const = 0; @@ -166,6 +167,7 @@ link_list *pending_reads; link_list *pending_writes; void queueRead(char *, size_t, off_t, STRCB *, void *); + void queueWrite(char *, size_t, off_t, FREE *); bool kickReadQueue(); bool kickWriteQueue(); char *read_buf; Index: squid3/src/fs/aufs/store_asyncufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_asyncufs.h,v retrieving revision 1.2.12.31 retrieving revision 1.2.12.32 diff -u -r1.2.12.31 -r1.2.12.32 --- squid3/src/fs/aufs/store_asyncufs.h 12 Dec 2002 23:57:04 -0000 1.2.12.31 +++ squid3/src/fs/aufs/store_asyncufs.h 13 Dec 2002 00:54:49 -0000 1.2.12.32 @@ -98,6 +98,7 @@ virtual bool error() const; virtual int getFD() const { return fd;} virtual bool canRead() const; + virtual bool canWrite() const; private: #if ASYNC_READ static AIOCB ReadDone; @@ -136,9 +137,7 @@ void closeCompleted(); void readCompleted(const char *buf, int len, int errflag); void writeCompleted(int errflag, size_t len); - void writeDone(int fd, int errflag, size_t len); -void queueWrite(char *buf, size_t size, off_t offset, FREE * free_func); private: CBDATA_CLASS(squidaiostate_t); void openDone(); Index: squid3/src/fs/aufs/store_io_aufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_io_aufs.cc,v retrieving revision 1.3.12.31 retrieving revision 1.3.12.32 diff -u -r1.3.12.31 -r1.3.12.32 --- squid3/src/fs/aufs/store_io_aufs.cc 12 Dec 2002 23:57:04 -0000 1.3.12.31 +++ squid3/src/fs/aufs/store_io_aufs.cc 13 Dec 2002 00:54:49 -0000 1.3.12.32 @@ -269,9 +269,9 @@ } void -squidaiostate_t::queueWrite(char *buf, size_t size, off_t offset, FREE * free_func) +UFSStoreState::queueWrite(char *buf, size_t size, off_t offset, FREE * free_func) { - debug(79, 3) ("storeAufsWrite: queuing write\n"); + debug(79, 3) ("UFSStoreState::queueWrite: queuing write\n"); struct _queued_write *q; q = new _queued_write; q->buf = buf; @@ -281,20 +281,27 @@ linklistPush(&pending_writes, q); } +bool +AUFSFile::canWrite() const { + // TODO: when writes are inside AUFSFile, check for + // outstanding writes too + return fd > -1; +} + /* Write */ void squidaiostate_t::write(char *buf, size_t size, off_t offset, FREE * free_func) { debug(79, 3) ("storeAufsWrite: dirno %d, fileno %08X, FD %d\n", swap_dirn, swap_filen, fd); - if (fd < 0) { + if (!theFile->canWrite()) { /* disk file not opened yet */ - assert(creating); + assert(creating || writing); queueWrite(buf, size, offset, free_func); return; } #if ASYNC_WRITE - if (writing) { + if (!theFile->canWrite() || writing) { queueWrite(buf, size, offset, free_func); return; }