]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/ufs/UFSStoreState.h
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/IORequestor.h"
13 #include "StoreIOState.h"
22 class UFSStoreState
: public StoreIOState
, public IORequestor
24 CBDATA_CLASS(UFSStoreState
);
27 UFSStoreState(SwapDir
* SD
, StoreEntry
* anEntry
, STIOCB
* callback_
, void *callback_data_
);
28 ~UFSStoreState() override
;
29 void close(int how
) override
;
30 void closeCompleted() override
;
32 void ioCompletedNotification() override
;
33 void readCompleted(const char *buf
, int len
, int errflag
, RefCount
<ReadRequest
>) override
;
34 void writeCompleted(int errflag
, size_t len
, RefCount
<WriteRequest
>) override
;
35 RefCount
<DiskFile
> theFile
;
41 /* StoreIOState API */
42 void read_(char *buf
, size_t size
, off_t offset
, STRCB
* callback
, void *callback_data
) override
;
43 bool write(char const *buf
, size_t size
, off_t offset
, FREE
* free_func
) override
;
46 virtual void doCloseCallback (int errflag
);
50 MEMPROXY_CLASS(UFSStoreState::_queued_read
);
52 _queued_read(char *b
, size_t s
, off_t o
, STRCB
*cb
, void *data
) :
57 callback_data(cbdataReference(data
))
60 cbdataReferenceDone(callback_data
);
62 _queued_read(const _queued_read
&qr
) = delete;
63 _queued_read
&operator =(const _queued_read
&qr
) = delete;
71 std::queue
<Ufs::UFSStoreState::_queued_read
> pending_reads
;
75 MEMPROXY_CLASS(UFSStoreState::_queued_write
);
77 _queued_write(const char *b
, size_t s
, off_t o
, FREE
*f
) :
86 * Note "free_func" is memNodeWriteComplete(), which doesn't
87 * really free the memory. Instead it clears the node's
91 free_func(const_cast<char *>(buf
));
93 _queued_write(const _queued_write
&qr
) = delete;
94 _queued_write
&operator =(const _queued_write
&qr
) = delete;
101 std::queue
<Ufs::UFSStoreState::_queued_write
> pending_writes
;
103 // TODO: These should be in the IO strategy
108 * the write_draining flag is used to avoid recursion inside
109 * the UFSStoreState::drainWriteQueue() method.
114 * The try_closing flag is set by UFSStoreState::tryClosing()
115 * when UFSStoreState wants to close the file, but cannot
116 * because of pending I/Os. If set, UFSStoreState will
117 * try to close again in the I/O callbacks.
122 bool kickReadQueue();
123 void drainWriteQueue();
136 #endif /* SQUID_FS_UFS_UFSSTORESTATE_H */