RockIoState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_FS_ROCK_ROCKIOSTATE_H
10 #define SQUID_SRC_FS_ROCK_ROCKIOSTATE_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  ~IoState() override;
34 
35  void file(const RefCount<DiskFile> &aFile);
36 
37  // ::StoreIOState API
38  void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data) override;
39  bool write(char const *buf, size_t size, off_t offset, FREE * free_func) override;
40  void close(int how) override;
41 
43  bool stillWaiting() const { return theFile != nullptr; }
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_SRC_FS_ROCK_ROCKIOSTATE_H */
110 
SlotId splicingPoint
the last db slot successfully read or written
Definition: RockIoState.h:60
SlotId staleSplicingPointNext
Definition: RockIoState.h:63
MemBlob theBuf
Definition: RockIoState.h:104
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:27
void FREE(void *)
Definition: forward.h:37
manages a single cache_dir
Definition: Disk.h:21
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:167
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:69
RefCount< IoState > Pointer
Definition: RockIoState.h:30
MEMPROXY_CLASS(IoState)
Ipc::StoreMapAnchor & writeAnchor()
Definition: RockIoState.cc:83
const Ipc::StoreMapSlice & currentReadableSlice() const
convenience wrapper returning the map slot we are reading now
Definition: RockIoState.cc:91
off_t offset() const
Definition: StoreIOState.h:48
void callBack(int errflag)
Definition: RockIoState.cc:462
void writeToDisk()
write what was buffered during write() calls
Definition: RockIoState.cc:266
bool expectedReply(const IoXactionId receivedId)
Definition: RockIoState.cc:333
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 read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) override
Definition: RockIoState.cc:97
void finishedWriting(const int errFlag)
called by SwapDir::writeCompleted() after the last write and on error
Definition: RockIoState.cc:349
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:68
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:150
Ipc::StoreMapAnchor * writeableAnchor_
starting point for writing
Definition: RockIoState.h:57
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
IoState(Rock::SwapDir::Pointer &, StoreEntry *, StoreIOState::STIOCB *, void *cbData)
Definition: RockIoState.cc:25
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
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
Definition: RockIoState.cc:184
STIOCB * callback
Definition: StoreIOState.h:76
const Ipc::StoreMapAnchor & readAnchor() const
Definition: RockIoState.cc:76
~IoState() override
Definition: RockIoState.cc:52
void * callback_data
Definition: StoreIOState.h:77
SlotId sidFirst
Definition: RockIoState.h:83
size_t writeToBuffer(char const *buf, size_t size)
Definition: RockIoState.cc:247
void tryWrite(char const *buf, size_t size, off_t offset)
Definition: RockIoState.cc:212
void close(int how) override
finish or abort swapping per CloseHow
Definition: RockIoState.cc:368

 

Introduction

Documentation

Support

Miscellaneous