RockRebuild.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
9 #ifndef SQUID_FS_ROCK_REBUILD_H
10 #define SQUID_FS_ROCK_REBUILD_H
11 
12 #include "base/AsyncJob.h"
13 #include "cbdata.h"
14 #include "fs/rock/forward.h"
15 #include "MemBuf.h"
16 #include "store_rebuild.h"
17 
18 namespace Rock
19 {
20 
21 class LoadingEntry;
22 class LoadingSlot;
23 class LoadingParts;
24 
27 class Rebuild: public AsyncJob
28 {
30 
31 public:
32  Rebuild(SwapDir *dir);
33  virtual ~Rebuild() override;
34 
35 protected:
36  /* AsyncJob API */
37  virtual void start() override;
38  virtual bool doneAll() const override;
39  virtual void swanSong() override;
40 
41  bool doneLoading() const;
42  bool doneValidating() const;
43 
44 private:
45  void checkpoint();
46  void steps();
47  void loadingSteps();
48  void validationSteps();
49  void loadOneSlot();
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);
54 
55  void failure(const char *msg, int errNo = 0);
56 
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);
64 
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);
69 
70  template <class SlotIdType>
71  void chainSlots(SlotIdType &from, const SlotId to);
72 
73  bool sameEntry(const sfileno fileno, const DbCellHeader &header) const;
74 
77 
78  int64_t dbSize;
79  int dbSlotSize;
82 
83  int fd; // store db file descriptor
84  int64_t dbOffset;
88 
90 
91  static void Steps(void *data);
92 };
93 
94 } // namespace Rock
95 
96 #endif /* SQUID_FS_ROCK_REBUILD_H */
97 
void addSlotToEntry(const sfileno fileno, const SlotId slotId, const DbCellHeader &header)
Definition: RockRebuild.cc:640
SwapDir * sd
Definition: RockRebuild.h:75
bool doneValidating() const
Definition: RockRebuild.cc:280
virtual void swanSong() override
Definition: RockRebuild.cc:559
void finalizeOrThrow(const sfileno fileNo, LoadingEntry &le)
Definition: RockRebuild.cc:467
void useNewSlot(const SlotId slotId, const DbCellHeader &header)
handle freshly loaded (and validated) db slot header
Definition: RockRebuild.cc:746
void finalizeOrFree(const sfileno fileNo, LoadingEntry &le)
Definition: RockRebuild.cc:501
void loadOneSlot()
Definition: RockRebuild.cc:362
int64_t dbOffset
Definition: RockRebuild.h:84
smart StoreEntry-level info pointer (hides anti-padding LoadingParts arrays)
Definition: RockRebuild.cc:94
virtual ~Rebuild() override
Definition: RockRebuild.cc:224
LoadingParts * parts
parts of store entries being loaded from disk
Definition: RockRebuild.h:76
void checkpoint()
continues after a pause if not done
Definition: RockRebuild.cc:267
sfileno SlotId
db cell number, starting with cell 0 (always occupied by the db header)
Definition: forward.h:30
void loadingSteps()
Definition: RockRebuild.cc:312
LoadingEntry loadingEntry(const sfileno fileNo)
Definition: RockRebuild.cc:347
bool importEntry(Ipc::StoreMapAnchor &anchor, const sfileno slotId, const DbCellHeader &header)
parse StoreEntry basics and add them to the map, returning true on success
Definition: RockRebuild.cc:406
void primeNewEntry(Ipc::StoreMapAnchor &anchor, const sfileno fileno, const DbCellHeader &header)
initialize housekeeping information for a newly accepted entry
Definition: RockRebuild.cc:700
Rebuild(SwapDir *dir)
Definition: RockRebuild.cc:203
smart db slot-level info pointer (hides anti-padding LoadingParts arrays)
Definition: RockRebuild.cc:118
void const char HLPCB void * data
Definition: stub_helper.cc:16
int64_t dbSize
Definition: RockRebuild.h:78
bool doneLoading() const
Definition: RockRebuild.cc:274
int dbSlotSize
the size of a db cell, including the cell header
Definition: RockRebuild.h:79
bool sameEntry(const sfileno fileno, const DbCellHeader &header) const
does the header belong to the fileno entry being loaded?
Definition: RockRebuild.cc:736
static void Steps(void *data)
Definition: RockRebuild.cc:294
void freeBadEntry(const sfileno fileno, const char *eDescription)
Definition: RockRebuild.cc:539
signed_int32_t sfileno
Definition: forward.h:22
sfileno loadingPos
index of the db slot being loaded from disk now
Definition: RockRebuild.h:85
virtual bool doneAll() const override
whether positive goal has been reached
Definition: RockRebuild.cc:288
void startNewEntry(const sfileno fileno, const SlotId slotId, const DbCellHeader &header)
handle a slot from an entry that we have not seen before
Definition: RockRebuild.cc:716
MemBuf buf
space to load current db slot (and entry metadata) into
Definition: RockRebuild.h:87
void validateOneEntry(const sfileno fileNo)
Definition: RockRebuild.cc:511
void chainSlots(SlotIdType &from, const SlotId to)
Definition: RockRebuild.cc:629
int dbSlotLimit
total number of db cells
Definition: RockRebuild.h:80
void validateOneSlot(const SlotId slotId)
Definition: RockRebuild.cc:529
int dbEntryLimit
maximum number of entries that can be stored in db
Definition: RockRebuild.h:81
sfileno validationPos
index of the loaded db slot being validated now
Definition: RockRebuild.h:86
virtual void start() override
prepares and initiates entry loading sequence
Definition: RockRebuild.cc:233
Definition: MemBuf.h:23
LoadingSlot loadingSlot(const SlotId slotId)
Definition: RockRebuild.cc:354
void validationSteps()
Definition: RockRebuild.cc:431
void mapSlot(const SlotId slotId, const DbCellHeader &header)
adds slot to the entry chain in the map
Definition: RockRebuild.cc:614
CBDATA_CHILD(Rebuild)
void failure(const char *msg, int errNo=0)
Definition: RockRebuild.cc:568
void freeSlot(const SlotId slotId, const bool invalid)
adds slot to the free slot index
Definition: RockRebuild.cc:584
StoreRebuildData counts
Definition: RockRebuild.h:89
void freeUnusedSlot(const SlotId slotId, const bool invalid)
freeSlot() for never-been-mapped slots
Definition: RockRebuild.cc:604

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors