Squid Web Cache master
Loading...
Searching...
No Matches
RockIoState.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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
16class DiskFile;
17
18namespace Rock
19{
20
21class DbCellHeader;
22class SwapDir;
23
26{
28
29public:
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
65private:
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
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
int size
Definition ModDevPoll.cc:70
uint64_t repliesReceived
the number of successful responses we received from theFile
SlotId sidPrevious
Definition RockIoState.h:87
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
~IoState() override
const Ipc::StoreMapSlice & currentReadableSlice() const
convenience wrapper returning the map slot we are reading now
SlotId sidFirst
Definition RockIoState.h:83
SlotId sidCurrent
Definition RockIoState.h:91
void writeToDisk()
write what was buffered during write() calls
const Ipc::StoreMapAnchor & readAnchor() const
SlotId splicingPoint
the last db slot successfully read or written
Definition RockIoState.h:60
MEMPROXY_CLASS(IoState)
bool expectedReply(const IoXactionId receivedId)
Rock::SwapDir::Pointer dir
swap dir that initiated I/O
Definition RockIoState.h:77
void callBack(int errflag)
void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) override
size_t writeToBuffer(char const *buf, size_t size)
RefCount< IoState > Pointer
Definition RockIoState.h:30
Ipc::StoreMapAnchor * writeableAnchor_
starting point for writing
Definition RockIoState.h:57
int64_t objOffset
object offset for current db slot
Definition RockIoState.h:79
SlotId staleSplicingPointNext
Definition RockIoState.h:63
void file(const RefCount< DiskFile > &aFile)
void callReaderBack(const char *buf, int rlen)
report (already sanitized/checked) I/O results to the read initiator
void finishedWriting(const int errFlag)
called by SwapDir::writeCompleted() after the last write and on error
Ipc::StoreMapAnchor & writeAnchor()
void tryWrite(char const *buf, size_t size, off_t offset)
const size_t slotSize
db cell size
Definition RockIoState.h:78
const Ipc::StoreMapAnchor * readableAnchor_
starting point for reading
Definition RockIoState.h:56
RefCount< DiskFile > theFile
bool stillWaiting() const
whether we are still waiting for the I/O results (i.e., not closed)
Definition RockIoState.h:43
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
uint64_t requestsSent
the number of read or write requests we sent to theFile
Definition RockIoState.h:98
void close(int how) override
finish or abort swapping per CloseHow
off_t offset() const
void * callback_data
STIOCB * callback
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
manages a single cache_dir
Definition Disk.h:22
void FREE(void *)
Definition forward.h:37
Definition forward.h:28
uint64_t IoXactionId
unique (within a given IoState object scope) I/O transaction identifier
Definition forward.h:36
sfileno SlotId
db cell number, starting with cell 0 (always occupied by the db header)
Definition forward.h:33