|
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/slabDepot.h#12 $
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#ifndef SLAB_DEPOT_H
|
|
Packit Service |
b3514a |
#define SLAB_DEPOT_H
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "buffer.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "adminState.h"
|
|
Packit Service |
b3514a |
#include "completion.h"
|
|
Packit Service |
b3514a |
#include "fixedLayout.h"
|
|
Packit Service |
b3514a |
#include "journalPoint.h"
|
|
Packit Service |
b3514a |
#include "statistics.h"
|
|
Packit Service |
b3514a |
#include "types.h"
|
|
Packit Service |
b3514a |
#include "waitQueue.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* A SlabDepot is responsible for managing all of the slabs and block
|
|
Packit Service |
b3514a |
* allocators of a VDO. It has a single array of slabs in order to eliminate
|
|
Packit Service |
b3514a |
* the need for additional math in order to compute which physical zone a PBN
|
|
Packit Service |
b3514a |
* is in. It also has a BlockAllocator per zone.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* Load operations are required to be performed on a single thread. Normal
|
|
Packit Service |
b3514a |
* operations are assumed to be performed in the appropriate zone. Allocations
|
|
Packit Service |
b3514a |
* and reference count updates must be done from the thread of their physical
|
|
Packit Service |
b3514a |
* zone. Requests to commit slab journal tail blocks from the recovery journal
|
|
Packit Service |
b3514a |
* must be done on the journal zone thread. Save operations are required to be
|
|
Packit Service |
b3514a |
* launched from the same thread as the original load operation.
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
typedef enum {
|
|
Packit Service |
b3514a |
NORMAL_LOAD,
|
|
Packit Service |
b3514a |
RECOVERY_LOAD,
|
|
Packit Service |
b3514a |
REBUILD_LOAD
|
|
Packit Service |
b3514a |
} SlabDepotLoadType;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Calculate the number of slabs a depot would have.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The number of slabs
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabCount calculateSlabCount(SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Create a slab depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param [in] blockCount The number of blocks initially available
|
|
Packit Service |
b3514a |
* @param [in] firstBlock The number of the first block which may be
|
|
Packit Service |
b3514a |
* allocated
|
|
Packit Service |
b3514a |
* @param [in] slabConfig The slab configuration
|
|
Packit Service |
b3514a |
* @param [in] threadConfig The thread configuration of the VDO
|
|
Packit Service |
b3514a |
* @param [in] nonce The nonce of the VDO
|
|
Packit Service |
b3514a |
* @param [in] vioPoolSize The size of the VIO pool
|
|
Packit Service |
b3514a |
* @param [in] layer The physical layer below this depot
|
|
Packit Service |
b3514a |
* @param [in] summaryPartition The partition which holds the slab summary
|
|
Packit Service |
b3514a |
* @param [in] readOnlyNotifier The context for entering read-only mode
|
|
Packit Service |
b3514a |
* @param [in] recoveryJournal The recovery journal of the VDO
|
|
Packit Service |
b3514a |
* @param [out] depotPtr A pointer to hold the depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return A success or error code
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int makeSlabDepot(BlockCount blockCount,
|
|
Packit Service |
b3514a |
PhysicalBlockNumber firstBlock,
|
|
Packit Service |
b3514a |
SlabConfig slabConfig,
|
|
Packit Service |
b3514a |
const ThreadConfig *threadConfig,
|
|
Packit Service |
b3514a |
Nonce nonce,
|
|
Packit Service |
b3514a |
BlockCount vioPoolSize,
|
|
Packit Service |
b3514a |
PhysicalLayer *layer,
|
|
Packit Service |
b3514a |
Partition *summaryPartition,
|
|
Packit Service |
b3514a |
ReadOnlyNotifier *readOnlyNotifier,
|
|
Packit Service |
b3514a |
RecoveryJournal *recoveryJournal,
|
|
Packit Service |
b3514a |
SlabDepot **depotPtr)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Destroy a slab depot and null out the reference to it.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depotPtr The reference to the depot to destroy
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void freeSlabDepot(SlabDepot **depotPtr);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the size of the encoded state of a slab depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The encoded size of the depot's state
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
size_t getSlabDepotEncodedSize(void)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Encode the state of a slab depot into a buffer.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to encode
|
|
Packit Service |
b3514a |
* @param buffer The buffer to encode into
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return UDS_SUCCESS or an error
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int encodeSlabDepot(const SlabDepot *depot, Buffer *buffer)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Decode the state of a slab depot saved in a buffer.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param [in] buffer The buffer containing the saved state
|
|
Packit Service |
b3514a |
* @param [in] threadConfig The thread config of the VDO
|
|
Packit Service |
b3514a |
* @param [in] nonce The nonce of the VDO
|
|
Packit Service |
b3514a |
* @param [in] layer The physical layer below this depot
|
|
Packit Service |
b3514a |
* @param [in] summaryPartition The partition which holds the slab summary
|
|
Packit Service |
b3514a |
* @param [in] readOnlyNotifier The context for entering read-only mode
|
|
Packit Service |
b3514a |
* @param [in] recoveryJournal The recovery journal of the VDO
|
|
Packit Service |
b3514a |
* @param [out] depotPtr A pointer to hold the depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return A success or error code
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int decodeSodiumSlabDepot(Buffer *buffer,
|
|
Packit Service |
b3514a |
const ThreadConfig *threadConfig,
|
|
Packit Service |
b3514a |
Nonce nonce,
|
|
Packit Service |
b3514a |
PhysicalLayer *layer,
|
|
Packit Service |
b3514a |
Partition *summaryPartition,
|
|
Packit Service |
b3514a |
ReadOnlyNotifier *readOnlyNotifier,
|
|
Packit Service |
b3514a |
RecoveryJournal *recoveryJournal,
|
|
Packit Service |
b3514a |
SlabDepot **depotPtr)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Decode the state of a slab depot saved in a buffer.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param [in] buffer The buffer containing the saved state
|
|
Packit Service |
b3514a |
* @param [in] threadConfig The thread config of the VDO
|
|
Packit Service |
b3514a |
* @param [in] nonce The nonce of the VDO
|
|
Packit Service |
b3514a |
* @param [in] layer The physical layer below this depot
|
|
Packit Service |
b3514a |
* @param [in] summaryPartition The partition which holds the slab summary
|
|
Packit Service |
b3514a |
* @param [in] readOnlyNotifier The context for entering read-only mode
|
|
Packit Service |
b3514a |
* @param [in] recoveryJournal The recovery journal of the VDO
|
|
Packit Service |
b3514a |
* @param [out] depotPtr A pointer to hold the depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return A success or error code
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int decodeSlabDepot(Buffer *buffer,
|
|
Packit Service |
b3514a |
const ThreadConfig *threadConfig,
|
|
Packit Service |
b3514a |
Nonce nonce,
|
|
Packit Service |
b3514a |
PhysicalLayer *layer,
|
|
Packit Service |
b3514a |
Partition *summaryPartition,
|
|
Packit Service |
b3514a |
ReadOnlyNotifier *readOnlyNotifier,
|
|
Packit Service |
b3514a |
RecoveryJournal *recoveryJournal,
|
|
Packit Service |
b3514a |
SlabDepot **depotPtr)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Allocate the RefCounts for all slabs in the depot. This method may be called
|
|
Packit Service |
b3514a |
* only before entering normal operation from the load thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot whose RefCounts need allocation
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int allocateSlabRefCounts(SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the block allocator for a specified physical zone from a depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
* @param zoneNumber The physical zone
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The block allocator for the specified zone
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockAllocator *getBlockAllocatorForZone(SlabDepot *depot,
|
|
Packit Service |
b3514a |
ZoneCount zoneNumber)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the number of the slab that contains a specified block.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
* @param pbn The physical block number
|
|
Packit Service |
b3514a |
* @param slabNumberPtr A pointer to hold the slab number
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int getSlabNumber(const SlabDepot *depot,
|
|
Packit Service |
b3514a |
PhysicalBlockNumber pbn,
|
|
Packit Service |
b3514a |
SlabCount *slabNumberPtr)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the slab object for the slab that contains a specified block. Will put
|
|
Packit Service |
b3514a |
* the VDO in read-only mode if the PBN is not a valid data block nor the zero
|
|
Packit Service |
b3514a |
* block.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
* @param pbn The physical block number
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The slab containing the block, or NULL if the block number is the
|
|
Packit Service |
b3514a |
* zero block or otherwise out of range
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
Slab *getSlab(const SlabDepot *depot, PhysicalBlockNumber pbn)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the slab journal for the slab that contains a specified block.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
* @param pbn The physical block number within the block depot partition
|
|
Packit Service |
b3514a |
* of any block in the slab
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The slab journal of the slab containing the block, or NULL if the
|
|
Packit Service |
b3514a |
* block number is for the zero block or otherwise out of range
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabJournal *getSlabJournal(const SlabDepot *depot, PhysicalBlockNumber pbn)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Determine how many new references a block can acquire. This method must be
|
|
Packit Service |
b3514a |
* called from the the physical zone thread of the PBN.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
* @param pbn The physical block number that is being queried
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return the number of available references
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
uint8_t getIncrementLimit(SlabDepot *depot, PhysicalBlockNumber pbn)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Determine whether the given PBN refers to a data block.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
* @param pbn The physical block number to ask about
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return True if the PBN corresponds to a data block
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
bool isPhysicalDataBlock(const SlabDepot *depot, PhysicalBlockNumber pbn)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the total number of data blocks allocated across all the slabs in the
|
|
Packit Service |
b3514a |
* depot, which is the total number of blocks with a non-zero reference count.
|
|
Packit Service |
b3514a |
* This may be called from any thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The total number of blocks with a non-zero reference count
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount getDepotAllocatedBlocks(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the total of the statistics from all the block allocators in the depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The statistics from all block allocators in the depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockAllocatorStatistics
|
|
Packit Service |
b3514a |
getDepotBlockAllocatorStatistics(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the total number of data blocks in all the slabs in the depot. This may
|
|
Packit Service |
b3514a |
* be called from any thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The total number of data blocks in all slabs
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount getDepotDataBlocks(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the total number of free blocks remaining in all the slabs in the
|
|
Packit Service |
b3514a |
* depot, which is the total number of blocks that have a zero reference
|
|
Packit Service |
b3514a |
* count. This may be called from any thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The total number of blocks with a zero reference count
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount getDepotFreeBlocks(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the total number of slabs in the depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The total number of slabs
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabCount getDepotSlabCount(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the total number of unrecovered slabs in the depot, which is the total
|
|
Packit Service |
b3514a |
* number of unrecovered slabs from all zones. This may be called from any
|
|
Packit Service |
b3514a |
* thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The total number of slabs that are unrecovered
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabCount getDepotUnrecoveredSlabCount(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the aggregated slab journal statistics for the depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The aggregated statistics for all slab journals in the depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabJournalStatistics getDepotSlabJournalStatistics(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the cumulative RefCounts statistics for the depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The cumulative statistics for all RefCounts in the depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
RefCountsStatistics getDepotRefCountsStatistics(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Asynchronously load any slab depot state that isn't included in the
|
|
Packit Service |
b3514a |
* SuperBlock component. This method may be called only before entering normal
|
|
Packit Service |
b3514a |
* operation from the load thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to load
|
|
Packit Service |
b3514a |
* @param operation The type of load to perform
|
|
Packit Service |
b3514a |
* @param parent The completion to finish when the load is complete
|
|
Packit Service |
b3514a |
* @param context Additional context for the load operation; may be NULL
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void loadSlabDepot(SlabDepot *depot,
|
|
Packit Service |
b3514a |
AdminStateCode operation,
|
|
Packit Service |
b3514a |
VDOCompletion *parent,
|
|
Packit Service |
b3514a |
void *context);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Prepare the slab depot to come online and start allocating blocks. This
|
|
Packit Service |
b3514a |
* method may be called only before entering normal operation from the load
|
|
Packit Service |
b3514a |
* thread. It must be called before allocation may proceed.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to prepare
|
|
Packit Service |
b3514a |
* @param loadType The load type
|
|
Packit Service |
b3514a |
* @param parent The completion to finish when the operation is complete
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void prepareToAllocate(SlabDepot *depot,
|
|
Packit Service |
b3514a |
SlabDepotLoadType loadType,
|
|
Packit Service |
b3514a |
VDOCompletion *parent);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Update the slab depot to reflect its new size in memory. This size is saved
|
|
Packit Service |
b3514a |
* to disk as part of the super block.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to update
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void updateSlabDepotSize(SlabDepot *depot);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Allocate new memory needed for a resize of a slab depot to the given size.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to prepare to resize
|
|
Packit Service |
b3514a |
* @param newSize The number of blocks in the new depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int prepareToGrowSlabDepot(SlabDepot *depot, BlockCount newSize)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Use the new slabs allocated for resize.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
* @param parent The object to notify when complete
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void useNewSlabs(SlabDepot *depot, VDOCompletion *parent);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Abandon any new slabs in this depot, freeing them as needed.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void abandonNewSlabs(SlabDepot *depot);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Drain all slab depot I/O. If saving, or flushing, all dirty depot metadata
|
|
Packit Service |
b3514a |
* will be written out. If saving or suspending, the depot will be left in a
|
|
Packit Service |
b3514a |
* suspended state.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to drain
|
|
Packit Service |
b3514a |
* @param operation The drain operation (flush, rebuild, suspend, or save)
|
|
Packit Service |
b3514a |
* @param parent The completion to finish when the drain is complete
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void drainSlabDepot(SlabDepot *depot,
|
|
Packit Service |
b3514a |
AdminStateCode operation,
|
|
Packit Service |
b3514a |
VDOCompletion *parent);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Resume a suspended slab depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to resume
|
|
Packit Service |
b3514a |
* @param parent The completion to finish when the depot has resumed
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void resumeSlabDepot(SlabDepot *depot, VDOCompletion *parent);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Commit all dirty tail blocks which are locking a given recovery journal
|
|
Packit Service |
b3514a |
* block. This method must be called from the journal zone thread.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot
|
|
Packit Service |
b3514a |
* @param recoveryBlockNumber The sequence number of the recovery journal
|
|
Packit Service |
b3514a |
* block whose locks should be released
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void commitOldestSlabJournalTailBlocks(SlabDepot *depot,
|
|
Packit Service |
b3514a |
SequenceNumber recoveryBlockNumber);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the SlabConfig of a depot.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The slab configuration of the specified depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
const SlabConfig *getSlabConfig(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the slab summary.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The slab summary
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabSummary *getSlabSummary(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the portion of the slab summary for a given physical zone.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
* @param zone The zone
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The portion of the slab summary for the specified zone
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
SlabSummaryZone *getSlabSummaryForZone(const SlabDepot *depot, ZoneCount zone)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Scrub all unrecovered slabs.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The depot to scrub
|
|
Packit Service |
b3514a |
* @param parent The object to notify when scrubbing is complete
|
|
Packit Service |
b3514a |
* @param callback The function to call when scrubbing is complete
|
|
Packit Service |
b3514a |
* @param errorHandler The handler for scrubbing errors
|
|
Packit Service |
b3514a |
* @param threadID The thread on which to run the callback
|
|
Packit Service |
b3514a |
* @param launchParent The object to notify when scrubbing has been launched
|
|
Packit Service |
b3514a |
* for all zones
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void scrubAllUnrecoveredSlabs(SlabDepot *depot,
|
|
Packit Service |
b3514a |
void *parent,
|
|
Packit Service |
b3514a |
VDOAction *callback,
|
|
Packit Service |
b3514a |
VDOAction *errorHandler,
|
|
Packit Service |
b3514a |
ThreadID threadID,
|
|
Packit Service |
b3514a |
VDOCompletion *launchParent);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Check whether there are outstanding unrecovered slabs.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return Whether there are outstanding unrecovered slabs
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
bool hasUnrecoveredSlabs(SlabDepot *depot);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the physical size to which this depot is prepared to grow.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The new number of blocks the depot will be grown to, or 0 if the
|
|
Packit Service |
b3514a |
* depot is not prepared to grow
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount getNewDepotSize(const SlabDepot *depot)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Dump the slab depot, in a thread-unsafe fashion.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param depot The slab depot
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void dumpSlabDepot(const SlabDepot *depot);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#endif // SLAB_DEPOT_H
|