#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 callReaderBack (const char *buf, int rlen)
 forwards read data 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...
 
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 (const SlotId nextSlot)
 
void writeBufToDisk (const SlotId nextSlot, const bool eof, const bool lastWrite)
 
SlotId reserveSlotForWriting ()
 finds and returns a free db slot to fill or throws 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 sidCurrent
 ID of the db slot currently being read or written. More...
 
RefCount< DiskFiletheFile
 
MemBlob theBuf
 

Detailed Description

Definition at line 24 of file RockIoState.h.

Member Typedef Documentation

Definition at line 29 of file RockIoState.h.

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

Definition at line 41 of file StoreIOState.h.

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

Definition at line 51 of file StoreIOState.h.

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

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

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.

Rock::IoState::~IoState ( )
virtual

Definition at line 48 of file RockIoState.cc.

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

Member Function Documentation

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

Definition at line 418 of file RockIoState.cc.

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

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

Definition at line 134 of file RockIoState.cc.

References assert, cbdataReferenceValidDone, debugs, and NULL.

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

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

Implements StoreIOState.

Definition at line 335 of file RockIoState.cc.

References assert, callback, debugs, and DISK_ERROR.

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

Definition at line 88 of file RockIoState.cc.

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

Definition at line 65 of file RockIoState.cc.

References assert, and NULL.

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

Definition at line 325 of file RockIoState.cc.

References CollapsedForwarding::Broadcast().

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

Rock::IoState::MEMPROXY_CLASS ( IoState  )
private
off_t StoreIOState::offset ( ) const
inlineinherited
void StoreIOState::operator delete ( void *  address)
inherited

Definition at line 25 of file StoreIOState.cc.

References assert.

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

Definition at line 18 of file StoreIOState.cc.

References assert.

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

Implements StoreIOState.

Definition at line 94 of file RockIoState.cc.

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

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

Definition at line 73 of file RockIoState.cc.

References assert.

Rock::SlotId Rock::IoState::reserveSlotForWriting ( )
private

Definition at line 311 of file RockIoState.cc.

References Ipc::Mem::PageId::number, and TexcHere.

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

Definition at line 42 of file RockIoState.h.

References NULL, and theFile.

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

bool StoreIOState::touchingStoreEntry ( ) const
inherited
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 180 of file RockIoState.cc.

References assert, debugs, Must, NULL, and Store::Root().

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

Implements StoreIOState.

Definition at line 152 of file RockIoState.cc.

References debugs, and DISK_ERROR.

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

Definition at line 80 of file RockIoState.cc.

References assert.

void Rock::IoState::writeBufToDisk ( const SlotId  sidNext,
const bool  eof,
const bool  lastWrite 
)
private
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 224 of file RockIoState.cc.

References min().

void Rock::IoState::writeToDisk ( const SlotId  sidNextProposal)
private

write what was buffered during write() calls negative sidNext means this is the last write request for this entry

Definition at line 244 of file RockIoState.cc.

References assert, debugs, and NULL.

Member Data Documentation

STIOCB* StoreIOState::callback
inherited

Definition at line 89 of file StoreIOState.h.

STRCB* StoreIOState::callback
inherited

Definition at line 93 of file StoreIOState.h.

void* StoreIOState::callback_data
inherited

Definition at line 90 of file StoreIOState.h.

Referenced by StoreIOState::~StoreIOState().

bool StoreIOState::closing
inherited

Definition at line 98 of file StoreIOState.h.

Referenced by storeClose().

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

Definition at line 73 of file RockIoState.h.

STFNCB* StoreIOState::file_callback
inherited

Definition at line 88 of file StoreIOState.h.

struct { ... } StoreIOState::flags
int64_t Rock::IoState::objOffset
private

Definition at line 75 of file RockIoState.h.

off_t StoreIOState::offset_
inherited
struct { ... } StoreIOState::read
const Ipc::StoreMapAnchor* Rock::IoState::readableAnchor_

Definition at line 51 of file RockIoState.h.

SlotId Rock::IoState::sidCurrent
private

Definition at line 76 of file RockIoState.h.

const size_t Rock::IoState::slotSize
private

Definition at line 74 of file RockIoState.h.

SlotId Rock::IoState::splicingPoint
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 58 of file RockIoState.h.

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

MemBlob Rock::IoState::theBuf
private

Definition at line 79 of file RockIoState.h.

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

Definition at line 78 of file RockIoState.h.

Referenced by stillWaiting().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors