From: robertc <> Date: Fri, 11 Jul 2003 10:02:01 +0000 (+0000) Subject: Summary: Merge of projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1 X-Git-Tag: SQUID_3_0_PRE1~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e70dae3cf3d99f9b5e7347ebeb0aa1f50611267;p=thirdparty%2Fsquid.git Summary: Merge of projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1 Keywords: MergeOf: projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1 Patches applied: * projects@swelltech.com--private/squid--mem-to-disk--3.0--patch-1 Refactoring store_client. * projects@swelltech.com--private/squid--mem-to-disk--3.0--base-0 tag of projects@swelltech.com--private/squid--ign--3.0--patch-76 * extract disk read scheduling from store_client::doCopy. * Ditto for mem scheduling. * Extract choice of memory or disk reads from store_client::doCopy. * Extract logic surrounding disk opens from store_client::doCopy. --- diff --git a/src/StoreClient.h b/src/StoreClient.h index c63cf98130..4c9636acf3 100644 --- a/src/StoreClient.h +++ b/src/StoreClient.h @@ -1,6 +1,6 @@ /* - * $Id: StoreClient.h,v 1.9 2003/02/21 22:50:06 robertc Exp $ + * $Id: StoreClient.h,v 1.10 2003/07/11 04:02:01 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -110,6 +110,10 @@ private: static MemPool *pool; void fileRead(); + void scheduleDiskRead(); + void scheduleMemRead(); + void scheduleRead(); + void startSwapin(); void unpackHeader(char const *buf, ssize_t len); int type; diff --git a/src/store_client.cc b/src/store_client.cc index bef8d15223..0120e15696 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.129 2003/07/11 01:40:37 robertc Exp $ + * $Id: store_client.cc,v 1.130 2003/07/11 04:02:01 robertc Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -368,47 +368,61 @@ store_client::doCopy(StoreEntry *anEntry) * if needed. */ - if (STORE_DISK_CLIENT == getType() && NULL == swapin_sio.getRaw()) { - debug(90, 3)("store_client::doCopy: Need to open swap in file\n"); - /* gotta open the swapin file */ + if (STORE_DISK_CLIENT == getType() && NULL == swapin_sio.getRaw()) + startSwapin(); + else + scheduleRead(); +} - if (storeTooManyDiskFilesOpen()) { - /* yuck -- this causes a TCP_SWAPFAIL_MISS on the client side */ - fail(); - flags.store_copying = 0; - return; - } else if (!flags.disk_io_pending) { - /* Don't set store_io_pending here */ - storeSwapInStart(this); - - if (NULL == swapin_sio.getRaw()) { - fail(); - flags.store_copying = 0; - return; - } +void +store_client::startSwapin() +{ + debug(90, 3)("store_client::doCopy: Need to open swap in file\n"); + /* gotta open the swapin file */ + + if (storeTooManyDiskFilesOpen()) { + /* yuck -- this causes a TCP_SWAPFAIL_MISS on the client side */ + fail(); + flags.store_copying = 0; + return; + } else if (!flags.disk_io_pending) { + /* Don't set store_io_pending here */ + storeSwapInStart(this); - /* - * If the open succeeds we either copy from memory, or - * schedule a disk read in the next block. - */ - } else { - debug (90, 1)("WARNING: Averted multiple fd operation (1)\n"); + if (NULL == swapin_sio.getRaw()) { + fail(); flags.store_copying = 0; return; } - } - if (copyInto.offset >= mem->inmem_lo && copyInto.offset < mem->endOffset()) { - /* What the client wants is in memory */ - /* Old style */ - debug(90, 3)("store_client::doCopy: Copying normal from memory\n"); - size_t sz = mem->data_hdr.copy(copyInto.offset, copyInto.data, - copyInto.length); - callback(sz); + /* + * If the open succeeds we either copy from memory, or + * schedule a disk read in the next block. + */ + scheduleRead(); + + return; + } else { + debug (90, 1)("WARNING: Averted multiple fd operation (1)\n"); flags.store_copying = 0; return; } +} + +void +store_client::scheduleRead() +{ + MemObject *mem = entry->mem_obj; + + if (copyInto.offset >= mem->inmem_lo && copyInto.offset < mem->endOffset()) + scheduleMemRead(); + else + scheduleDiskRead(); +} +void +store_client::scheduleDiskRead() +{ /* What the client wants is not in memory. Schedule a disk read */ assert(STORE_DISK_CLIENT == getType()); @@ -421,6 +435,19 @@ store_client::doCopy(StoreEntry *anEntry) flags.store_copying = 0; } +void +store_client::scheduleMemRead() +{ + /* What the client wants is in memory */ + /* Old style */ + debug(90, 3)("store_client::doCopy: Copying normal from memory\n"); + MemObject *mem = entry->mem_obj; + size_t sz = mem->data_hdr.copy(copyInto.offset, copyInto.data, + copyInto.length); + callback(sz); + flags.store_copying = 0; +} + void store_client::fileRead() { diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 943901a20f..0b6626783d 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.cc,v 1.95 2003/06/26 12:51:58 robertc Exp $ + * $Id: store_swapout.cc,v 1.96 2003/07/11 04:02:01 robertc Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -377,6 +377,8 @@ storeSwapOutAble(const StoreEntry * e) * even if its not cachable * RBC: Surely we should not create disk client on non cacheable objects? * therefore this should be an assert? + * RBC 20030708: We can use disk to avoid mem races, so this shouldn't be + * an assert. */ for (node = e->mem_obj->clients.head; node; node = node->next) { if (((store_client *) node->data)->getType() == STORE_DISK_CLIENT)