|
Packit Service |
75d76b |
/*
|
|
Packit Service |
75d76b |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
75d76b |
*
|
|
Packit Service |
75d76b |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
75d76b |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
75d76b |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
75d76b |
* of the License, or (at your option) any later version.
|
|
Packit Service |
75d76b |
*
|
|
Packit Service |
75d76b |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
75d76b |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
75d76b |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
75d76b |
* GNU General Public License for more details.
|
|
Packit Service |
75d76b |
*
|
|
Packit Service |
75d76b |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
75d76b |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
75d76b |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
75d76b |
* 02110-1301, USA.
|
|
Packit Service |
75d76b |
*
|
|
Packit Service |
75d76b |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/slabSummaryInternals.h#7 $
|
|
Packit Service |
75d76b |
*/
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
#ifndef SLAB_SUMMARY_INTERNALS_H
|
|
Packit Service |
75d76b |
#define SLAB_SUMMARY_INTERNALS_H
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
#include "slabSummary.h"
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
#include "adminState.h"
|
|
Packit Service |
75d76b |
#include "atomic.h"
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
typedef struct slabSummaryEntry {
|
|
Packit Service |
75d76b |
/** Bits 7..0: The offset of the tail block within the slab journal */
|
|
Packit Service |
75d76b |
TailBlockOffset tailBlockOffset;
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
Packit Service |
75d76b |
/** Bits 13..8: A hint about the fullness of the slab */
|
|
Packit Service |
75d76b |
unsigned int fullnessHint : 6;
|
|
Packit Service |
75d76b |
/** Bit 14: Whether the refCounts must be loaded from the layer */
|
|
Packit Service |
75d76b |
unsigned int loadRefCounts : 1;
|
|
Packit Service |
75d76b |
/** Bit 15: The believed cleanliness of this slab */
|
|
Packit Service |
75d76b |
unsigned int isDirty : 1;
|
|
Packit Service |
75d76b |
#else
|
|
Packit Service |
75d76b |
/** Bit 15: The believed cleanliness of this slab */
|
|
Packit Service |
75d76b |
unsigned int isDirty : 1;
|
|
Packit Service |
75d76b |
/** Bit 14: Whether the refCounts must be loaded from the layer */
|
|
Packit Service |
75d76b |
unsigned int loadRefCounts : 1;
|
|
Packit Service |
75d76b |
/** Bits 13..8: A hint about the fullness of the slab */
|
|
Packit Service |
75d76b |
unsigned int fullnessHint : 6;
|
|
Packit Service |
75d76b |
#endif
|
|
Packit Service |
75d76b |
} __attribute__((packed)) SlabSummaryEntry;
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
typedef struct slabSummaryBlock {
|
|
Packit Service |
75d76b |
/** The zone to which this block belongs */
|
|
Packit Service |
75d76b |
SlabSummaryZone *zone;
|
|
Packit Service |
75d76b |
/** The index of this block in its zone's summary */
|
|
Packit Service |
75d76b |
BlockCount index;
|
|
Packit Service |
75d76b |
/** Whether this block has a write outstanding */
|
|
Packit Service |
75d76b |
bool writing;
|
|
Packit Service |
75d76b |
/** Ring of updates waiting on the outstanding write */
|
|
Packit Service |
75d76b |
WaitQueue currentUpdateWaiters;
|
|
Packit Service |
75d76b |
/** Ring of updates waiting on the next write */
|
|
Packit Service |
75d76b |
WaitQueue nextUpdateWaiters;
|
|
Packit Service |
75d76b |
/** The active SlabSummaryEntry array for this block */
|
|
Packit Service |
75d76b |
SlabSummaryEntry *entries;
|
|
Packit Service |
75d76b |
/** The VIO used to write this block */
|
|
Packit Service |
75d76b |
VIO *vio;
|
|
Packit Service |
75d76b |
/** The packed entries, one block long, backing the VIO */
|
|
Packit Service |
75d76b |
char *outgoingEntries;
|
|
Packit Service |
75d76b |
} SlabSummaryBlock;
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
/**
|
|
Packit Service |
75d76b |
* The statistics for all the slab summary zones owned by this slab summary.
|
|
Packit Service |
75d76b |
* These fields are all mutated only by their physical zone threads, but are
|
|
Packit Service |
75d76b |
* read by other threads when gathering statistics for the entire depot.
|
|
Packit Service |
75d76b |
**/
|
|
Packit Service |
75d76b |
typedef struct atomicSlabSummaryStatistics {
|
|
Packit Service |
75d76b |
/** Number of blocks written */
|
|
Packit Service |
75d76b |
Atomic64 blocksWritten;
|
|
Packit Service |
75d76b |
} AtomicSlabSummaryStatistics;
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
struct slabSummaryZone {
|
|
Packit Service |
75d76b |
/** The summary of which this is a zone */
|
|
Packit Service |
75d76b |
SlabSummary *summary;
|
|
Packit Service |
75d76b |
/** The number of this zone */
|
|
Packit Service |
75d76b |
ZoneCount zoneNumber;
|
|
Packit Service |
75d76b |
/** Count of the number of blocks currently out for writing */
|
|
Packit Service |
75d76b |
BlockCount writeCount;
|
|
Packit Service |
75d76b |
/** The state of this zone */
|
|
Packit Service |
75d76b |
AdminState state;
|
|
Packit Service |
75d76b |
/** The array (owned by the blocks) of all entries */
|
|
Packit Service |
75d76b |
SlabSummaryEntry *entries;
|
|
Packit Service |
75d76b |
/** The array of SlabSummaryEntryBlocks */
|
|
Packit Service |
75d76b |
SlabSummaryBlock summaryBlocks[];
|
|
Packit Service |
75d76b |
};
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
struct slabSummary {
|
|
Packit Service |
75d76b |
/** The context for entering read-only mode */
|
|
Packit Service |
75d76b |
ReadOnlyNotifier *readOnlyNotifier;
|
|
Packit Service |
75d76b |
/** The statistics for this slab summary */
|
|
Packit Service |
75d76b |
AtomicSlabSummaryStatistics statistics;
|
|
Packit Service |
75d76b |
/** The start of the slab summary partition relative to the layer */
|
|
Packit Service |
75d76b |
PhysicalBlockNumber origin;
|
|
Packit Service |
75d76b |
/** The number of bits to shift to get a 7-bit fullness hint */
|
|
Packit Service |
75d76b |
unsigned int hintShift;
|
|
Packit Service |
75d76b |
/** The number of blocks (calculated based on MAX_SLABS) */
|
|
Packit Service |
75d76b |
BlockCount blocksPerZone;
|
|
Packit Service |
75d76b |
/** The number of slabs per block (calculated from block size) */
|
|
Packit Service |
75d76b |
SlabCount entriesPerBlock;
|
|
Packit Service |
75d76b |
/** The entries for all of the zones the partition can hold */
|
|
Packit Service |
75d76b |
SlabSummaryEntry *entries;
|
|
Packit Service |
75d76b |
/** The number of zones which were active at the time of the last update */
|
|
Packit Service |
75d76b |
ZoneCount zonesToCombine;
|
|
Packit Service |
75d76b |
/** The current number of active zones */
|
|
Packit Service |
75d76b |
ZoneCount zoneCount;
|
|
Packit Service |
75d76b |
/** The currently active zones */
|
|
Packit Service |
75d76b |
SlabSummaryZone *zones[];
|
|
Packit Service |
75d76b |
};
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
/**
|
|
Packit Service |
75d76b |
* Treating the current entries buffer as the on-disk value of all zones,
|
|
Packit Service |
75d76b |
* update every zone to the correct values for every slab.
|
|
Packit Service |
75d76b |
*
|
|
Packit Service |
75d76b |
* @param summary The summary whose entries should be combined
|
|
Packit Service |
75d76b |
**/
|
|
Packit Service |
75d76b |
void combineZones(SlabSummary *summary);
|
|
Packit Service |
75d76b |
|
|
Packit Service |
75d76b |
#endif // SLAB_SUMMARY_INTERNALS_H
|