]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/ufs/UFSStoreState.h
296bdaad77969443eca3afc933adc0ed140607ca
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_FS_UFS_UFSSTORESTATE_H
10 #define SQUID_FS_UFS_UFSSTORESTATE_H
12 #include "DiskIO/DiskFile.h"
13 #include "DiskIO/IORequestor.h"
14 #include "StoreIOState.h"
23 class UFSStoreState
: public StoreIOState
, public IORequestor
25 CBDATA_CLASS(UFSStoreState
);
28 UFSStoreState(SwapDir
* SD
, StoreEntry
* anEntry
, STIOCB
* callback_
, void *callback_data_
);
29 ~UFSStoreState() override
;
30 void close(int how
) override
;
31 void closeCompleted() override
;
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
;
36 RefCount
<DiskFile
> theFile
;
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
;
47 virtual void doCloseCallback (int errflag
);
51 MEMPROXY_CLASS(UFSStoreState::_queued_read
);
53 _queued_read(char *b
, size_t s
, off_t o
, STRCB
*cb
, void *data
) :
58 callback_data(cbdataReference(data
))
61 cbdataReferenceDone(callback_data
);
63 _queued_read(const _queued_read
&qr
) = delete;
64 _queued_read
&operator =(const _queued_read
&qr
) = delete;
72 std::queue
<Ufs::UFSStoreState::_queued_read
> pending_reads
;
76 MEMPROXY_CLASS(UFSStoreState::_queued_write
);
78 _queued_write(const char *b
, size_t s
, off_t o
, FREE
*f
) :
87 * Note "free_func" is memNodeWriteComplete(), which doesn't
88 * really free the memory. Instead it clears the node's
92 free_func(const_cast<char *>(buf
));
94 _queued_write(const _queued_write
&qr
) = delete;
95 _queued_write
&operator =(const _queued_write
&qr
) = delete;
102 std::queue
<Ufs::UFSStoreState::_queued_write
> pending_writes
;
104 // TODO: These should be in the IO strategy
109 * the write_draining flag is used to avoid recursion inside
110 * the UFSStoreState::drainWriteQueue() method.
115 * The try_closing flag is set by UFSStoreState::tryClosing()
116 * when UFSStoreState wants to close the file, but cannot
117 * because of pending I/Os. If set, UFSStoreState will
118 * try to close again in the I/O callbacks.
123 bool kickReadQueue();
124 void drainWriteQueue();
137 #endif /* SQUID_FS_UFS_UFSSTORESTATE_H */