]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fs/rock/RockDbCell.h
Maintenance: automate header guards 2/3 (#1655)
[thirdparty/squid.git] / src / fs / rock / RockDbCell.h
CommitLineData
bbc27441 1/*
b8ae064d 2 * Copyright (C) 1996-2023 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
ff9d9458
FC
9#ifndef SQUID_SRC_FS_ROCK_ROCKDBCELL_H
10#define SQUID_SRC_FS_ROCK_ROCKDBCELL_H
c728b6f9 11
2745fea5 12#include "store/forward.h"
93910d5c 13
9199139f
AR
14namespace Rock
15{
c728b6f9 16
fcd789da
AR
17/** \ingroup Rock
18 * Meta-information at the beginning of every db cell.
50dc81ec 19 * Links multiple map slots belonging to the same entry into an entry chain.
fcd789da
AR
20 * Stored on disk and used as sizeof() argument so it must remain POD.
21 */
c728b6f9
AR
22class DbCellHeader
23{
24public:
93910d5c 25 DbCellHeader();
c728b6f9 26
50dc81ec
AR
27 /// true iff no entry occupies this slot
28 bool empty() const { return !firstSlot && !nextSlot && !payloadSize; }
29
30 /* members below are not meaningful if empty() */
31
32 /// whether this slot is not corrupted
9d4e9cfb
AR
33 bool sane(const size_t slotSize, int slotLimit) const {
34 return
35 0 <= firstSlot && firstSlot < slotLimit &&
36 -1 <= nextSlot && nextSlot < slotLimit &&
37 version > 0 &&
38 0 < payloadSize && payloadSize <= slotSize - sizeof(DbCellHeader);
39 }
c728b6f9 40
93910d5c 41 uint64_t key[2]; ///< StoreEntry key
50dc81ec
AR
42 uint64_t entrySize; ///< total entry content size or zero if still unknown
43 uint32_t payloadSize; ///< slot contents size, always positive
44 uint32_t version; ///< detects conflicts among same-key entries
45 sfileno firstSlot; ///< slot ID of the first slot occupied by the entry
46 sfileno nextSlot; ///< slot ID of the next slot occupied by the entry
c728b6f9
AR
47};
48
49} // namespace Rock
50
ff9d9458 51#endif /* SQUID_SRC_FS_ROCK_ROCKDBCELL_H */
f53969cc 52