|
Packit Service |
b3514a |
/*
|
|
Packit Service |
b3514a |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
b3514a |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
b3514a |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
b3514a |
* of the License, or (at your option) any later version.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
b3514a |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
b3514a |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
b3514a |
* GNU General Public License for more details.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
b3514a |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
b3514a |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
b3514a |
* 02110-1301, USA.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/slabDepotInternals.h#13 $
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#ifndef SLAB_DEPOT_INTERNALS_H
|
|
Packit Service |
b3514a |
#define SLAB_DEPOT_INTERNALS_H
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "slabDepot.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "atomic.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "actionManager.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
struct slabDepot {
|
|
Packit Service |
b3514a |
ZoneCount zoneCount;
|
|
Packit Service |
b3514a |
ZoneCount oldZoneCount;
|
|
Packit Service |
b3514a |
SlabConfig slabConfig;
|
|
Packit Service |
b3514a |
SlabSummary *slabSummary;
|
|
Packit Service |
b3514a |
ReadOnlyNotifier *readOnlyNotifier;
|
|
Packit Service |
b3514a |
ActionManager *actionManager;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
PhysicalBlockNumber firstBlock;
|
|
Packit Service |
b3514a |
PhysicalBlockNumber lastBlock;
|
|
Packit Service |
b3514a |
PhysicalBlockNumber origin;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** slabSize == (1 << slabSizeShift) */
|
|
Packit Service |
b3514a |
unsigned int slabSizeShift;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** Determines how slabs should be queued during load */
|
|
Packit Service |
b3514a |
SlabDepotLoadType loadType;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** The state for notifying slab journals to release recovery journal */
|
|
Packit Service |
b3514a |
SequenceNumber activeReleaseRequest;
|
|
Packit Service |
b3514a |
SequenceNumber newReleaseRequest;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** The completion for scrubbing */
|
|
Packit Service |
b3514a |
VDOCompletion scrubbingCompletion;
|
|
Packit Service |
b3514a |
Atomic32 zonesToScrub;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** Cached journal pointer for slab creation */
|
|
Packit Service |
b3514a |
RecoveryJournal *journal;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** Array of pointers to individually allocated slabs */
|
|
Packit Service |
b3514a |
Slab **slabs;
|
|
Packit Service |
b3514a |
/** The number of slabs currently allocated and stored in 'slabs' */
|
|
Packit Service |
b3514a |
SlabCount slabCount;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** Array of pointers to a larger set of slabs (used during resize) */
|
|
Packit Service |
b3514a |
Slab **newSlabs;
|
|
Packit Service |
b3514a |
/** The number of slabs currently allocated and stored in 'newSlabs' */
|
|
Packit Service |
b3514a |
SlabCount newSlabCount;
|
|
Packit Service |
b3514a |
/** The size that 'newSlabs' was allocated for */
|
|
Packit Service |
b3514a |
BlockCount newSize;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** The last block before resize, for rollback */
|
|
Packit Service |
b3514a |
PhysicalBlockNumber oldLastBlock;
|
|
Packit Service |
b3514a |
/** The last block after resize, for resize */
|
|
Packit Service |
b3514a |
PhysicalBlockNumber newLastBlock;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/** The block allocators for this depot */
|
|
Packit Service |
b3514a |
BlockAllocator *allocators[];
|
|
Packit Service |
b3514a |
};
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Destroy a slab.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param slab The slab to destroy
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void destroySlab(Slab *slab);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Inform a slab's depot that the slab has been created.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param slab The slab to register
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void registerSlabWithDepot(Slab *slab);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Notify a slab depot that one of its allocators has finished scrubbing slabs.
|
|
Packit Service |
b3514a |
* This method should only be called if the scrubbing was successful. This
|
|
Packit Service |
b3514a |
* callback is registered by each block allocator in
|
|
Packit Service |
b3514a |
* scrubAllUnrecoveredSlabsInZone().
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param completion A completion whose parent must be a slab depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void notifyZoneFinishedScrubbing(VDOCompletion *completion);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Check whether two depots are equivalent (i.e. represent the same
|
|
Packit Service |
b3514a |
* state and have the same reference counter). This method is used for unit
|
|
Packit Service |
b3514a |
* testing.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depotA The first depot to compare
|
|
Packit Service |
b3514a |
* @param depotB The second depot to compare
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return true if the two depots are equivalent
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
bool areEquivalentDepots(SlabDepot *depotA, SlabDepot *depotB)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Start allocating from the highest numbered slab in each zone.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void allocateFromLastSlab(SlabDepot *depot);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#endif /* SLAB_DEPOT_INTERNALS_H */
|