|
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/blockMapInternals.h#12 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef BLOCK_MAP_INTERNALS_H
|
|
Packit Service |
310c69 |
#define BLOCK_MAP_INTERNALS_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "adminState.h"
|
|
Packit Service |
310c69 |
#include "blockMapEntry.h"
|
|
Packit Service |
310c69 |
#include "blockMapTree.h"
|
|
Packit Service |
310c69 |
#include "completion.h"
|
|
Packit Service |
310c69 |
#include "dirtyLists.h"
|
|
Packit Service |
310c69 |
#include "header.h"
|
|
Packit Service |
310c69 |
#include "intMap.h"
|
|
Packit Service |
310c69 |
#include "ringNode.h"
|
|
Packit Service |
310c69 |
#include "types.h"
|
|
Packit Service |
310c69 |
#include "vdoPageCache.h"
|
|
Packit Service |
310c69 |
#include "vioPool.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* The per-zone fields used by the block map tree.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
struct blockMapTreeZone {
|
|
Packit Service |
310c69 |
/** The BlockMapZone which owns this tree zone */
|
|
Packit Service |
310c69 |
BlockMapZone *mapZone;
|
|
Packit Service |
310c69 |
/** The lists of dirty tree pages */
|
|
Packit Service |
310c69 |
DirtyLists *dirtyLists;
|
|
Packit Service |
310c69 |
/** The number of tree lookups in progress */
|
|
Packit Service |
310c69 |
VIOCount activeLookups;
|
|
Packit Service |
310c69 |
/** The map of pages currently being loaded */
|
|
Packit Service |
310c69 |
IntMap *loadingPages;
|
|
Packit Service |
310c69 |
/** The pool of VIOs for tree I/O */
|
|
Packit Service |
310c69 |
VIOPool *vioPool;
|
|
Packit Service |
310c69 |
/** The tree page which has issued or will be issuing a flush */
|
|
Packit Service |
310c69 |
TreePage *flusher;
|
|
Packit Service |
310c69 |
/** The queue of pages waiting for a flush so they can be written out */
|
|
Packit Service |
310c69 |
WaitQueue flushWaiters;
|
|
Packit Service |
310c69 |
/** The generation after the most recent flush */
|
|
Packit Service |
310c69 |
uint8_t generation;
|
|
Packit Service |
310c69 |
/** The oldest active generation */
|
|
Packit Service |
310c69 |
uint8_t oldestGeneration;
|
|
Packit Service |
310c69 |
/** The counts of dirty pages in each generation */
|
|
Packit Service |
310c69 |
uint32_t dirtyPageCounts[256];
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* The per-zone fields of the block map.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
struct blockMapZone {
|
|
Packit Service |
310c69 |
/** The number of the zone this is */
|
|
Packit Service |
310c69 |
ZoneCount zoneNumber;
|
|
Packit Service |
310c69 |
/** The ID of this zone's logical thread */
|
|
Packit Service |
310c69 |
ThreadID threadID;
|
|
Packit Service |
310c69 |
/** The BlockMap which owns this BlockMapZone */
|
|
Packit Service |
310c69 |
BlockMap *blockMap;
|
|
Packit Service |
310c69 |
/** The ReadOnlyNotifier of the VDO */
|
|
Packit Service |
310c69 |
ReadOnlyNotifier *readOnlyNotifier;
|
|
Packit Service |
310c69 |
/** The page cache for this zone */
|
|
Packit Service |
310c69 |
VDOPageCache *pageCache;
|
|
Packit Service |
310c69 |
/** The per-zone portion of the tree for this zone */
|
|
Packit Service |
310c69 |
BlockMapTreeZone treeZone;
|
|
Packit Service |
310c69 |
/** The administrative state of the zone */
|
|
Packit Service |
310c69 |
AdminState state;
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
struct blockMap {
|
|
Packit Service |
310c69 |
/** The manager for block map actions */
|
|
Packit Service |
310c69 |
ActionManager *actionManager;
|
|
Packit Service |
310c69 |
/** The count of pages in the linear part of the block map */
|
|
Packit Service |
310c69 |
BlockCount flatPageCount;
|
|
Packit Service |
310c69 |
/** The absolute PBN of the first root of the tree part of the block map */
|
|
Packit Service |
310c69 |
PhysicalBlockNumber rootOrigin;
|
|
Packit Service |
310c69 |
/** The count of root pages of the tree part of the block map */
|
|
Packit Service |
310c69 |
BlockCount rootCount;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The era point we are currently distributing to the zones */
|
|
Packit Service |
310c69 |
SequenceNumber currentEraPoint;
|
|
Packit Service |
310c69 |
/** The next era point, not yet distributed to any zone */
|
|
Packit Service |
310c69 |
SequenceNumber pendingEraPoint;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The number of entries in block map */
|
|
Packit Service |
310c69 |
BlockCount entryCount;
|
|
Packit Service |
310c69 |
/** The VDO's nonce, for the pages */
|
|
Packit Service |
310c69 |
Nonce nonce;
|
|
Packit Service |
310c69 |
/** The recovery journal for this map */
|
|
Packit Service |
310c69 |
RecoveryJournal *journal;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The trees for finding block map pages */
|
|
Packit Service |
310c69 |
Forest *forest;
|
|
Packit Service |
310c69 |
/** The expanded trees awaiting growth */
|
|
Packit Service |
310c69 |
Forest *nextForest;
|
|
Packit Service |
310c69 |
/** The number of entries after growth */
|
|
Packit Service |
310c69 |
BlockCount nextEntryCount;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** The number of logical zones */
|
|
Packit Service |
310c69 |
ZoneCount zoneCount;
|
|
Packit Service |
310c69 |
/** The per zone block map structure */
|
|
Packit Service |
310c69 |
BlockMapZone zones[];
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Compute the number of pages required for a block map with the specified
|
|
Packit Service |
310c69 |
* parameters.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param entries The number of block map entries
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of pages required
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
PageCount computeBlockMapPageCount(BlockCount entries);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Compute the number of the block map page on which the entry for a given
|
|
Packit Service |
310c69 |
* logical block resides.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param lbn The logical block number whose page is desired
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The number of the block map page containing the entry for
|
|
Packit Service |
310c69 |
* the given logical block number
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
static inline PageNumber computePageNumber(LogicalBlockNumber lbn)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return (lbn / BLOCK_MAP_ENTRIES_PER_PAGE);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Find the block map page slot in which the entry for a given logical
|
|
Packit Service |
310c69 |
* block resides.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param lbn The logical block number whose slot
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The slot containing the entry for the given logical block number
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
static inline SlotNumber computeSlot(LogicalBlockNumber lbn)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return (lbn % BLOCK_MAP_ENTRIES_PER_PAGE);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether a zone of the block map has drained, and if so, send a
|
|
Packit Service |
310c69 |
* notification thereof.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The zone to check
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void checkForDrainComplete(BlockMapZone *zone);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif // BLOCK_MAP_INTERNALS_H
|