#include <RockIoState.h>

Inheritance diagram for Rock::IoState:
Collaboration diagram for Rock::IoState:

Public Types

typedef RefCount< IoStatePointer
 
enum  CloseHow {
  wroteAll,
  writerGone,
  readerDone
}
 
typedef void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
 
typedef void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
 
typedef void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
 

Public Member Functions

 IoState (Rock::SwapDir::Pointer &aDir, StoreEntry *e, StoreIOState::STFNCB *cbFile, StoreIOState::STIOCB *cbIo, void *data)
 
virtual ~IoState ()
 
void file (const RefCount< DiskFile > &aFile)
 
virtual void read_ (char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)
 
virtual bool write (char const *buf, size_t size, off_t offset, FREE *free_func)
 wraps tryWrite() to handle deep write failures centrally and safely More...
 
virtual void close (int how)
 finish or abort swapping per CloseHow More...
 
bool stillWaiting () const
 whether we are still waiting for the I/O results (i.e., not closed) More...
 
void handleReadCompletion (Rock::ReadRequest &request, const int rlen, const int errFlag)
 forwards read data (or an error) to the reader that initiated this I/O More...
 
void finishedWriting (const int errFlag)
 called by SwapDir::writeCompleted() after the last write and on error More...
 
bool expectedReply (const IoXactionId receivedId)
 
void * operator new (size_t amount)
 
void operator delete (void *address)
 
off_t offset () const
 
bool touchingStoreEntry () const
 

Public Attributes

const Ipc::StoreMapAnchorreadableAnchor_
 starting point for reading More...
 
Ipc::StoreMapAnchorwriteableAnchor_
 starting point for writing More...
 
SlotId splicingPoint
 the last db slot successfully read or written More...
 
SlotId staleSplicingPointNext
 
sdirno swap_dirn
 
sfileno swap_filen
 
StoreEntrye
 
mode_t mode
 
off_t offset_
 number of bytes written or read for this entry so far More...
 
STFNCBfile_callback
 
STIOCBcallback
 
void * callback_data
 
struct {
   STRCB *   callback
 
   void *   callback_data
 
read
 
struct {
   bool   closing
 
flags
 

Private Member Functions

