|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/blockMappingState.h#1 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef BLOCK_MAPPING_STATE_H
|
|
Packit Service |
310c69 |
#define BLOCK_MAPPING_STATE_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "common.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Four bits of each five-byte block map entry contain a mapping state value
|
|
Packit Service |
310c69 |
* used to distinguish unmapped or trimmed logical blocks (which are treated
|
|
Packit Service |
310c69 |
* as mapped to the zero block) from entries that have been mapped to a
|
|
Packit Service |
310c69 |
* physical block, including the zero block.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
typedef enum {
|
|
Packit Service |
310c69 |
MAPPING_STATE_UNMAPPED = 0, // Must be zero to be the default value
|
|
Packit Service |
310c69 |
MAPPING_STATE_UNCOMPRESSED = 1, // A normal (uncompressed) block
|
|
Packit Service |
310c69 |
MAPPING_STATE_COMPRESSED_BASE = 2, // Compressed in slot 0
|
|
Packit Service |
310c69 |
MAPPING_STATE_COMPRESSED_MAX = 15, // Compressed in slot 13
|
|
Packit Service |
310c69 |
} BlockMappingState;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* The total number of compressed blocks that can live in a physical block.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
enum {
|
|
Packit Service |
310c69 |
MAX_COMPRESSION_SLOTS =
|
|
Packit Service |
310c69 |
MAPPING_STATE_COMPRESSED_MAX - MAPPING_STATE_COMPRESSED_BASE + 1,
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
static inline BlockMappingState getStateForSlot(byte slotNumber)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return (slotNumber + MAPPING_STATE_COMPRESSED_BASE);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
static inline byte getSlotFromState(BlockMappingState mappingState)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return (mappingState - MAPPING_STATE_COMPRESSED_BASE);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
static inline bool isCompressed(const BlockMappingState mappingState)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return (mappingState > MAPPING_STATE_UNCOMPRESSED);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif // BLOCK_MAPPING_STATE_H
|