|
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/blockMapTreeInternals.h#4 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef BLOCK_MAP_TREE_INTERNALS_H
|
|
Packit Service |
310c69 |
#define BLOCK_MAP_TREE_INTERNALS_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "blockMapTree.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "blockMapPage.h"
|
|
Packit Service |
310c69 |
#include "types.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** A single page of a block map tree */
|
|
Packit Service |
310c69 |
struct treePage {
|
|
Packit Service |
310c69 |
/** Waiter for a VIO to write out this page */
|
|
Packit Service |
310c69 |
Waiter waiter;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** Dirty list node */
|
|
Packit Service |
310c69 |
RingNode node;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* If this is a dirty tree page, the tree zone flush generation in which it
|
|
Packit Service |
310c69 |
* was last dirtied.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
uint8_t generation;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** Whether this page is an interior tree page being written out. */
|
|
Packit Service |
310c69 |
bool writing;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* If this page is being written, the tree zone flush generation of the
|
|
Packit Service |
310c69 |
* copy of the page being written.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
uint8_t writingGeneration;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The earliest journal block containing uncommitted updates to this page */
|
|
Packit Service |
310c69 |
SequenceNumber recoveryLock;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The value of recoveryLock when the this page last started writing */
|
|
Packit Service |
310c69 |
SequenceNumber writingRecoveryLock;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The buffer to hold the on-disk representation of this page */
|
|
Packit Service |
310c69 |
char pageBuffer[VDO_BLOCK_SIZE];
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct {
|
|
Packit Service |
310c69 |
PageNumber levels[BLOCK_MAP_TREE_HEIGHT];
|
|
Packit Service |
310c69 |
} Boundary;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* An invalid PBN used to indicate that the page holding the location of a
|
|
Packit Service |
310c69 |
* tree root has been "loaded".
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
extern const PhysicalBlockNumber INVALID_PBN;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Extract the BlockMapPage from a TreePage.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param treePage The TreePage
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The BlockMapPage of the TreePage
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
static inline BlockMapPage *asBlockMapPage(TreePage *treePage)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return (BlockMapPage *) treePage->pageBuffer;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Replace the VIOPool in a tree zone. This method is used by unit tests.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The zone whose pool is to be replaced
|
|
Packit Service |
310c69 |
* @param layer The physical layer from which to make VIOs
|
|
Packit Service |
310c69 |
* @param poolSize The size of the new pool
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int replaceTreeZoneVIOPool(BlockMapTreeZone *zone,
|
|
Packit Service |
310c69 |
PhysicalLayer *layer,
|
|
Packit Service |
310c69 |
size_t poolSize)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether a buffer contains a valid page. If the page is bad, log an
|
|
Packit Service |
310c69 |
* error. If the page is valid, copy it to the supplied page.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param buffer The buffer to validate (and copy)
|
|
Packit Service |
310c69 |
* @param nonce The VDO nonce
|
|
Packit Service |
310c69 |
* @param pbn The absolute PBN of the page
|
|
Packit Service |
310c69 |
* @param page The page to copy into if valid
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the page was copied (valid)
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool copyValidPage(char *buffer,
|
|
Packit Service |
310c69 |
Nonce nonce,
|
|
Packit Service |
310c69 |
PhysicalBlockNumber pbn,
|
|
Packit Service |
310c69 |
BlockMapPage *page);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif // BLOCK_MAP_TREE_INTERNALS_H
|