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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors