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