 MEMPROXY_CLASS (IoState)
 
const Ipc::StoreMapAnchorreadAnchor () const
 
Ipc::StoreMapAnchorwriteAnchor ()
 
const Ipc::StoreMapSlicecurrentReadableSlice () const
 convenience wrapper returning the map slot we are reading now More...
 
void tryWrite (char const *buf, size_t size, off_t offset)
 
size_t writeToBuffer (char const *buf, size_t size)
 
void writeToDisk ()
 write what was buffered during write() calls More...
 
void callReaderBack (const char *buf, int rlen)
 report (already sanitized/checked) I/O results to the read initiator More...
 
void callBack (int errflag)
 

Private Attributes

Rock::SwapDir::Pointer dir
 swap dir that initiated I/O More...
 
const size_t slotSize
 db cell size More...
 
int64_t objOffset
 object offset for current db slot More...
 
SlotId sidFirst
 
SlotId sidPrevious
 
SlotId sidCurrent
 
SlotId sidNext
 
uint64_t requestsSent
 the number of read or write requests we sent to theFile More...
 
uint64_t repliesReceived
 the number of successful responses we received from theFile More...
 
RefCount< DiskFiletheFile
 
MemBlob theBuf
 

Detailed Description

Definition at line 25 of file RockIoState.h.

Member Typedef Documentation

◆ Pointer

Definition at line 30 of file RockIoState.h.

◆ STFNCB

typedef void StoreIOState::STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
inherited

Definition at line 41 of file StoreIOState.h.

◆ STIOCB

typedef void StoreIOState::STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
inherited

Definition at line 51 of file StoreIOState.h.

◆ STRCB

typedef void StoreIOState::STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
inherited

Definition at line 29 of file StoreIOState.h.

Member Enumeration Documentation

◆ CloseHow

enum StoreIOState::CloseHow
inherited
Enumerator
wroteAll 

success: caller supplied all data it wanted to swap out

writerGone 

failure: caller left before swapping out everything

readerDone 

success or failure: either way, stop swapping in

Definition at line 69 of file StoreIOState.h.

Constructor & Destructor Documentation

◆ IoState()

Rock::IoState::IoState ( Rock::SwapDir::Pointer aDir,
StoreEntry e,
StoreIOState::STFNCB cbFile,
StoreIOState::STIOCB cbIo,
void *  data 
)

Definition at line 25 of file RockIoState.cc.

References StoreIOState::e, StoreEntry::lock(), and store_open_disk_fd.

◆ ~IoState()

Rock::IoState::~IoState ( )
virtual

Definition at line 53 of file RockIoState.cc.

References assert, cbdataReferenceDone, NULL, shutting_down, and store_open_disk_fd.

Member Function Documentation

◆ callBack()

void Rock::IoState::callBack ( int  errflag)
private

Definition at line 454 of file RockIoState.cc.

References asyncCall(), callback, cbdataReferenceDone, debugs, HERE(), NULL, and ScheduleCallHere.

◆ callReaderBack()

void Rock::IoState::callReaderBack ( const char *  buf,
int  rlen 
)
private

Definition at line 159 of file RockIoState.cc.

References assert, buf, cbdataReferenceValidDone, and NULL.

◆ close()

void Rock::IoState::close ( int  how)
virtual

Implements StoreIOState.

Definition at line 360 of file RockIoState.cc.

References assert, callback, CurrentException(), debugs, and DISK_ERROR.

◆ currentReadableSlice()

const Ipc::StoreMapSlice & Rock::IoState::currentReadableSlice ( ) const
private

Definition at line 93 of file RockIoState.cc.

◆ expectedReply()

bool Rock::IoState::expectedReply ( const IoXactionId  receivedId)

notes that the disker has satisfied the given I/O request

Returns
whether all earlier I/O requests have been satisfied already

Definition at line 325 of file RockIoState.cc.

References debugs, and Must.

Referenced by Rock::SwapDir::writeCompleted().

◆ file()

void Rock::IoState::file ( const RefCount< DiskFile > &  aFile)

Definition at line 70 of file RockIoState.cc.

References assert, and NULL.

◆ finishedWriting()

void Rock::IoState::finishedWriting ( const int  errFlag)

Definition at line 341 of file RockIoState.cc.

References CollapsedForwarding::Broadcast().

◆ handleReadCompletion()

void Rock::IoState::handleReadCompletion ( Rock::ReadRequest request,
const int  rlen,
const int  errFlag 
)

Definition at line 142 of file RockIoState.cc.

References _request::buf, debugs, DISK_OK, and request().

Referenced by Rock::SwapDir::readCompleted().

◆ MEMPROXY_CLASS()

Rock::IoState::MEMPROXY_CLASS ( IoState  )
private

◆ offset()

off_t StoreIOState::offset ( ) const
inlineinherited

◆ operator delete()

void StoreIOState::operator delete ( void *  address)
inherited

Definition at line 25 of file StoreIOState.cc.

References assert.

◆ operator new()

void * StoreIOState::operator new ( size_t  amount)
inherited

Definition at line 18 of file StoreIOState.cc.

References assert.

◆ read_()

void Rock::IoState::read_ ( char *  buf,
size_t  size,
off_t  offset,
STRCB callback,
void *  callback_data 
)
virtual

Implements StoreIOState.

Definition at line 99 of file RockIoState.cc.

References assert, buf, cbdataReference, data, debugs, len, min(), NULL, request(), and size.

◆ readAnchor()

const Ipc::StoreMapAnchor & Rock::IoState::readAnchor ( ) const
private

Definition at line 78 of file RockIoState.cc.

References assert.

◆ stillWaiting()

bool Rock::IoState::stillWaiting ( ) const
inline

Definition at line 43 of file RockIoState.h.

References NULL, and theFile.

Referenced by Rock::SwapDir::writeCompleted().

◆ touchingStoreEntry()

bool StoreIOState::touchingStoreEntry ( ) const
inherited

◆ tryWrite()

void Rock::IoState::tryWrite ( char const *  buf,
size_t  size,
off_t  coreOff 
)
private

Possibly send data to be written to disk: We only write data when full slot is accumulated or when close() is called. We buffer, in part, to avoid forcing OS to read old unwritten portions of the slot when the write does not end at the page or sector boundary.

Definition at line 204 of file RockIoState.cc.

References assert, buf, debugs, Must, NULL, and size.

◆ write()

bool Rock::IoState::write ( char const *  buf,
size_t  size,
off_t  offset,
FREE free_func 
)
virtual

Implements StoreIOState.

Definition at line 176 of file RockIoState.cc.

References buf, debugs, DISK_ERROR, and size.

◆ writeAnchor()

Ipc::StoreMapAnchor & Rock::IoState::writeAnchor ( )
private

Definition at line 85 of file RockIoState.cc.

References assert.

◆ writeToBuffer()

size_t Rock::IoState::writeToBuffer ( char const *  buf,
size_t  size 
)
private

Buffers incoming data for the current slot.

Returns
the number of bytes buffered

Definition at line 239 of file RockIoState.cc.

References buf, min(), and size.

◆ writeToDisk()

Member Data Documentation

◆ callback [1/2]

STIOCB* StoreIOState::callback
inherited

Definition at line 89 of file StoreIOState.h.

◆ callback [2/2]

STRCB* StoreIOState::callback
inherited

Definition at line 93 of file StoreIOState.h.

◆ callback_data

void* StoreIOState::callback_data
inherited

Definition at line 90 of file StoreIOState.h.

Referenced by StoreIOState::~StoreIOState().

◆ closing

bool StoreIOState::closing
inherited

Definition at line 98 of file StoreIOState.h.

Referenced by storeClose().

◆ dir

Rock::SwapDir::Pointer Rock::IoState::dir
private

Definition at line 77 of file RockIoState.h.

◆ e

◆ file_callback

STFNCB* StoreIOState::file_callback
inherited

Definition at line 88 of file StoreIOState.h.

◆ flags

struct { ... } StoreIOState::flags

◆ mode

◆ objOffset

int64_t Rock::IoState::objOffset
private

Definition at line 79 of file RockIoState.h.

◆ offset_

off_t StoreIOState::offset_
inherited

Definition at line 87 of file StoreIOState.h.

Referenced by StoreIOState::offset().

◆ read

struct { ... } StoreIOState::read

◆ readableAnchor_

const Ipc::StoreMapAnchor* Rock::IoState::readableAnchor_

Definition at line 56 of file RockIoState.h.

◆ repliesReceived

uint64_t Rock::IoState::repliesReceived
private

Definition at line 101 of file RockIoState.h.

◆ requestsSent

uint64_t Rock::IoState::requestsSent
private

Definition at line 98 of file RockIoState.h.

◆ sidCurrent

SlotId Rock::IoState::sidCurrent
private

For readers, the db slot currently being read from disk. For writers, the reserved db slot currently being filled (to be written).

Definition at line 91 of file RockIoState.h.

◆ sidFirst

SlotId Rock::IoState::sidFirst
private

The very first entry slot. Usually the same as anchor.first, but writers set anchor.first only after the first write is done.

Definition at line 83 of file RockIoState.h.

◆ sidNext

SlotId Rock::IoState::sidNext
private

Unused by readers. For writers, the reserved db slot that sidCurrent.next will point to.

Definition at line 95 of file RockIoState.h.

◆ sidPrevious

SlotId Rock::IoState::sidPrevious
private

Unused by readers. For writers, the slot pointing (via .next) to sidCurrent.

Definition at line 87 of file RockIoState.h.

◆ slotSize

const size_t Rock::IoState::slotSize
private

Definition at line 78 of file RockIoState.h.

◆ splicingPoint

SlotId Rock::IoState::splicingPoint

◆ staleSplicingPointNext

SlotId Rock::IoState::staleSplicingPointNext

when reading, this is the next slot we are going to read (if asked) when writing, this is the next slot to use after the last fresh slot

Definition at line 63 of file RockIoState.h.

Referenced by Rock::HeaderUpdater::startWriting(), and Rock::HeaderUpdater::stopReading().

◆ swap_dirn

sdirno StoreIOState::swap_dirn
inherited

◆ swap_filen

◆ theBuf

MemBlob Rock::IoState::theBuf
private

Definition at line 104 of file RockIoState.h.

◆ theFile

RefCount<DiskFile> Rock::IoState::theFile
private

Definition at line 103 of file RockIoState.h.

Referenced by stillWaiting().

◆ writeableAnchor_

Ipc::StoreMapAnchor* Rock::IoState::writeableAnchor_

The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors