RockIoState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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/forward.h"
13 #include "fs/rock/RockSwapDir.h"
14 #include "sbuf/MemBlob.h"
15 
16 class DiskFile;
17 
18 namespace Rock
19 {
20 
21 class DbCellHeader;
22 class SwapDir;
23 
25 class IoState: public ::StoreIOState
26 {
28 
29 public:
31 
33  virtual ~IoState();
34 
35  void file(const RefCount<DiskFile> &aFile);
36 
37  // ::StoreIOState API
38  virtual void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data);
39  virtual bool write(char const *buf, size_t size, off_t offset, FREE * free_func);
40  virtual void close(int how);
41 
43  bool stillWaiting() const { return theFile != NULL; }
44 
46  void handleReadCompletion(Rock::ReadRequest &request, const int rlen, const int errFlag);
47 
49  void finishedWriting(const int errFlag);
50 
53  bool expectedReply(const IoXactionId receivedId);
54 
55  /* one and only one of these will be set and locked; access via *Anchor() */
58 
64 
65 private:
66  const Ipc::StoreMapAnchor &readAnchor() const;
69 
70  void tryWrite(char const *buf, size_t size, off_t offset);
71  size_t writeToBuffer(char const *buf, size_t size);
72  void writeToDisk();
73 
74  void callReaderBack(const char *buf, int rlen);
75  void callBack(int errflag);
76 
78  const size_t slotSize;
79  int64_t objOffset;
80 
84 
88 
92 
96 
98  uint64_t requestsSent;
99 
101  uint64_t repliesReceived;
102 
103  RefCount<DiskFile> theFile; // "file" responsible for this I/O
104  MemBlob theBuf; // use for write content accumulation only
105 };
106 
107 } // namespace Rock
108 
109 #endif /* SQUID_FS_ROCK_IO_STATE_H */
110 
SlotId splicingPoint
the last db slot successfully read or written
Definition: RockIoState.h:60
SlotId staleSplicingPointNext
Definition: RockIoState.h:63
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)
Definition: RockIoState.cc:99
MemBlob theBuf
Definition: RockIoState.h:104
virtual void close(int how)
finish or abort swapping per CloseHow
Definition: RockIoState.cc:360
SlotId sidCurrent
Definition: RockIoState.h:91
int64_t objOffset
object offset for current db slot
Definition: RockIoState.h:79
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
Definition: forward.h:28
void FREE(void *)
Definition: forward.h:36
manages a single cache_dir
Definition: Disk.h:22
uint64_t repliesReceived
the number of successful responses we received from theFile
Definition: RockIoState.h:101
void callReaderBack(const char *buf, int rlen)
report (already sanitized/checked) I/O results to the read initiator
Definition: RockIoState.cc:159
bool stillWaiting() const
whether we are still waiting for the I/O results (i.e., not closed)
Definition: RockIoState.h:43
SlotId sidPrevious
Definition: RockIoState.h:87
int size
Definition: ModDevPoll.cc:75
#define NULL
Definition: types.h:166
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
virtual ~IoState()
Definition: RockIoState.cc:53
RefCount< IoState > Pointer
Definition: RockIoState.h:30
MEMPROXY_CLASS(IoState)
IoState(Rock::SwapDir::Pointer &aDir, StoreEntry *e, StoreIOState::STFNCB *cbFile, StoreIOState::STIOCB *cbIo, void *data)
Definition: RockIoState.cc:25
Ipc::StoreMapAnchor & writeAnchor()
Definition: RockIoState.cc:85
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:176
const Ipc::StoreMapSlice & currentReadableSlice() const
convenience wrapper returning the map slot we are reading now
Definition: RockIoState.cc:93
off_t offset() const
Definition: StoreIOState.h:60
void callBack(int errflag)
Definition: RockIoState.cc:454
void writeToDisk()
write what was buffered during write() calls
Definition: RockIoState.cc:258
bool expectedReply(const IoXactionId receivedId)
Definition: RockIoState.cc:325
const size_t slotSize
db cell size
Definition: RockIoState.h:78
Rock::SwapDir::Pointer dir
swap dir that initiated I/O
Definition: RockIoState.h:77
void finishedWriting(const int errFlag)
called by SwapDir::writeCompleted() after the last write and on error
Definition: RockIoState.cc:341
const Ipc::StoreMapAnchor * readableAnchor_
starting point for reading
Definition: RockIoState.h:56
uint64_t IoXactionId
unique (within a given IoState object scope) I/O transaction identifier
Definition: forward.h:36
void file(const RefCount< DiskFile > &aFile)
Definition: RockIoState.cc:70
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
Definition: RockIoState.cc:142
Ipc::StoreMapAnchor * writeableAnchor_
starting point for writing
Definition: RockIoState.h:57
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
sfileno SlotId
db cell number, starting with cell 0 (always occupied by the db header)
Definition: forward.h:30
uint64_t requestsSent
the number of read or write requests we sent to theFile
Definition: RockIoState.h:98
SlotId sidNext
Definition: RockIoState.h:95
RefCount< DiskFile > theFile
Definition: RockIoState.h:103
StoreEntry * e
Definition: StoreIOState.h:85
STIOCB * callback
Definition: StoreIOState.h:89
const Ipc::StoreMapAnchor & readAnchor() const
Definition: RockIoState.cc:78
void * callback_data
Definition: StoreIOState.h:90
SlotId sidFirst
Definition: RockIoState.h:83
size_t writeToBuffer(char const *buf, size_t size)
Definition: RockIoState.cc:239
void tryWrite(char const *buf, size_t size, off_t offset)
Definition: RockIoState.cc:204
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors