From 0b8be48baf5750ba2cb723deb037de44bbf4c385 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Wed, 29 May 2013 10:24:49 -0600 Subject: [PATCH] Made some of the Rock collapsing behavior dependent on collapsed_forwarding. Do not write empty rock I/O buffer to disk. Added more comments and polished. --- src/fs/rock/RockIoState.cc | 8 ++++++-- src/fs/rock/RockIoState.h | 2 +- src/fs/rock/RockSwapDir.cc | 6 ++++-- src/ipc/Messages.h | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/fs/rock/RockIoState.cc b/src/fs/rock/RockIoState.cc index f8e461eb83..c7ed4722c5 100644 --- a/src/fs/rock/RockIoState.cc +++ b/src/fs/rock/RockIoState.cc @@ -175,11 +175,14 @@ Rock::IoState::tryWrite(char const *buf, size_t size, off_t coreOff) const SlotId sidNext = reserveSlotForWriting(); // throws assert(sidNext >= 0); writeToDisk(sidNext); + } else if (Config.onoff.collapsed_forwarding) { + // write partial buffer for all collapsed hit readers to see + // XXX: can we check that this is needed w/o stalling readers + // that appear right after our check? + writeBufToDisk(false); } } - // XXX: check that there are workers waiting for data, i.e. readers > 0 - writeBufToDisk(); } /// Buffers incoming data for the current slot. @@ -242,6 +245,7 @@ Rock::IoState::writeToDisk(const SlotId sidNext) sidCurrent = sidNext; } +/// Write header-less (XXX) or complete buffer to disk. void Rock::IoState::writeBufToDisk(const bool last) { diff --git a/src/fs/rock/RockIoState.h b/src/fs/rock/RockIoState.h index ee6f6a3dfc..f22a736e0a 100644 --- a/src/fs/rock/RockIoState.h +++ b/src/fs/rock/RockIoState.h @@ -50,7 +50,7 @@ private: void tryWrite(char const *buf, size_t size, off_t offset); size_t writeToBuffer(char const *buf, size_t size); void writeToDisk(const SlotId nextSlot); - void writeBufToDisk(const bool last = false); + void writeBufToDisk(const bool last); SlotId reserveSlotForWriting(); void callBack(int errflag); diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 5b08b23839..a732232fd7 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -748,8 +748,10 @@ Rock::SwapDir::writeCompleted(int errflag, size_t rlen, RefCount< ::WriteRequest return; } - // XXX: check that there are workers waiting for data, i.e. readers > 0 - CollapsedForwarding::NewData(sio); + // XXX: can we check that this is needed w/o stalling readers + // that appear right after our check? + if (Config.onoff.collapsed_forwarding) + CollapsedForwarding::NewData(sio); if (errflag == DISK_OK) { // do not increment sio.offset_ because we do it in sio->write() diff --git a/src/ipc/Messages.h b/src/ipc/Messages.h index 14837ff81b..e7e8d07f9b 100644 --- a/src/ipc/Messages.h +++ b/src/ipc/Messages.h @@ -15,7 +15,8 @@ namespace Ipc typedef enum { mtNone = 0, mtRegistration, mtStrandSearchRequest, mtStrandSearchResponse, mtSharedListenRequest, mtSharedListenResponse, - mtIpcIoNotification, mtCollapsedForwardingNotification, + mtIpcIoNotification, + mtCollapsedForwardingNotification, mtCacheMgrRequest, mtCacheMgrResponse #if SQUID_SNMP , -- 2.39.5