RockIoState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_FS_ROCK_IO_STATE_H
10 #define SQUID_FS_ROCK_IO_STATE_H
11 
12 #include "fs/rock/RockSwapDir.h"
13 #include "sbuf/MemBlob.h"
14 
15 class DiskFile;
16 
17 namespace Rock
18 {
19 
20 class DbCellHeader;
21 class SwapDir;
22 
24 class IoState: public ::StoreIOState
25 {
27 
28 public:
30 
32  virtual ~IoState();
33 
34  void file(const RefCount<DiskFile> &aFile);
35 
36  // ::StoreIOState API
37  virtual void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data);
38  virtual bool write(char const *buf, size_t size, off_t offset, FREE * free_func);
39  virtual void close(int how);
40 
42  bool stillWaiting() const { return theFile != NULL; }
43 
45  void callReaderBack(const char *buf, int rlen);
46 
48  void finishedWriting(const int errFlag);
49 
50  /* one and only one of these will be set and locked; access via *Anchor() */
53 
59 
60 private:
61  const Ipc::StoreMapAnchor &readAnchor() const;
64 
65  void tryWrite(char const *buf, size_t size, off_t offset);
66  size_t writeToBuffer(char const *buf, size_t size);
67  void writeToDisk(const SlotId nextSlot);
68  void writeBufToDisk(const SlotId nextSlot, const bool eof, const bool lastWrite);
70 
71  void callBack(int errflag);
72 
74  const size_t slotSize;
75  int64_t objOffset;
77 
78  RefCount<DiskFile> theFile; // "file" responsible for this I/O
79  MemBlob theBuf; // use for write content accumulation only
80 };
81 
82 } // namespace Rock
83 
84 #endif /* SQUID_FS_ROCK_IO_STATE_H */
85 
virtual ~IoState()
Definition: RockIoState.cc:48
SlotId reserveSlotForWriting()
finds and returns a free db slot to fill or throws
Definition: RockIoState.cc:311
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
const Ipc::StoreMapAnchor & readAnchor() const
Definition: RockIoState.cc:73
virtual void close(int how)
finish or abort swapping per CloseHow
Definition: RockIoState.cc:335
RefCount< DiskFile > theFile
Definition: RockIoState.h:78
void writeBufToDisk(const SlotId nextSlot, const bool eof, const bool lastWrite)
Definition: RockIoState.cc:270
sfileno SlotId
db cell number, starting with cell 0 (always occupied by the db header)
Definition: forward.h:30
off_t offset() const
Definition: StoreIOState.h:60
void FREE(void *)
Definition: forward.h:36
SlotId sidCurrent
ID of the db slot currently being read or written.
Definition: RockIoState.h:76
SlotId splicingPoint
the last db slot successfully read or written
Definition: RockIoState.h:55
void const char HLPCB void * data
Definition: stub_helper.cc:16
IoState(Rock::SwapDir::Pointer &aDir, StoreEntry *e, StoreIOState::STFNCB *cbFile, StoreIOState::STIOCB *cbIo, void *data)
Definition: RockIoState.cc:25
Ipc::StoreMapAnchor * writeableAnchor_
starting point for writing
Definition: RockIoState.h:52
bool stillWaiting() const
whether we are still waiting for the I/O results (i.e., not closed)
Definition: RockIoState.h:42
MEMPROXY_CLASS(IoState)
int64_t objOffset
object offset for current db slot
Definition: RockIoState.h:75
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
size_t writeToBuffer(char const *buf, size_t size)
Definition: RockIoState.cc:224
SlotId staleSplicingPointNext
Definition: RockIoState.h:58
void file(const RefCount< DiskFile > &aFile)
Definition: RockIoState.cc:65
RefCount< IoState > Pointer
Definition: RockIoState.h:29
void const char * buf
Definition: stub_helper.cc:16
void writeToDisk(const SlotId nextSlot)
Definition: RockIoState.cc:244
void callBack(int errflag)
Definition: RockIoState.cc:418
const size_t slotSize
db cell size
Definition: RockIoState.h:74
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
MemBlob theBuf
Definition: RockIoState.h:79
void finishedWriting(const int errFlag)
called by SwapDir::writeCompleted() after the last write and on error
Definition: RockIoState.cc:325
void callReaderBack(const char *buf, int rlen)
forwards read data to the reader that initiated this I/O
Definition: RockIoState.cc:134
StoreEntry * e
Definition: StoreIOState.h:85
STIOCB * callback
Definition: StoreIOState.h:89
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
Definition: RockIoState.cc:152
const Ipc::StoreMapSlice & currentReadableSlice() const
convenience wrapper returning the map slot we are reading now
Definition: RockIoState.cc:88
void * callback_data
Definition: StoreIOState.h:90
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)
Definition: RockIoState.cc:94
Rock::SwapDir::Pointer dir
swap dir that initiated I/O
Definition: RockIoState.h:73
void tryWrite(char const *buf, size_t size, off_t offset)
Definition: RockIoState.cc:180
#define NULL
Definition: types.h:166
int size
Definition: ModDevPoll.cc:77
Ipc::StoreMapAnchor & writeAnchor()
Definition: RockIoState.cc:80
manages a single cache_dir
Definition: Disk.h:21
const Ipc::StoreMapAnchor * readableAnchor_
starting point for reading
Definition: RockIoState.h:51

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors