UFSStoreState.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_UFS_UFSSTORESTATE_H
10#define SQUID_FS_UFS_UFSSTORESTATE_H
11
12#include "DiskIO/DiskFile.h"
13#include "DiskIO/IORequestor.h"
14#include "StoreIOState.h"
15
16#include <queue>
17
18namespace Fs
19{
20namespace Ufs
21{
22
24{
26
27public:
28 UFSStoreState(SwapDir * SD, StoreEntry * anEntry, STIOCB * callback_, void *callback_data_);
29 ~UFSStoreState() override;
30 void close(int how) override;
31 void closeCompleted() override;
32 // protected:
33 void ioCompletedNotification() override;
34 void readCompleted(const char *buf, int len, int errflag, RefCount<ReadRequest>) override;
35 void writeCompleted(int errflag, size_t len, RefCount<WriteRequest>) override;
37 bool opening;
39 bool closing;
40 bool reading;
41 bool writing;
42 /* StoreIOState API */
43 void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data) override;
44 bool write(char const *buf, size_t size, off_t offset, FREE * free_func) override;
45
46protected:
47 virtual void doCloseCallback (int errflag);
48
50 {
52 public:
53 _queued_read(char *b, size_t s, off_t o, STRCB *cb, void *data) :
54 buf(b),
55 size(s),
56 offset(o),
57 callback(cb),
59 {}
62 }
63 _queued_read(const _queued_read &qr) = delete;
64 _queued_read &operator =(const _queued_read &qr) = delete;
65
66 char *buf;
67 size_t size;
68 off_t offset;
71 };
72 std::queue<Ufs::UFSStoreState::_queued_read> pending_reads;
73
75 {
77 public:
78 _queued_write(const char *b, size_t s, off_t o, FREE *f) :
79 buf(b),
80 size(s),
81 offset(o),
82 free_func(f)
83 {}
85 /*
86 * DPW 2006-05-24
87 * Note "free_func" is memNodeWriteComplete(), which doesn't
88 * really free the memory. Instead it clears the node's
89 * write_pending flag.
90 */
91 if (free_func && buf)
92 free_func(const_cast<char *>(buf));
93 }
94 _queued_write(const _queued_write &qr) = delete;
96
97 char const *buf;
98 size_t size;
99 off_t offset;
101 };
102 std::queue<Ufs::UFSStoreState::_queued_write> pending_writes;
103
104 // TODO: These should be in the IO strategy
105
106 struct {
122
123 bool kickReadQueue();
124 void drainWriteQueue();
125 void tryClosing();
126 char *read_buf;
127
128private:
129 void openDone();
130 void freePending();
131 void doWrite();
132};
133
134} //namespace Ufs
135} //namespace Fs
136
137#endif /* SQUID_FS_UFS_UFSSTORESTATE_H */
138
int size
Definition: ModDevPoll.cc:75
#define cbdataReferenceDone(var)
Definition: cbdata.h:352
#define cbdataReference(var)
Definition: cbdata.h:343
MEMPROXY_CLASS(UFSStoreState::_queued_read)
_queued_read(char *b, size_t s, off_t o, STRCB *cb, void *data)
Definition: UFSStoreState.h:53
_queued_read & operator=(const _queued_read &qr)=delete
_queued_read(const _queued_read &qr)=delete
MEMPROXY_CLASS(UFSStoreState::_queued_write)
_queued_write(const char *b, size_t s, off_t o, FREE *f)
Definition: UFSStoreState.h:78
_queued_write(const _queued_write &qr)=delete
_queued_write & operator=(const _queued_write &qr)=delete
virtual void doCloseCallback(int errflag)
CBDATA_CLASS(UFSStoreState)
void closeCompleted() override
void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) override
void writeCompleted(int errflag, size_t len, RefCount< WriteRequest >) override
std::queue< Ufs::UFSStoreState::_queued_write > pending_writes
bool write(char const *buf, size_t size, off_t offset, FREE *free_func) override
std::queue< Ufs::UFSStoreState::_queued_read > pending_reads
Definition: UFSStoreState.h:72
UFSStoreState(SwapDir *SD, StoreEntry *anEntry, STIOCB *callback_, void *callback_data_)
void close(int how) override
finish or abort swapping per CloseHow
void readCompleted(const char *buf, int len, int errflag, RefCount< ReadRequest >) override
struct Fs::Ufs::UFSStoreState::@66 flags
RefCount< DiskFile > theFile
Definition: UFSStoreState.h:36
void ioCompletedNotification() override
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: Module.h:13

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors