|
Packit Service |
d40955 |
/*
|
|
Packit Service |
d40955 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
d40955 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
d40955 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
d40955 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
d40955 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
d40955 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
d40955 |
* GNU General Public License for more details.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
d40955 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
d40955 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
d40955 |
* 02110-1301, USA.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/vdoLayout.h#2 $
|
|
Packit Service |
d40955 |
*/
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* VDOLayout is an object which manages the layout of a VDO. It wraps
|
|
Packit Service |
d40955 |
* FixedLayout, but includes the knowledge of exactly which partitions a VDO is
|
|
Packit Service |
d40955 |
* expected to have. Because of this knowledge, the VDOLayout validates the
|
|
Packit Service |
d40955 |
* FixedLayout encoded in the super block at load time, obviating the need for
|
|
Packit Service |
d40955 |
* subsequent error checking when other modules need to get partitions from the
|
|
Packit Service |
d40955 |
* layout.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* The VDOLayout also manages the preparation and growth of the layout for grow
|
|
Packit Service |
d40955 |
* physical operations.
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#ifndef VDO_LAYOUT_H
|
|
Packit Service |
d40955 |
#define VDO_LAYOUT_H
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "fixedLayout.h"
|
|
Packit Service |
d40955 |
#include "types.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Make a VDO layout with the specified parameters.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param [in] physicalBlocks The number of physical blocks in the VDO
|
|
Packit Service |
d40955 |
* @param [in] startingOffset The starting offset of the layout
|
|
Packit Service |
d40955 |
* @param [in] blockMapBlocks The size of the block map partition
|
|
Packit Service |
d40955 |
* @param [in] journalBlocks The size of the journal partition
|
|
Packit Service |
d40955 |
* @param [in] summaryBlocks The size of the slab summary partition
|
|
Packit Service |
d40955 |
* @param [out] vdoLayoutPtr A pointer to hold the new VDOLayout
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
int makeVDOLayout(BlockCount physicalBlocks,
|
|
Packit Service |
d40955 |
PhysicalBlockNumber startingOffset,
|
|
Packit Service |
d40955 |
BlockCount blockMapBlocks,
|
|
Packit Service |
d40955 |
BlockCount journalBlocks,
|
|
Packit Service |
d40955 |
BlockCount summaryBlocks,
|
|
Packit Service |
d40955 |
VDOLayout **vdoLayoutPtr)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Decode a VDOLayout from a buffer.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param [in] buffer The buffer from which to decode
|
|
Packit Service |
d40955 |
* @param [out] vdoLayoutPtr A pointer to hold the VDOLayout
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
int decodeVDOLayout(Buffer *buffer, VDOLayout **vdoLayoutPtr)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Free a VDOLayout and NULL out the reference to it.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayoutPtr The pointer to a VDOLayout to free
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
void freeVDOLayout(VDOLayout **vdoLayoutPtr);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Get a partition from a VDOLayout. Because the layout's FixedLayout has
|
|
Packit Service |
d40955 |
* already been validated, this can not fail.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The VDOLayout from which to get the partition
|
|
Packit Service |
d40955 |
* @param id The ID of the desired partition
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The requested partition
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
Partition *getVDOPartition(VDOLayout *vdoLayout, PartitionID id)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Prepare the layout to be grown.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The layout to grow
|
|
Packit Service |
d40955 |
* @param oldPhysicalBlocks The current size of the VDO
|
|
Packit Service |
d40955 |
* @param newPhysicalBlocks The size to which the VDO will be grown
|
|
Packit Service |
d40955 |
* @param layer The layer being grown
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return VDO_SUCCESS or an error code
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
int prepareToGrowVDOLayout(VDOLayout *vdoLayout,
|
|
Packit Service |
d40955 |
BlockCount oldPhysicalBlocks,
|
|
Packit Service |
d40955 |
BlockCount newPhysicalBlocks,
|
|
Packit Service |
d40955 |
PhysicalLayer *layer)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Get the size of the next layout.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The layout to check
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The size which was specified when the layout was prepared for growth
|
|
Packit Service |
d40955 |
* or 0 if the layout is not prepared to grow
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
BlockCount getNextVDOLayoutSize(VDOLayout *vdoLayout)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Get the size of the next block allocator partition.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The VDOLayout which has been prepared to grow
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The size of the block allocator partition in the next layout or 0
|
|
Packit Service |
d40955 |
* if the layout is not prepared to grow
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
BlockCount getNextBlockAllocatorPartitionSize(VDOLayout *vdoLayout)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Grow the layout by swapping in the prepared layout.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The layout to grow
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The new size of the VDO
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
BlockCount growVDOLayout(VDOLayout *vdoLayout)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Revert the last growth attempt.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The layout to revert
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The reverted size (in blocks) of the VDO
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
BlockCount revertVDOLayout(VDOLayout *vdoLayout)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Clean up any unused resources once an attempt to grow has completed.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The layout
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
void finishVDOLayoutGrowth(VDOLayout *vdoLayout);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Copy a partition from the location specified in the current layout to that in
|
|
Packit Service |
d40955 |
* the next layout.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param layout The VDOLayout which is prepared to grow
|
|
Packit Service |
d40955 |
* @param partitionID The ID of the partition to copy
|
|
Packit Service |
d40955 |
* @param parent The completion to notify when the copy is complete
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
void copyPartition(VDOLayout *layout,
|
|
Packit Service |
d40955 |
PartitionID partitionID,
|
|
Packit Service |
d40955 |
VDOCompletion *parent);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Get the size of an encoded VDOLayout.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The VDOLayout
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The encoded size of the VDOLayout
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
size_t getVDOLayoutEncodedSize(const VDOLayout *vdoLayout)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Encode a VDOLayout into a buffer.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdoLayout The VDOLayout to encode
|
|
Packit Service |
d40955 |
* @param buffer The buffer to encode into
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return UDS_SUCCESS or an error
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
int encodeVDOLayout(const VDOLayout *vdoLayout, Buffer *buffer)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#endif // VDO_LAYOUT_H
|