]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fs/ufs/RebuildState.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / fs / ufs / RebuildState.h
CommitLineData
58373ff8 1/*
b8ae064d 2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
58373ff8 3 *
bbc27441
AJ
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.
58373ff8
FC
7 */
8
9#ifndef SQUID_FS_UFS_REBUILDSTATE_H
10#define SQUID_FS_UFS_REBUILDSTATE_H
11
8bf217bd 12#include "base/RefCount.h"
602d9612 13#include "store_rebuild.h"
58373ff8 14#include "UFSSwapDir.h"
58373ff8
FC
15#include "UFSSwapLogParser.h"
16
17class StoreEntry;
18
19namespace Fs
20{
21namespace Ufs
22{
23
de9c02cd 24class RebuildState
58373ff8 25{
5c2f68b7
AJ
26 CBDATA_CLASS(RebuildState);
27
58373ff8
FC
28public:
29 static EVH RebuildStep;
30
31 RebuildState(RefCount<UFSSwapDir> sd);
de9c02cd 32 virtual ~RebuildState();
58373ff8
FC
33
34 virtual bool error() const;
35 virtual bool isDone() const;
58373ff8
FC
36
37 RefCount<UFSSwapDir> sd;
38 int n_read;
39 /* FILE *log;*/
40 Fs::Ufs::UFSSwapLogParser *LogParser;
41 int curlvl1;
42 int curlvl2;
43
1a6347cd
FC
44 struct Flags {
45 Flags() : need_to_validate(false), clean(false), init(false) {}
46 bool need_to_validate;
47 bool clean;
48 bool init;
58373ff8
FC
49 } flags;
50 int in_dir;
51 int done;
52 int fn;
53
54 dirent_t *entry;
55 DIR *td;
7c964f99
FC
56 SBuf fullpath;
57 SBuf fullfilename;
58373ff8 58
211e9ce2 59 StoreRebuildData counts;
58373ff8
FC
60
61private:
58373ff8
FC
62 void rebuildFromDirectory();
63 void rebuildFromSwapLog();
64 void rebuildStep();
4310f8b0
EB
65 void addIfFresh(const cache_key *key,
66 sfileno file_number,
67 uint64_t swap_file_sz,
68 time_t expires,
69 time_t timestamp,
70 time_t lastref,
71 time_t lastmod,
72 uint32_t refcount,
73 uint16_t flags);
74 bool evictStaleAndContinue(const cache_key *candidateKey, const time_t maxRef, int &staleCount);
58373ff8 75 int getNextFile(sfileno *, int *size);
58373ff8
FC
76 bool fromLog;
77 bool _done;
78 /// \bug (callback) should be hidden behind a proper human readable name
79 void (callback)(void *cbdata);
80 void *cbdata;
81};
82
58373ff8
FC
83} /* namespace Ufs */
84} /* namespace Fs */
85
86#endif /* SQUID_FS_UFS_REBUILDSTATE_H */
f53969cc 87