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
16class DiskFile;
17
18namespace Rock
19{
20
21class DbCellHeader;
22class SwapDir;
23
26{
28
29public:
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 != 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
const Ipc::StoreMapSlice & currentReadableSlice() const
convenience wrapper returning the map slot we are reading now
Definition: RockIoState.cc:93
SlotId sidFirst
Definition: RockIoState.h:83
SlotId sidCurrent
Definition: RockIoState.h:91
void writeToDisk()
write what was buffered during write() calls
Definition: RockIoState.cc:268
const Ipc::StoreMapAnchor & readAnchor() const
Definition: RockIoState.cc:78
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:335
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:464
size_t writeToBuffer(char const *buf, size_t size)
Definition: RockIoState.cc:249
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
IoState(Rock::SwapDir::Pointer &aDir, StoreEntry *e, StoreIOState::STFNCB *cbFile, StoreIOState::STIOCB *cbIo, void *data)
Definition: RockIoState.cc:25
void file(const RefCount< DiskFile > &aFile)
Definition: RockIoState.cc:70
void callReaderBack(const char *buf, int rlen)
report (already sanitized/checked) I/O results to the read initiator
Definition: RockIoState.cc:169
void finishedWriting(const int errFlag)
called by SwapDir::writeCompleted() after the last write and on error
Definition: RockIoState.cc:351
Ipc::StoreMapAnchor & writeAnchor()
Definition: RockIoState.cc:85
virtual ~IoState()
Definition: RockIoState.cc:53
void tryWrite(char const *buf, size_t size, off_t offset)
Definition: RockIoState.cc:214
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
virtual void close(int how)
finish or abort swapping per CloseHow
Definition: RockIoState.cc:370
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:152
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:186
uint64_t requestsSent
the number of read or write requests we sent to theFile
Definition: RockIoState.h:98
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)
Definition: RockIoState.cc:99
off_t offset() const
Definition: StoreIOState.h:60
void * callback_data
Definition: StoreIOState.h:90
STIOCB * callback
Definition: StoreIOState.h:89
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
StoreEntry * e
Definition: StoreIOState.h:85
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
manages a single cache_dir
Definition: Disk.h:22
void FREE(void *)
Definition: forward.h:36
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
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors