#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 STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
 

Public Member Functions

 IoState (Rock::SwapDir::Pointer &, StoreEntry *, StoreIOState::STIOCB *, void *cbData)
 
 ~IoState () override
 
void file (const RefCount< DiskFile > &aFile)
 
void read_ (char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) override
 
bool write (char const *buf, size_t size, off_t offset, FREE *free_func) override
 wraps tryWrite() to handle deep write failures centrally and safely More...
 
void close (int how) override
 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...
 
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.

◆ STIOCB

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

Definition at line 39 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 57 of file StoreIOState.h.

Constructor & Destructor Documentation

◆ IoState()

Rock::IoState::IoState ( Rock::SwapDir::Pointer aDir,
StoreEntry anEntry,
StoreIOState::STIOCB cbIo,
void *  cbData 
)

Definition at line 25 of file RockIoState.cc.

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

◆ ~IoState()

Rock::IoState::~IoState ( )
override

Definition at line 52 of file RockIoState.cc.

References assert, cbdataReferenceDone, shutting_down, and store_open_disk_fd.

Member Function Documentation

◆ callBack()

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

Definition at line 463 of file RockIoState.cc.

References asyncCall(), cbdataReferenceDone, debugs, and ScheduleCallHere.

◆ callReaderBack()

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

Definition at line 168 of file RockIoState.cc.

References assert, and cbdataReferenceValidDone.

◆ close()

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

Implements StoreIOState.

Definition at line 369 of file RockIoState.cc.

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

◆ currentReadableSlice()

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

Definition at line 92 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 334 of file RockIoState.cc.

References debugs, and Must.

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

◆ file()

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

◆ finishedWriting()

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

Definition at line 350 of file RockIoState.cc.

References CollapsedForwarding::Broadcast().

◆ handleReadCompletion()

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

Definition at line 151 of file RockIoState.cc.

References ReadRequest::buf, debugs, DISK_OK, and Rock::ReadRequest::id.

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 
)
overridevirtual

Implements StoreIOState.

Definition at line 98 of file RockIoState.cc.

References assert, cbdataReference, debugs, min(), and size.

◆ readAnchor()

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

Definition at line 77 of file RockIoState.cc.

References assert.

◆ stillWaiting()

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

Definition at line 43 of file RockIoState.h.

References 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 213 of file RockIoState.cc.

References assert, debugs, Must, and size.

◆ write()

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

Implements StoreIOState.

Definition at line 185 of file RockIoState.cc.

References debugs, DISK_ERROR, and size.

◆ writeAnchor()

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

Definition at line 84 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 248 of file RockIoState.cc.

References min(), and size.

◆ writeToDisk()

Member Data Documentation

◆ callback [1/2]

STIOCB* StoreIOState::callback
inherited

Definition at line 76 of file StoreIOState.h.

◆ callback [2/2]

STRCB* StoreIOState::callback
inherited

Definition at line 80 of file StoreIOState.h.

◆ callback_data

void* StoreIOState::callback_data
inherited

Definition at line 77 of file StoreIOState.h.

Referenced by StoreIOState::~StoreIOState().

◆ closing

bool StoreIOState::closing
inherited

Definition at line 85 of file StoreIOState.h.

Referenced by storeClose().

◆ dir

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

Definition at line 77 of file RockIoState.h.

◆ e

◆ 

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 75 of file StoreIOState.h.

Referenced by StoreIOState::offset().

◆ 

struct { ... } StoreIOState::read

◆ readableAnchor_

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

Definition at line 56 of file RockIoState.h.

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

◆ 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

◆ 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_


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors