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