]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/rock/RockRebuild.h
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_FS_ROCK_REBUILD_H
10 #define SQUID_FS_ROCK_REBUILD_H
12 #include "base/AsyncJob.h"
14 #include "fs/rock/forward.h"
16 #include "store_rebuild.h"
26 /// manages store rebuild process: loading meta information from db on disk
27 class Rebuild
: public AsyncJob
29 CBDATA_CHILD(Rebuild
);
32 Rebuild(SwapDir
*dir
);
33 virtual ~Rebuild() override
;
37 virtual void start() override
;
38 virtual bool doneAll() const override
;
39 virtual void swanSong() override
;
41 bool doneLoading() const;
42 bool doneValidating() const;
48 void validationSteps();
50 void validateOneEntry(const sfileno fileNo
);
51 void validateOneSlot(const SlotId slotId
);
52 bool importEntry(Ipc::StoreMapAnchor
&anchor
, const sfileno slotId
, const DbCellHeader
&header
);
53 void freeBadEntry(const sfileno fileno
, const char *eDescription
);
55 void failure(const char *msg
, int errNo
= 0);
57 LoadingEntry
loadingEntry(const sfileno fileNo
);
58 void startNewEntry(const sfileno fileno
, const SlotId slotId
, const DbCellHeader
&header
);
59 void primeNewEntry(Ipc::StoreMapAnchor
&anchor
, const sfileno fileno
, const DbCellHeader
&header
);
60 void finalizeOrFree(const sfileno fileNo
, LoadingEntry
&le
);
61 void finalizeOrThrow(const sfileno fileNo
, LoadingEntry
&le
);
62 void addSlotToEntry(const sfileno fileno
, const SlotId slotId
, const DbCellHeader
&header
);
63 void useNewSlot(const SlotId slotId
, const DbCellHeader
&header
);
65 LoadingSlot
loadingSlot(const SlotId slotId
);
66 void mapSlot(const SlotId slotId
, const DbCellHeader
&header
);
67 void freeUnusedSlot(const SlotId slotId
, const bool invalid
);
68 void freeSlot(const SlotId slotId
, const bool invalid
);
70 template <class SlotIdType
>
71 void chainSlots(SlotIdType
&from
, const SlotId to
);
73 bool sameEntry(const sfileno fileno
, const DbCellHeader
&header
) const;
76 LoadingParts
*parts
; ///< parts of store entries being loaded from disk
79 int dbSlotSize
; ///< the size of a db cell, including the cell header
80 int dbSlotLimit
; ///< total number of db cells
81 int dbEntryLimit
; ///< maximum number of entries that can be stored in db
83 int fd
; // store db file descriptor
85 sfileno loadingPos
; ///< index of the db slot being loaded from disk now
86 sfileno validationPos
; ///< index of the loaded db slot being validated now
87 MemBuf buf
; ///< space to load current db slot (and entry metadata) into
89 StoreRebuildData counts
;
91 static void Steps(void *data
);
96 #endif /* SQUID_FS_ROCK_REBUILD_H */