]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fs/rock/RockRebuild.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / fs / rock / RockRebuild.h
CommitLineData
bbc27441 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
bbc27441
AJ
3 *
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.
7 */
8
e2851fe7
AR
9#ifndef SQUID_FS_ROCK_REBUILD_H
10#define SQUID_FS_ROCK_REBUILD_H
11
078274f6 12#include "base/AsyncJob.h"
211e9ce2 13#include "cbdata.h"
50dc81ec
AR
14#include "fs/rock/RockForward.h"
15#include "MemBuf.h"
211e9ce2 16#include "store_rebuild.h"
e2851fe7 17
9199139f
AR
18namespace Rock
19{
e2851fe7 20
50dc81ec 21class LoadingEntry;
e2851fe7
AR
22
23/// \ingroup Rock
24/// manages store rebuild process: loading meta information from db on disk
9199139f
AR
25class Rebuild: public AsyncJob
26{
5c2f68b7
AJ
27 CBDATA_CLASS(Rebuild);
28
e2851fe7
AR
29public:
30 Rebuild(SwapDir *dir);
31 ~Rebuild();
e2851fe7 32
078274f6
AR
33protected:
34 /* AsyncJob API */
35 virtual void start();
36 virtual bool doneAll() const;
37 virtual void swanSong();
e2851fe7 38
078274f6 39private:
e2851fe7
AR
40 void checkpoint();
41 void steps();
50dc81ec
AR
42 void loadingSteps();
43 void validationSteps();
44 void loadOneSlot();
45 void validateOneEntry();
46 bool importEntry(Ipc::StoreMapAnchor &anchor, const sfileno slotId, const DbCellHeader &header);
47 void freeBadEntry(const sfileno fileno, const char *eDescription);
48
e2851fe7 49 void failure(const char *msg, int errNo = 0);
50dc81ec
AR
50
51 void startNewEntry(const sfileno fileno, const SlotId slotId, const DbCellHeader &header);
52 void primeNewEntry(Ipc::StoreMapAnchor &anchor, const sfileno fileno, const DbCellHeader &header);
53 void addSlotToEntry(const sfileno fileno, const SlotId slotId, const DbCellHeader &header);
54 void useNewSlot(const SlotId slotId, const DbCellHeader &header);
55
56 void mapSlot(const SlotId slotId, const DbCellHeader &header);
57 void freeSlotIfIdle(const SlotId slotId, const bool invalid);
58 void freeBusySlot(const SlotId slotId, const bool invalid);
59 void freeSlot(const SlotId slotId, const bool invalid);
60
61 bool canAdd(const sfileno fileno, const SlotId slotId, const DbCellHeader &header) const;
62 bool sameEntry(const sfileno fileno, const DbCellHeader &header) const;
63
e2851fe7 64 SwapDir *sd;
50dc81ec 65 LoadingEntry *entries; ///< store entries being loaded from disk
e2851fe7
AR
66
67 int64_t dbSize;
36c84e19
AR
68 int dbSlotSize; ///< the size of a db cell, including the cell header
69 int dbSlotLimit; ///< total number of db cells
70 int dbEntryLimit; ///< maximum number of entries that can be stored in db
e2851fe7
AR
71
72 int fd; // store db file descriptor
73 int64_t dbOffset;
6d68a230
AR
74 sfileno loadingPos; ///< index of the db slot being loaded from disk now
75 sfileno validationPos; ///< index of the loaded db slot being validated now
76 MemBuf buf; ///< space to load current db slot (and entry metadata) into
93910d5c 77
211e9ce2 78 StoreRebuildData counts;
e2851fe7
AR
79
80 static void Steps(void *data);
81};
82
83} // namespace Rock
84
85#endif /* SQUID_FS_ROCK_REBUILD_H */
f53969cc 86