#include <IpcIoFile.h>
Public Types | |
typedef RefCount< IpcIoFile > | Pointer |
Public Member Functions | |
IpcIoFile (char const *aDb) | |
~IpcIoFile () override | |
void | configure (const Config &cfg) override |
notes supported configuration options; kids must call this first More... | |
void | open (int flags, mode_t mode, RefCount< IORequestor > callback) override |
void | create (int flags, mode_t mode, RefCount< IORequestor > callback) override |
void | read (ReadRequest *) override |
void | write (WriteRequest *) override |
void | close () override |
bool | error () const override |
int | getFD () const override |
bool | canRead () const override |
bool | canWrite () const override |
bool | ioInProgress () const override |
Static Public Member Functions | |
static void | HandleOpenResponse (const Ipc::StrandMessage &) |
handle open response from coordinator More... | |
static void | HandleNotification (const Ipc::TypedMsgHdr &msg) |
handle queue push notifications from worker or disker More... | |
static void | StatQueue (std::ostream &) |
prints IPC message queue state; suitable for cache manager reports More... | |
Public Attributes | |
DiskFile::Config | config |
supported configuration options More... | |
Protected Member Functions | |
void | openCompleted (const Ipc::StrandMessage *) |
void | readCompleted (ReadRequest *readRequest, IpcIoMsg *const response) |
void | writeCompleted (WriteRequest *writeRequest, const IpcIoMsg *const response) |
bool | canWait () const |
whether we think there is enough time to complete the I/O More... | |
Private Types | |
typedef std::map< unsigned int, IpcIoPendingRequest * > | RequestMap |
maps requestId to the handleResponse callback More... | |
typedef std::list< Pointer > | IpcIoFileList |
typedef std::map< int, IpcIoFile * > | IpcIoFilesMap |
typedef Ipc::FewToFewBiQueue | Queue |
Private Member Functions | |
CBDATA_CLASS (IpcIoFile) | |
void | trackPendingRequest (const unsigned int id, IpcIoPendingRequest *const pending) |
track a new pending request More... | |
void | push (IpcIoPendingRequest *const pending) |
push an I/O request to disker More... | |
IpcIoPendingRequest * | dequeueRequest (const unsigned int requestId) |
returns and forgets the right IpcIoFile pending request More... | |
size_t | pendingRequests () const |
void | checkTimeouts () |
void | scheduleTimeoutCheck () |
prepare to check for timeouts in a little while More... | |
void | handleResponse (IpcIoMsg &ipcIo) |
Static Private Member Functions | |
static void | Notify (const int peerId) |
static void | OpenTimeout (void *const param) |
handles open request timeout More... | |
static void | CheckTimeouts (void *const param) |
IpcIoFile::checkTimeouts wrapper. More... | |
static void | HandleResponses (const char *const when) |
static void | DiskerHandleMoreRequests (void *) |
static void | DiskerHandleRequests () |
static void | DiskerHandleRequest (const int workerId, IpcIoMsg &ipcIo) |
called when disker receives an I/O request More... | |
static bool | WaitBeforePop () |
static void | HandleMessagesAtStart () |
Private Attributes | |
const String | dbName |
the name of the file we are managing More... | |
const pid_t | myPid |
optimization: cached process ID of our process More... | |
int | diskId |
the kid ID of the disker we talk to More... | |
RefCount< IORequestor > | ioRequestor |
bool | error_ |
whether we have seen at least one I/O error (XXX) More... | |
unsigned int | lastRequestId |
last requestId used More... | |
RequestMap | requestMap1 |
older (or newer) pending requests More... | |
RequestMap | requestMap2 |
newer (or older) pending requests More... | |
RequestMap * | olderRequests |
older requests (map1 or map2) More... | |
RequestMap * | newerRequests |
newer requests (map2 or map1) More... | |
bool | timeoutCheckScheduled |
we expect a CheckTimeouts() call More... | |
Static Private Attributes | |
static const double | Timeout = 7 |
timeout value in seconds More... | |
static IpcIoFileList | WaitingForOpen |
pending open requests More... | |
static IpcIoFilesMap | IpcIoFiles |
static std::unique_ptr< Queue > | queue |
IPC queue. More... | |
static bool | DiskerHandleMoreRequestsScheduled = false |
whether we are waiting for an event to handle still queued I/O requests More... | |
Friends | |
class | IpcIoPendingRequest |
Detailed Description
In a worker process, represents a single (remote) cache_dir disker file. In a disker process, used as a bunch of static methods handling that file.
Definition at line 66 of file IpcIoFile.h.
Member Typedef Documentation
◆ IpcIoFileList
|
private |
Definition at line 153 of file IpcIoFile.h.
◆ IpcIoFilesMap
|
private |
Definition at line 157 of file IpcIoFile.h.
◆ Pointer
typedef RefCount<IpcIoFile> IpcIoFile::Pointer |
Definition at line 71 of file IpcIoFile.h.
◆ Queue
|
private |
Definition at line 160 of file IpcIoFile.h.
◆ RequestMap
|
private |
Definition at line 144 of file IpcIoFile.h.
Constructor & Destructor Documentation
◆ IpcIoFile()
IpcIoFile::IpcIoFile | ( | char const * | aDb | ) |
Definition at line 95 of file IpcIoFile.cc.
◆ ~IpcIoFile()
|
override |
Definition at line 107 of file IpcIoFile.cc.
References diskId, IpcIoFiles, Must, and SWALLOW_EXCEPTIONS.
Member Function Documentation
◆ canRead()
|
overridevirtual |
◆ canWait()
|
protected |
Definition at line 421 of file IpcIoFile.cc.
References config, current_time, debugs, diskId, DiskFile::Config::ioTimeout, KidIdentifier, max(), queue, IpcIoMsg::start, and tvSubMsec().
Referenced by canRead(), and canWrite().
◆ canWrite()
|
overridevirtual |
◆ CBDATA_CLASS()
|
private |
◆ checkTimeouts()
|
private |
Definition at line 587 of file IpcIoFile.cc.
References CallBack(), IpcIoPendingRequest::codeContext, DBG_IMPORTANT, dbName, debugs, HandleResponses(), newerRequests, olderRequests, scheduleTimeoutCheck(), Timeout, and timeoutCheckScheduled.
◆ CheckTimeouts()
|
staticprivate |
Definition at line 576 of file IpcIoFile.cc.
References debugs, diskId, IpcIoFiles, and Must.
Referenced by scheduleTimeoutCheck().
◆ close()
|
overridevirtual |
Implements DiskFile.
Definition at line 206 of file IpcIoFile.cc.
References assert, IORequestor::closeCompleted(), dbName, DiskerClose(), IamDiskProcess(), ioRequestor, and String::termedBuf().
◆ configure()
|
overridevirtual |
Reimplemented from DiskFile.
Definition at line 120 of file IpcIoFile.cc.
References config, and DiskFile::configure().
◆ create()
|
overridevirtual |
◆ dequeueRequest()
|
private |
Definition at line 644 of file IpcIoFile.cc.
References Must, requestMap1, and requestMap2.
Referenced by handleResponse().
◆ DiskerHandleMoreRequests()
|
staticprivate |
Definition at line 826 of file IpcIoFile.cc.
References debugs, DiskerHandleMoreRequestsScheduled, and DiskerHandleRequests().
Referenced by DiskerHandleRequests(), and WaitBeforePop().
◆ DiskerHandleRequest()
Definition at line 939 of file IpcIoFile.cc.
References assert, IpcIo::cmdRead, IpcIo::cmdWrite, IpcIoMsg::command, DBG_CRITICAL, DBG_IMPORTANT, DbName, debugs, diskerRead(), diskerWrite(), KidIdentifier, IpcIoMsg::len, Notify(), IpcIoMsg::offset, queue, IpcIoMsg::requestId, and IpcIoMsg::workerPid.
Referenced by DiskerHandleRequests().
◆ DiskerHandleRequests()
|
staticprivate |
Definition at line 896 of file IpcIoFile.cc.
References current_time, debugs, DiskerHandleMoreRequests(), DiskerHandleMoreRequestsScheduled, DiskerHandleRequest(), eventAdd(), getCurrentTime(), queue, tvSubMsec(), and WaitBeforePop().
Referenced by DiskerHandleMoreRequests(), HandleMessagesAtStart(), and HandleNotification().
◆ error()
|
overridevirtual |
◆ getFD()
|
overridevirtual |
During migration only
Reimplemented from DiskFile.
Definition at line 668 of file IpcIoFile.cc.
References assert.
◆ HandleMessagesAtStart()
|
staticprivate |
Handle queued IPC messages for the first time in this process lifetime, when the queue may be reflecting the state of our killed predecessor.
- See also
- CollapsedForwarding::HandleNewDataAtStart() – duplicates this logic
Definition at line 537 of file IpcIoFile.cc.
References DiskerHandleRequests(), HandleResponses(), IamDiskProcess(), and queue.
Referenced by open().
◆ HandleNotification()
|
static |
Definition at line 524 of file IpcIoFile.cc.
References debugs, DiskerHandleRequests(), Ipc::TypedMsgHdr::getInt(), HandleResponses(), IamDiskProcess(), and queue.
Referenced by Ipc::Strand::receive().
◆ HandleOpenResponse()
|
static |
called when coordinator responds to worker open request
Definition at line 456 of file IpcIoFile.cc.
References debugs, Ipc::StrandMessage::strand, Ipc::StrandCoord::tag, and WaitingForOpen.
Referenced by Ipc::Strand::receive().
◆ handleResponse()
|
private |
Definition at line 491 of file IpcIoFile.cc.
References CallBack(), debugs, dequeueRequest(), diskId, KidIdentifier, Must, and IpcIoMsg::requestId.
◆ HandleResponses()
|
staticprivate |
Definition at line 474 of file IpcIoFile.cc.
References debugs, diskId, IpcIoFiles, KidIdentifier, and queue.
Referenced by checkTimeouts(), HandleMessagesAtStart(), HandleNotification(), and push().
◆ ioInProgress()
|
overridevirtual |
Inform callers if there is IO in progress
Implements DiskFile.
Definition at line 338 of file IpcIoFile.cc.
References newerRequests, and olderRequests.
◆ Notify()
|
staticprivate |
Definition at line 512 of file IpcIoFile.cc.
References debugs, KidIdentifier, Ipc::Port::MakeAddr(), Ipc::mtIpcIoNotification, Ipc::TypedMsgHdr::putInt(), Ipc::SendMessage(), Ipc::TypedMsgHdr::setType(), and Ipc::strandAddrLabel.
Referenced by DiskerHandleRequest(), and push().
◆ open()
|
overridevirtual |
Implements DiskFile.
Definition at line 127 of file IpcIoFile.cc.
References asyncCall(), config, Ipc::Port::CoordinatorAddr(), dbName, DiskerOpen(), diskId, error_, eventAdd(), Ipc::FewToFewBiQueue::groupA, Ipc::FewToFewBiQueue::groupB, HandleMessagesAtStart(), IamDiskProcess(), IamWorkerProcess(), IORequestor::ioCompletedNotification(), DiskFile::Config::ioRate, ioRequestor, IpcIoFiles, KidIdentifier, Ipc::mtRegisterStrand, Must, Ipc::StrandMessage::NotifyCoordinator(), OpenTimeout(), Ipc::StrandSearchRequest::pack(), queue, ScheduleCallHere, Ipc::SendMessage(), ShmLabel, String::termedBuf(), Timeout, and WaitingForOpen.
Referenced by create().
◆ openCompleted()
|
protected |
Definition at line 169 of file IpcIoFile.cc.
References DBG_IMPORTANT, dbName, debugs, diskId, error_, IORequestor::ioCompletedNotification(), ioRequestor, IpcIoFiles, Ipc::StrandCoord::kidId, Must, and Ipc::StrandMessage::strand.
Referenced by OpenTimeout().
◆ OpenTimeout()
|
staticprivate |
Definition at line 558 of file IpcIoFile.cc.
References Must, openCompleted(), and WaitingForOpen.
Referenced by open().
◆ pendingRequests()
|
inlineprivate |
the total number of I/O requests in push queue and pop queue (but no, the implementation does not add push and pop queue sizes)
Definition at line 114 of file IpcIoFile.h.
References newerRequests, and olderRequests.
Referenced by push().
◆ push()
|
private |
Definition at line 356 of file IpcIoFile.cc.
References WriteRequest::buf, CallService(), IpcIo::cmdRead, IpcIo::cmdWrite, IpcIoMsg::command, IpcIoPendingRequest::completeIo(), current_time, DBG_IMPORTANT, dbName, debugs, diskId, Ipc::Mem::GetPage(), HandleResponses(), Ipc::Mem::PageId::ioPage, KidIdentifier, lastRequestId, IpcIoMsg::len, ReadRequest::len, WriteRequest::len, Must, MYNAME, myPid, Notify(), IpcIoMsg::offset, ReadRequest::offset, WriteRequest::offset, IpcIoMsg::page, Ipc::Mem::PagePointer(), Ipc::Mem::PageSize(), pendingRequests(), Ipc::Mem::PutPage(), queue, QueueCapacity, IpcIoPendingRequest::readRequest, IpcIoMsg::requestId, IpcIoMsg::start, TexcHere, trackPendingRequest(), TextException::what(), IpcIoMsg::workerPid, and IpcIoPendingRequest::writeRequest.
◆ read()
|
overridevirtual |
Implements DiskFile.
Definition at line 236 of file IpcIoFile.cc.
References assert, debugs, diskId, error_, ioRequestor, IpcIoPendingRequest, ReadRequest::len, Must, ReadRequest::offset, push(), and IpcIoPendingRequest::readRequest.
◆ readCompleted()
|
protected |
Definition at line 254 of file IpcIoFile.cc.
References ReadRequest::buf, DBG_IMPORTANT, dbName, debugs, DISK_ERROR, DISK_OK, error_, ioRequestor, IpcIoMsg::len, ReadRequest::len, IpcIoMsg::page, Ipc::Mem::PagePointer(), Ipc::Mem::PutPage(), IORequestor::readCompleted(), IpcIoMsg::xerrno, and xstrerr().
◆ scheduleTimeoutCheck()
|
private |
Definition at line 630 of file IpcIoFile.cc.
References CallService(), CheckTimeouts(), diskId, eventAdd(), Timeout, and timeoutCheckScheduled.
Referenced by checkTimeouts(), and trackPendingRequest().
◆ StatQueue()
|
static |
◆ trackPendingRequest()
|
private |
Definition at line 345 of file IpcIoFile.cc.
References Must, newerRequests, scheduleTimeoutCheck(), and timeoutCheckScheduled.
Referenced by push().
◆ WaitBeforePop()
|
staticprivate |
Definition at line 835 of file IpcIoFile.cc.
References IpcIo::cmdWrite, IpcIoMsg::command, current_time, DBG_IMPORTANT, DbName, debugs, DiskerHandleMoreRequests(), DiskerHandleMoreRequestsScheduled, eventAdd(), min(), queue, Timeout, and tvSubMsec().
Referenced by DiskerHandleRequests().
◆ write()
|
overridevirtual |
Implements DiskFile.
Definition at line 284 of file IpcIoFile.cc.
References assert, debugs, diskId, error_, ioRequestor, IpcIoPendingRequest, WriteRequest::len, Must, WriteRequest::offset, push(), and IpcIoPendingRequest::writeRequest.
◆ writeCompleted()
|
protected |
Definition at line 303 of file IpcIoFile.cc.
References WriteRequest::buf, DBG_IMPORTANT, dbName, debugs, DISK_ERROR, DISK_OK, diskId, error_, WriteRequest::free_func, ioRequestor, IpcIoMsg::len, WriteRequest::len, WriteRequest::offset, IORequestor::writeCompleted(), IpcIoMsg::xerrno, and xstrerr().
Friends And Related Function Documentation
◆ IpcIoPendingRequest
|
friend |
Definition at line 101 of file IpcIoFile.h.
Member Data Documentation
◆ config
DiskFile::Config IpcIoFile::config |
Definition at line 98 of file IpcIoFile.h.
Referenced by canWait(), configure(), and open().
◆ dbName
|
private |
Definition at line 134 of file IpcIoFile.h.
Referenced by checkTimeouts(), close(), open(), openCompleted(), push(), readCompleted(), and writeCompleted().
◆ DiskerHandleMoreRequestsScheduled
|
staticprivate |
Definition at line 164 of file IpcIoFile.h.
Referenced by DiskerHandleMoreRequests(), DiskerHandleRequests(), and WaitBeforePop().
◆ diskId
|
private |
Definition at line 136 of file IpcIoFile.h.
Referenced by ~IpcIoFile(), canRead(), canWait(), canWrite(), CheckTimeouts(), handleResponse(), HandleResponses(), open(), openCompleted(), push(), read(), scheduleTimeoutCheck(), write(), and writeCompleted().
◆ error_
|
private |
Definition at line 139 of file IpcIoFile.h.
Referenced by canRead(), canWrite(), error(), open(), openCompleted(), read(), readCompleted(), write(), and writeCompleted().
◆ ioRequestor
|
private |
Definition at line 137 of file IpcIoFile.h.
Referenced by close(), open(), openCompleted(), read(), readCompleted(), write(), and writeCompleted().
◆ IpcIoFiles
|
staticprivate |
Definition at line 158 of file IpcIoFile.h.
Referenced by ~IpcIoFile(), CheckTimeouts(), HandleResponses(), open(), and openCompleted().
◆ lastRequestId
|
private |
Definition at line 141 of file IpcIoFile.h.
Referenced by push().
◆ myPid
|
private |
Definition at line 135 of file IpcIoFile.h.
Referenced by IpcIoFile(), and push().
◆ newerRequests
|
private |
Definition at line 148 of file IpcIoFile.h.
Referenced by checkTimeouts(), ioInProgress(), pendingRequests(), and trackPendingRequest().
◆ olderRequests
|
private |
Definition at line 147 of file IpcIoFile.h.
Referenced by checkTimeouts(), ioInProgress(), and pendingRequests().
◆ queue
|
staticprivate |
Definition at line 161 of file IpcIoFile.h.
Referenced by canWait(), DiskerHandleRequest(), DiskerHandleRequests(), HandleMessagesAtStart(), HandleNotification(), HandleResponses(), open(), push(), StatQueue(), and WaitBeforePop().
◆ requestMap1
|
private |
Definition at line 145 of file IpcIoFile.h.
Referenced by dequeueRequest().
◆ requestMap2
|
private |
Definition at line 146 of file IpcIoFile.h.
Referenced by dequeueRequest().
◆ Timeout
|
staticprivate |
Definition at line 151 of file IpcIoFile.h.
Referenced by checkTimeouts(), open(), scheduleTimeoutCheck(), and WaitBeforePop().
◆ timeoutCheckScheduled
|
private |
Definition at line 149 of file IpcIoFile.h.
Referenced by checkTimeouts(), scheduleTimeoutCheck(), and trackPendingRequest().
◆ WaitingForOpen
|
staticprivate |
maps diskerId to IpcIoFile, cleared in destructor
Definition at line 154 of file IpcIoFile.h.
Referenced by HandleOpenResponse(), open(), and OpenTimeout().
The documentation for this class was generated from the following files:
- src/DiskIO/IpcIo/IpcIoFile.h
- src/DiskIO/IpcIo/IpcIoFile.cc