|
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/vdoLayout.h#2 $
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* VDOLayout is an object which manages the layout of a VDO. It wraps
|
|
Packit Service |
b3514a |
* FixedLayout, but includes the knowledge of exactly which partitions a VDO is
|
|
Packit Service |
b3514a |
* expected to have. Because of this knowledge, the VDOLayout validates the
|
|
Packit Service |
b3514a |
* FixedLayout encoded in the super block at load time, obviating the need for
|
|
Packit Service |
b3514a |
* subsequent error checking when other modules need to get partitions from the
|
|
Packit Service |
b3514a |
* layout.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* The VDOLayout also manages the preparation and growth of the layout for grow
|
|
Packit Service |
b3514a |
* physical operations.
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#ifndef VDO_LAYOUT_H
|
|
Packit Service |
b3514a |
#define VDO_LAYOUT_H
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "fixedLayout.h"
|
|
Packit Service |
b3514a |
#include "types.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Make a VDO layout with the specified parameters.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param [in] physicalBlocks The number of physical blocks in the VDO
|
|
Packit Service |
b3514a |
* @param [in] startingOffset The starting offset of the layout
|
|
Packit Service |
b3514a |
* @param [in] blockMapBlocks The size of the block map partition
|
|
Packit Service |
b3514a |
* @param [in] journalBlocks The size of the journal partition
|
|
Packit Service |
b3514a |
* @param [in] summaryBlocks The size of the slab summary partition
|
|
Packit Service |
b3514a |
* @param [out] vdoLayoutPtr A pointer to hold the new VDOLayout
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int makeVDOLayout(BlockCount physicalBlocks,
|
|
Packit Service |
b3514a |
PhysicalBlockNumber startingOffset,
|
|
Packit Service |
b3514a |
BlockCount blockMapBlocks,
|
|
Packit Service |
b3514a |
BlockCount journalBlocks,
|
|
Packit Service |
b3514a |
BlockCount summaryBlocks,
|
|
Packit Service |
b3514a |
VDOLayout **vdoLayoutPtr)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Decode a VDOLayout from a buffer.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param [in] buffer The buffer from which to decode
|
|
Packit Service |
b3514a |
* @param [out] vdoLayoutPtr A pointer to hold the VDOLayout
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int decodeVDOLayout(Buffer *buffer, VDOLayout **vdoLayoutPtr)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Free a VDOLayout and NULL out the reference to it.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayoutPtr The pointer to a VDOLayout to free
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void freeVDOLayout(VDOLayout **vdoLayoutPtr);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get a partition from a VDOLayout. Because the layout's FixedLayout has
|
|
Packit Service |
b3514a |
* already been validated, this can not fail.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The VDOLayout from which to get the partition
|
|
Packit Service |
b3514a |
* @param id The ID of the desired partition
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The requested partition
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
Partition *getVDOPartition(VDOLayout *vdoLayout, PartitionID id)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Prepare the layout to be grown.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The layout to grow
|
|
Packit Service |
b3514a |
* @param oldPhysicalBlocks The current size of the VDO
|
|
Packit Service |
b3514a |
* @param newPhysicalBlocks The size to which the VDO will be grown
|
|
Packit Service |
b3514a |
* @param layer The layer being grown
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return VDO_SUCCESS or an error code
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
int prepareToGrowVDOLayout(VDOLayout *vdoLayout,
|
|
Packit Service |
b3514a |
BlockCount oldPhysicalBlocks,
|
|
Packit Service |
b3514a |
BlockCount newPhysicalBlocks,
|
|
Packit Service |
b3514a |
PhysicalLayer *layer)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the size of the next layout.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The layout to check
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The size which was specified when the layout was prepared for growth
|
|
Packit Service |
b3514a |
* or 0 if the layout is not prepared to grow
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount getNextVDOLayoutSize(VDOLayout *vdoLayout)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the size of the next block allocator partition.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The VDOLayout which has been prepared to grow
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The size of the block allocator partition in the next layout or 0
|
|
Packit Service |
b3514a |
* if the layout is not prepared to grow
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount getNextBlockAllocatorPartitionSize(VDOLayout *vdoLayout)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Grow the layout by swapping in the prepared layout.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The layout to grow
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The new size of the VDO
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount growVDOLayout(VDOLayout *vdoLayout)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Revert the last growth attempt.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The layout to revert
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The reverted size (in blocks) of the VDO
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
BlockCount revertVDOLayout(VDOLayout *vdoLayout)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Clean up any unused resources once an attempt to grow has completed.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The layout
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void finishVDOLayoutGrowth(VDOLayout *vdoLayout);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Copy a partition from the location specified in the current layout to that in
|
|
Packit Service |
b3514a |
* the next layout.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param layout The VDOLayout which is prepared to grow
|
|
Packit Service |
b3514a |
* @param partitionID The ID of the partition to copy
|
|
Packit Service |
b3514a |
* @param parent The completion to notify when the copy is complete
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void copyPartition(VDOLayout *layout,
|
|
Packit Service |
b3514a |
PartitionID partitionID,
|
|
Packit Service |
b3514a |
VDOCompletion *parent);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the size of an encoded VDOLayout.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The VDOLayout
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The encoded size of the VDOLayout
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
size_t getVDOLayoutEncodedSize(const VDOLayout *vdoLayout)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Encode a VDOLayout into a buffer.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param vdoLayout The VDOLayout 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 encodeVDOLayout(const VDOLayout *vdoLayout, Buffer *buffer)
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result));
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#endif // VDO_LAYOUT_H
|