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_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
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_FS_ROCK_IO_STATE_H */
110
int size
Definition: ModDevPoll.cc:75
uint64_t repliesReceived
the number of successful responses we received from theFile
Definition: RockIoState.h:101
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
Definition: RockIoState.cc:185
~IoState() override
Definition: RockIoState.cc:52
const Ipc::StoreMapSlice & currentReadableSlice() const
convenience wrapper returning the map slot we are reading now
Definition: RockIoState.cc:92
SlotId sidFirst
Definition: RockIoState.h:83
SlotId sidCurrent
Definition: RockIoState.h:91
void writeToDisk()
write what was buffered during write() calls
Definition: RockIoState.cc:267
const Ipc::StoreMapAnchor & readAnchor() const
Definition: RockIoState.cc:77
SlotId splicingPoint
the last db slot successfully read or written
Definition: RockIoState.h:60
MEMPROXY_CLASS(IoState)
bool expectedReply(const IoXactionId receivedId)
Definition: RockIoState.cc:334
SlotId sidNext
Definition: RockIoState.h:95
Rock::SwapDir::Pointer dir
swap dir that initiated I/O
Definition: RockIoState.h:77
void callBack(int errflag)
Definition: RockIoState.cc:463
void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) override
Definition: RockIoState.cc:98
size_t writeToBuffer(char const *buf, size_t size)
Definition: RockIoState.cc:248
RefCount< IoState > Pointer
Definition: RockIoState.h:30
Ipc::StoreMapAnchor * writeableAnchor_
starting point for writing
Definition: RockIoState.h:57
MemBlob theBuf
Definition: RockIoState.h:104
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)
Definition: RockIoState.cc:69
void callReaderBack(const char *buf, int rlen)
report (already sanitized/checked) I/O results to the read initiator
Definition: RockIoState.cc:168
void finishedWriting(const int errFlag)
called by SwapDir::writeCompleted() after the last write and on error
Definition: RockIoState.cc:350
Ipc::StoreMapAnchor & writeAnchor()
Definition: RockIoState.cc:84
void tryWrite(char const *buf, size_t size, off_t offset)
Definition: RockIoState.cc:213
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
Definition: RockIoState.h:103
IoState(Rock::SwapDir::Pointer &, StoreEntry *, StoreIOState::STIOCB *, void *cbData)
Definition: RockIoState.cc:25
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
Definition: RockIoState.cc:151
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
Definition: RockIoState.cc:369
off_t offset() const
Definition: StoreIOState.h:48
void * callback_data
Definition: StoreIOState.h:77
STIOCB * callback
Definition: StoreIOState.h:76
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors