]>
Commit | Line | Data |
---|---|---|
687f5275 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 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 | ||
ff9d9458 FC |
11 | #ifndef SQUID_SRC_STORE_REBUILD_H |
12 | #define SQUID_SRC_STORE_REBUILD_H | |
bbc27441 | 13 | |
e1ba42a4 FC |
14 | #include "store_key_md5.h" |
15 | ||
8ecbe78d EB |
16 | class MemBuf; |
17 | ||
18 | /// cache_dir(s) indexing statistics | |
1b2f0924 FC |
19 | class StoreRebuildData |
20 | { | |
211e9ce2 | 21 | public: |
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 | |
46 | class Progress | |
47 | { | |
48 | public: | |
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 |
59 | inline std::ostream & |
60 | operator <<(std::ostream &os, const Progress &p) | |
61 | { | |
62 | p.print(os); | |
63 | return os; | |
64 | } | |
65 | ||
8a648e8d FC |
66 | void storeRebuildStart(void); |
67 | void storeRebuildComplete(StoreRebuildData *); | |
68 | void storeRebuildProgress(int sd_index, int total, int sofar); | |
687f5275 FC |
69 | |
70 | /// loads entry from disk; fills supplied memory buffer on success | |
8a648e8d | 71 | bool storeRebuildLoadEntry(int fd, int diskIndex, MemBuf &buf, StoreRebuildData &counts); |
d448e1eb EB |
72 | |
73 | /** | |
74 | * Parses the given Store entry metadata, filling e and key. | |
75 | * Optimization: Both e and key parameters may be updated even on failures. | |
76 | * | |
77 | * \param buf memory containing serialized Store entry swap metadata (at least) | |
78 | * \param e caller's temporary StoreEntry object for returning parsed metadata | |
79 | * \param key caller's temporary Store entry key buffer; usable to set e.key | |
80 | * \param expectedSize either total entry size (including swap metadata) or 0 | |
81 | * | |
82 | * \retval true success; e/key filled with parsed metadata | |
83 | * \retval false failure; e/key ought to be ignored (may be filled/dirty) | |
84 | */ | |
8a648e8d | 85 | bool storeRebuildParseEntry(MemBuf &buf, StoreEntry &e, cache_key *key, StoreRebuildData &counts, uint64_t expectedSize); |
687f5275 | 86 | |
ff9d9458 | 87 | #endif /* SQUID_SRC_STORE_REBUILD_H */ |
f53969cc | 88 |