Blame source/vdo/base/superBlock.h

Packit Service 75d76b
/*
Packit Service 75d76b
 * Copyright (c) 2020 Red Hat, Inc.
Packit Service 75d76b
 *
Packit Service 75d76b
 * This program is free software; you can redistribute it and/or
Packit Service 75d76b
 * modify it under the terms of the GNU General Public License
Packit Service 75d76b
 * as published by the Free Software Foundation; either version 2
Packit Service 75d76b
 * of the License, or (at your option) any later version.
Packit Service 75d76b
 * 
Packit Service 75d76b
 * This program is distributed in the hope that it will be useful,
Packit Service 75d76b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 75d76b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 75d76b
 * GNU General Public License for more details.
Packit Service 75d76b
 * 
Packit Service 75d76b
 * You should have received a copy of the GNU General Public License
Packit Service 75d76b
 * along with this program; if not, write to the Free Software
Packit Service 75d76b
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service 75d76b
 * 02110-1301, USA. 
Packit Service 75d76b
 *
Packit Service 75d76b
 * $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/superBlock.h#2 $
Packit Service 75d76b
 */
Packit Service 75d76b
Packit Service 75d76b
#ifndef SUPER_BLOCK_H
Packit Service 75d76b
#define SUPER_BLOCK_H
Packit Service 75d76b
Packit Service 75d76b
#include "buffer.h"
Packit Service 75d76b
Packit Service 75d76b
#include "completion.h"
Packit Service 75d76b
#include "types.h"
Packit Service 75d76b
Packit Service 75d76b
typedef struct superBlock SuperBlock;
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Make a new super block.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param [in]  layer          The layer on which to write this super block
Packit Service 75d76b
 * @param [out] superBlockPtr  A pointer to hold the new super block
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return VDO_SUCCESS or an error
Packit Service 75d76b
 **/
Packit Service 75d76b
int makeSuperBlock(PhysicalLayer *layer, SuperBlock **superBlockPtr)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Free a super block and null out the reference to it.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param superBlockPtr the reference to the super block to free
Packit Service 75d76b
 **/
Packit Service 75d76b
void freeSuperBlock(SuperBlock **superBlockPtr);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Save a super block.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param layer             The physical layer on which to save the super block
Packit Service 75d76b
 * @param superBlock        The super block to save
Packit Service 75d76b
 * @param superBlockOffset  The location of the super block
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return VDO_SUCCESS or an error
Packit Service 75d76b
 **/
Packit Service 75d76b
int saveSuperBlock(PhysicalLayer       *layer,
Packit Service 75d76b
                   SuperBlock          *superBlock,
Packit Service 75d76b
                   PhysicalBlockNumber  superBlockOffset)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Save a super block asynchronously.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param superBlock        The super block to save
Packit Service 75d76b
 * @param superBlockOffset  The location at which to write the super block
Packit Service 75d76b
 * @param parent            The object to notify when the save is complete
Packit Service 75d76b
 **/
Packit Service 75d76b
void saveSuperBlockAsync(SuperBlock          *superBlock,
Packit Service 75d76b
                         PhysicalBlockNumber  superBlockOffset,
Packit Service 75d76b
                         VDOCompletion       *parent);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Allocate a super block and read its contents from storage.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param [in]  layer             The layer from which to load the super block
Packit Service 75d76b
 * @param [in]  superBlockOffset  The location from which to read the super
Packit Service 75d76b
 *                                block
Packit Service 75d76b
 * @param [out] superBlockPtr     A pointer to hold the loaded super block
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return VDO_SUCCESS or an error
Packit Service 75d76b
 **/
Packit Service 75d76b
int loadSuperBlock(PhysicalLayer        *layer,
Packit Service 75d76b
                   PhysicalBlockNumber   superBlockOffset,
Packit Service 75d76b
                   SuperBlock          **superBlockPtr)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Allocate a super block and read its contents from storage asynchronously. If
Packit Service 75d76b
 * a load error occurs before the super block's own completion can be allocated,
Packit Service 75d76b
 * the parent will be finished with the error.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param [in]  parent            The completion to finish after loading the
Packit Service 75d76b
 *                                super block
Packit Service 75d76b
 * @param [in]  superBlockOffset  The location from which to read the super
Packit Service 75d76b
 *                                block
Packit Service 75d76b
 * @param [out] superBlockPtr     A pointer to hold the super block
Packit Service 75d76b
 **/
Packit Service 75d76b
void loadSuperBlockAsync(VDOCompletion        *parent,
Packit Service 75d76b
                         PhysicalBlockNumber   superBlockOffset,
Packit Service 75d76b
                         SuperBlock          **superBlockPtr);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get a buffer which contains the component data from a super block.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param superBlock  The super block from which to get the component data
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return the component data in a buffer
Packit Service 75d76b
 **/
Packit Service 75d76b
Buffer *getComponentBuffer(SuperBlock *superBlock)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the release version number that was loaded from the volume when the
Packit Service 75d76b
 * SuperBlock was decoded.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param superBlock  The super block to query
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return the release version number that was decoded from the volume
Packit Service 75d76b
 **/
Packit Service 75d76b
ReleaseVersionNumber getLoadedReleaseVersion(const SuperBlock *superBlock)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the encoded size of the fixed (non-component data) portion of a super
Packit Service 75d76b
 * block (this is for unit testing).
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The encoded size of the fixed portion of the super block
Packit Service 75d76b
 **/
Packit Service 75d76b
size_t getFixedSuperBlockSize(void)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
#endif /* SUPER_BLOCK_H */