]> git.ipfire.org Git - thirdparty/squid.git/blame - src/store_rebuild.h
Maintenance: Update astyle version to 3.1 (#841)
[thirdparty/squid.git] / src / store_rebuild.h
CommitLineData
687f5275 1/*
f70aedc4 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
687f5275 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.
687f5275 7 */
001d55dc 8
bbc27441
AJ
9/* DEBUG: section 20 Store Rebuild Routines */
10
11#ifndef SQUID_STORE_REBUILD_H_
12#define SQUID_STORE_REBUILD_H_
13
e1ba42a4
FC
14#include "store_key_md5.h"
15
8ecbe78d
EB
16class MemBuf;
17
18/// cache_dir(s) indexing statistics
1b2f0924
FC
19class StoreRebuildData
20{
211e9ce2 21public:
8ecbe78d
EB
22 /// maintain earliest initiation time across multiple indexing cache_dirs
23 void updateStartTime(const timeval &dirStartTime);
24
25 /// whether we have worked on indexing this(these) cache_dir(s) before
26 bool started() const { return startTime.tv_sec > 0; }
27
28 // when adding members, keep the class compatible with placement new onto a
29 // zeroed shared memory segment (see Rock::Rebuild::Stats usage)
30
b56b37cf
AJ
31 int objcount = 0; /* # objects successfully reloaded */
32 int expcount = 0; /* # objects expired */
33 int scancount = 0; /* # entries scanned or read from state file */
34 int clashcount = 0; /* # swapfile clashes avoided */
35 int dupcount = 0; /* # duplicates purged */
36 int cancelcount = 0; /* # SWAP_LOG_DEL objects purged */
37 int invalid = 0; /* # bad lines */
38 int badflags = 0; /* # bad e->flags */
39 int bad_log_op = 0;
40 int zero_object_sz = 0;
8ecbe78d
EB
41 int64_t validations = 0; ///< the number of validated cache entries, slots
42 timeval startTime = {}; ///< absolute time when the rebuild was initiated
43};
44
45/// advancement of work that consists of (usually known number) of similar steps
46class Progress
47{
48public:
49 Progress(const int64_t stepsCompleted, const int64_t stepsTotal):
50 completed(stepsCompleted), goal(stepsTotal) {}
51
52 /// brief progress report suitable for level-0/1 debugging
53 void print(std::ostream &os) const;
54
55 int64_t completed; ///< the number of finished work steps
56 int64_t goal; ///< the known total number of work steps (or negative)
211e9ce2 57};
687f5275 58
8ecbe78d
EB
59inline std::ostream &
60operator <<(std::ostream &os, const Progress &p)
61{
62 p.print(os);
63 return os;
64}
65
8a648e8d
FC
66void storeRebuildStart(void);
67void storeRebuildComplete(StoreRebuildData *);
68void storeRebuildProgress(int sd_index, int total, int sofar);
687f5275
FC
69
70/// loads entry from disk; fills supplied memory buffer on success
8a648e8d 71bool storeRebuildLoadEntry(int fd, int diskIndex, MemBuf &buf, StoreRebuildData &counts);
687f5275 72/// parses entry buffer and validates entry metadata; fills e on success
8a648e8d 73bool storeRebuildParseEntry(MemBuf &buf, StoreEntry &e, cache_key *key, StoreRebuildData &counts, uint64_t expectedSize);
687f5275 74
687f5275 75#endif /* SQUID_STORE_REBUILD_H_ */
f53969cc 76