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

◆ Pointer

Definition at line 29 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()

Member Function Documentation

◆ callBack()

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

◆ callReaderBack()

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

◆ close()

◆ currentReadableSlice()

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

Definition at line 88 of file RockIoState.cc.

References dir, sidCurrent, and StoreIOState::swap_filen.

Referenced by callReaderBack(), and read_().

◆ file()

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

Definition at line 65 of file RockIoState.cc.

References assert, NULL, and theFile.

◆ finishedWriting()

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

◆ MEMPROXY_CLASS()

Rock::IoState::MEMPROXY_CLASS ( IoState  )
private

◆ offset()

◆ 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

◆ readAnchor()

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

Definition at line 73 of file RockIoState.cc.

References assert, and readableAnchor_.

Referenced by read_().

◆ stillWaiting()

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

Definition at line 42 of file RockIoState.h.

References buf, callReaderBack(), finishedWriting(), 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 180 of file RockIoState.cc.

References assert, debugs, dir, StoreIOState::e, Must, NULL, StoreIOState::offset_, Store::Root(), sidCurrent, Ipc::StoreMapAnchor::start, StoreIOState::swap_filen, theFile, writeAnchor(), writeBufToDisk(), writeToBuffer(), and writeToDisk().

Referenced by write().

◆ write()

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, dir, DISK_ERROR, finishedWriting(), and tryWrite().

◆ writeAnchor()

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

Definition at line 80 of file RockIoState.cc.

References assert, and writeableAnchor_.

Referenced by tryWrite(), and writeBufToDisk().

◆ writeBufToDisk()

◆ 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 224 of file RockIoState.cc.

References MemBlob::append(), MemBlob::appended(), min(), StoreIOState::offset_, MemBlob::size, MemBlob::spaceSize(), and theBuf.

Referenced by tryWrite().

◆ writeToDisk()

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, MemBlob::clear(), debugs, NULL, sidCurrent, MemBlob::size, staleSplicingPointNext, theBuf, theFile, StoreIOState::touchingStoreEntry(), and writeBufToDisk().

Referenced by close(), and tryWrite().

Member Data Documentation

◆ callback [1/2]

◆ callback [2/2]

STRCB* StoreIOState::callback
inherited

Definition at line 93 of file StoreIOState.h.

◆ callback_data

◆ 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 72 of file RockIoState.h.

Referenced by close(), currentReadableSlice(), read_(), tryWrite(), write(), and writeBufToDisk().

◆ 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 74 of file RockIoState.h.

Referenced by read_().

◆ offset_

◆ read

◆ readableAnchor_

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

Definition at line 51 of file RockIoState.h.

Referenced by close(), and readAnchor().

◆ sidCurrent

SlotId Rock::IoState::sidCurrent
private

◆ slotSize

const size_t Rock::IoState::slotSize
private

Definition at line 73 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 58 of file RockIoState.h.

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

◆ swap_dirn

◆ swap_filen

◆ theBuf

MemBlob Rock::IoState::theBuf
private

Definition at line 78 of file RockIoState.h.

Referenced by close(), writeBufToDisk(), writeToBuffer(), and writeToDisk().

◆ theFile

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

◆ 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