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_SRC_FS_UFS_UFSSTORESTATE_H
10 #define SQUID_SRC_FS_UFS_UFSSTORESTATE_H
11 
12 #include "DiskIO/DiskFile.h"
13 #include "DiskIO/IORequestor.h"
14 #include "StoreIOState.h"
15 
16 #include <queue>
17 
18 namespace Fs
19 {
20 namespace Ufs
21 {
22 
23 class UFSStoreState : public StoreIOState, public IORequestor
24 {
26 
27 public:
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;
38  bool creating;
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 
46 protected:
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;
95  _queued_write &operator =(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 {
121  } flags;
122 
123  bool kickReadQueue();
124  void drainWriteQueue();
125  void tryClosing();
126  char *read_buf;
127 
128 private:
129  void openDone();
130  void freePending();
131  void doWrite();
132 };
133 
134 } //namespace Ufs
135 } //namespace Fs
136 
137 #endif /* SQUID_SRC_FS_UFS_UFSSTORESTATE_H */
138 
_queued_read(char *b, size_t s, off_t o, STRCB *cb, void *data)
Definition: UFSStoreState.h:53
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
_queued_write(const char *b, size_t s, off_t o, FREE *f)
Definition: UFSStoreState.h:78
void FREE(void *)
Definition: forward.h:37
manages a single cache_dir
Definition: Disk.h:21
void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) override
void readCompleted(const char *buf, int len, int errflag, RefCount< ReadRequest >) override
void close(int how) override
finish or abort swapping per CloseHow
RefCount< DiskFile > theFile
Definition: UFSStoreState.h:36
CBDATA_CLASS(UFSStoreState)
#define cbdataReference(var)
Definition: cbdata.h:348
struct Fs::Ufs::UFSStoreState::@58 flags
void closeCompleted() override
int size
Definition: ModDevPoll.cc:69
_queued_write & operator=(const _queued_write &qr)=delete
std::queue< Ufs::UFSStoreState::_queued_read > pending_reads
Definition: UFSStoreState.h:72
std::queue< Ufs::UFSStoreState::_queued_write > pending_writes
MEMPROXY_CLASS(UFSStoreState::_queued_write)
off_t offset() const
Definition: StoreIOState.h:48
MEMPROXY_CLASS(UFSStoreState::_queued_read)
#define cbdataReferenceDone(var)
Definition: cbdata.h:357
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
Definition: Module.h:12
_queued_read & operator=(const _queued_read &qr)=delete
UFSStoreState(SwapDir *SD, StoreEntry *anEntry, STIOCB *callback_, void *callback_data_)
STIOCB * callback
Definition: StoreIOState.h:76
void * callback_data
Definition: StoreIOState.h:77
void ioCompletedNotification() override
bool write(char const *buf, size_t size, off_t offset, FREE *free_func) override
void writeCompleted(int errflag, size_t len, RefCount< WriteRequest >) override
virtual void doCloseCallback(int errflag)

 

Introduction

Documentation

Support

Miscellaneous