Blame source/vdo/base/vdo.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/vdo.h#3 $
Packit Service 75d76b
 */
Packit Service 75d76b
Packit Service 75d76b
#ifndef VDO_H
Packit Service 75d76b
#define VDO_H
Packit Service 75d76b
Packit Service 75d76b
#include "types.h"
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Allocate a VDO and associate it with its physical layer.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param [in]  layer       The physical layer the VDO sits on
Packit Service 75d76b
 * @param [out] vdoPtr      A pointer to hold the allocated VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return VDO_SUCCESS or an error
Packit Service 75d76b
 **/
Packit Service 75d76b
int allocateVDO(PhysicalLayer *layer, VDO **vdoPtr)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Construct a VDO for use in user space with a synchronous layer.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param [in]  layer   The physical layer the VDO sits on
Packit Service 75d76b
 * @param [out] vdoPtr  A pointer to hold the allocated VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return VDO_SUCCESS or an error
Packit Service 75d76b
 **/
Packit Service 75d76b
int makeVDO(PhysicalLayer *layer, VDO **vdoPtr)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Destroy a VDO instance.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO to destroy
Packit Service 75d76b
 **/
Packit Service 75d76b
void destroyVDO(VDO *vdo);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Destroy a VDO instance, free it, and null out the reference to it.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdoPtr  A reference to the VDO to free
Packit Service 75d76b
 **/
Packit Service 75d76b
void freeVDO(VDO **vdoPtr);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Put a VDO into read-only mode and save the read-only state in the super
Packit Service 75d76b
 * block.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo             The VDO to put into read-only mode
Packit Service 75d76b
 * @param errorCode       The error which caused the VDO to enter read-only
Packit Service 75d76b
 *                        mode
Packit Service 75d76b
 **/
Packit Service 75d76b
void makeVDOReadOnly(VDO *vdo, int errorCode);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Set whether compression is enabled in VDO.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo                The VDO
Packit Service 75d76b
 * @param enableCompression  Whether to enable compression in VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return State of compression before new value is set
Packit Service 75d76b
 **/
Packit Service 75d76b
bool setVDOCompressing(VDO *vdo, bool enableCompression);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get whether compression is enabled in VDO.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return State of compression
Packit Service 75d76b
 **/
Packit Service 75d76b
bool getVDOCompressing(VDO *vdo);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the VDO statistics.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param [in]  vdo    The VDO
Packit Service 75d76b
 * @param [out] stats  The VDO statistics are returned here
Packit Service 75d76b
 **/
Packit Service 75d76b
void getVDOStatistics(const VDO *vdo, VDOStatistics *stats);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the number of physical blocks in use by user data.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The number of blocks allocated for user data
Packit Service 75d76b
 **/
Packit Service 75d76b
BlockCount getPhysicalBlocksAllocated(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the number of unallocated physical blocks.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The number of free blocks
Packit Service 75d76b
 **/
Packit Service 75d76b
BlockCount getPhysicalBlocksFree(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the number of physical blocks used by VDO metadata.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The number of overhead blocks
Packit Service 75d76b
 **/
Packit Service 75d76b
BlockCount getPhysicalBlocksOverhead(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the total number of blocks used for the block map.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The number of block map blocks
Packit Service 75d76b
 **/
Packit Service 75d76b
BlockCount getTotalBlockMapBlocks(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the VDO write policy.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The write policy
Packit Service 75d76b
 **/
Packit Service 75d76b
WritePolicy getWritePolicy(const VDO *vdo);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Set the VDO write policy.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 * @param new  The new write policy
Packit Service 75d76b
 **/
Packit Service 75d76b
void setWritePolicy(VDO *vdo, WritePolicy new);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get a copy of the load-time configuration of the VDO.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The load-time configuration of the VDO
Packit Service 75d76b
 **/
Packit Service 75d76b
const VDOLoadConfig *getVDOLoadConfig(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the thread config of the VDO.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The thread config
Packit Service 75d76b
 **/
Packit Service 75d76b
const ThreadConfig *getThreadConfig(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the configured maximum age of a dirty block map page.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The block map era length
Packit Service 75d76b
 **/
Packit Service 75d76b
BlockCount getConfiguredBlockMapMaximumAge(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the configured page cache size of the VDO.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The number of pages for the page cache
Packit Service 75d76b
 **/
Packit Service 75d76b
PageCount getConfiguredCacheSize(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Get the location of the first block of the VDO.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The location of the first block managed by the VDO
Packit Service 75d76b
 **/
Packit Service 75d76b
PhysicalBlockNumber getFirstBlockOffset(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Check whether the VDO was new when it was loaded.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO to query
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return true if the VDO was new
Packit Service 75d76b
 **/
Packit Service 75d76b
bool wasNew(const VDO *vdo)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Check whether a DataLocation containing potential dedupe advice is
Packit Service 75d76b
 * well-formed and addresses a data block in one of the configured physical
Packit Service 75d76b
 * zones of the VDO. If it is, return the location and zone as a ZonedPBN;
Packit Service 75d76b
 * otherwise increment statistics tracking invalid advice and return an
Packit Service 75d76b
 * unmapped ZonedPBN.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo     The VDO
Packit Service 75d76b
 * @param advice  The advice to validate (NULL indicates no advice)
Packit Service 75d76b
 * @param lbn     The logical block number of the write that requested advice,
Packit Service 75d76b
 *                which is only used for debug-level logging of invalid advice
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return The ZonedPBN representing the advice, if valid, otherwise an
Packit Service 75d76b
 *         unmapped ZonedPBN if the advice was invalid or NULL
Packit Service 75d76b
 **/
Packit Service 75d76b
ZonedPBN validateDedupeAdvice(VDO                *vdo,
Packit Service 75d76b
                              const DataLocation *advice,
Packit Service 75d76b
                              LogicalBlockNumber  lbn)
Packit Service 75d76b
  __attribute__((warn_unused_result));
Packit Service 75d76b
Packit Service 75d76b
// TEST SUPPORT ONLY BEYOND THIS POINT
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Dump status information about VDO to the log for debugging.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The vdo to dump
Packit Service 75d76b
 **/
Packit Service 75d76b
void dumpVDOStatus(const VDO *vdo);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Set the VIO tracing flag.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo         The VDO
Packit Service 75d76b
 * @param vioTracing  Whether VIO tracing is enabled for this device
Packit Service 75d76b
 **/
Packit Service 75d76b
void setVDOTracingFlags(VDO *vdo, bool vioTracing);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Indicate whether VIO tracing is enabled.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return Whether VIO tracing is enabled
Packit Service 75d76b
 **/
Packit Service 75d76b
bool vdoVIOTracingEnabled(const VDO *vdo);
Packit Service 75d76b
Packit Service 75d76b
/**
Packit Service 75d76b
 * Indicate whether extent tracing is enabled.
Packit Service 75d76b
 *
Packit Service 75d76b
 * @param vdo  The VDO
Packit Service 75d76b
 *
Packit Service 75d76b
 * @return Whether extent tracing is enabled
Packit Service 75d76b
 **/
Packit Service 75d76b
bool vdoExtentTracingEnabled(const VDO *vdo);
Packit Service 75d76b
Packit Service 75d76b
#endif /* VDO_H */