|
Packit Service |
d40955 |
/*
|
|
Packit Service |
d40955 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
d40955 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
d40955 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
d40955 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
d40955 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
d40955 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
d40955 |
* GNU General Public License for more details.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
d40955 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
d40955 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
d40955 |
* 02110-1301, USA.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/vdoRecoveryInternals.h#2 $
|
|
Packit Service |
d40955 |
*/
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#ifndef VDO_RECOVERY_INTERNALS_H
|
|
Packit Service |
d40955 |
#define VDO_RECOVERY_INTERNALS_H
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "vdoRecovery.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "blockMapRecovery.h"
|
|
Packit Service |
d40955 |
#include "intMap.h"
|
|
Packit Service |
d40955 |
#include "journalPoint.h"
|
|
Packit Service |
d40955 |
#include "ringNode.h"
|
|
Packit Service |
d40955 |
#include "types.h"
|
|
Packit Service |
d40955 |
#include "waitQueue.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* The absolute position of an entry in the recovery journal, including
|
|
Packit Service |
d40955 |
* the sector number and the entry number within the sector.
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
typedef struct {
|
|
Packit Service |
d40955 |
SequenceNumber sequenceNumber; // Block sequence number
|
|
Packit Service |
d40955 |
uint8_t sectorCount; // Sector number
|
|
Packit Service |
d40955 |
JournalEntryCount entryCount; // Entry number
|
|
Packit Service |
d40955 |
} RecoveryPoint;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
typedef struct {
|
|
Packit Service |
d40955 |
/** The completion header */
|
|
Packit Service |
d40955 |
VDOCompletion completion;
|
|
Packit Service |
d40955 |
/** The sub-task completion */
|
|
Packit Service |
d40955 |
VDOCompletion subTaskCompletion;
|
|
Packit Service |
d40955 |
/** The VDO in question */
|
|
Packit Service |
d40955 |
VDO *vdo;
|
|
Packit Service |
d40955 |
/** The BlockAllocator whose journals are being recovered */
|
|
Packit Service |
d40955 |
BlockAllocator *allocator;
|
|
Packit Service |
d40955 |
/** A buffer to hold the data read off disk */
|
|
Packit Service |
d40955 |
char *journalData;
|
|
Packit Service |
d40955 |
/** The number of increfs */
|
|
Packit Service |
d40955 |
size_t increfCount;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/** The entry data for the block map recovery */
|
|
Packit Service |
d40955 |
NumberedBlockMapping *entries;
|
|
Packit Service |
d40955 |
/** The number of entries in the entry array */
|
|
Packit Service |
d40955 |
size_t entryCount;
|
|
Packit Service |
d40955 |
/** The sequence number of the first valid block for block map recovery */
|
|
Packit Service |
d40955 |
SequenceNumber blockMapHead;
|
|
Packit Service |
d40955 |
/** The sequence number of the first valid block for slab journal replay */
|
|
Packit Service |
d40955 |
SequenceNumber slabJournalHead;
|
|
Packit Service |
d40955 |
/** The sequence number of the last valid block of the journal (if known) */
|
|
Packit Service |
d40955 |
SequenceNumber tail;
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* The highest sequence number of the journal, not the same as the tail,
|
|
Packit Service |
d40955 |
* since the tail ignores blocks after the first hole.
|
|
Packit Service |
d40955 |
*/
|
|
Packit Service |
d40955 |
SequenceNumber highestTail;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/** A location just beyond the last valid entry of the journal */
|
|
Packit Service |
d40955 |
RecoveryPoint tailRecoveryPoint;
|
|
Packit Service |
d40955 |
/** The location of the next recovery journal entry to apply */
|
|
Packit Service |
d40955 |
RecoveryPoint nextRecoveryPoint;
|
|
Packit Service |
d40955 |
/** The number of logical blocks currently known to be in use */
|
|
Packit Service |
d40955 |
BlockCount logicalBlocksUsed;
|
|
Packit Service |
d40955 |
/** The number of block map data blocks known to be allocated */
|
|
Packit Service |
d40955 |
BlockCount blockMapDataBlocks;
|
|
Packit Service |
d40955 |
/** The journal point to give to the next synthesized decref */
|
|
Packit Service |
d40955 |
JournalPoint nextJournalPoint;
|
|
Packit Service |
d40955 |
/** The number of entries played into slab journals */
|
|
Packit Service |
d40955 |
size_t entriesAddedToSlabJournals;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
// Decref synthesis fields
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/** An intMap for use in finding which slots are missing decrefs */
|
|
Packit Service |
d40955 |
IntMap *slotEntryMap;
|
|
Packit Service |
d40955 |
/** The number of synthesized decrefs */
|
|
Packit Service |
d40955 |
size_t missingDecrefCount;
|
|
Packit Service |
d40955 |
/** The number of incomplete decrefs */
|
|
Packit Service |
d40955 |
size_t incompleteDecrefCount;
|
|
Packit Service |
d40955 |
/** The fake journal point of the next missing decref */
|
|
Packit Service |
d40955 |
JournalPoint nextSynthesizedJournalPoint;
|
|
Packit Service |
d40955 |
/** The queue of missing decrefs */
|
|
Packit Service |
d40955 |
WaitQueue missingDecrefs[];
|
|
Packit Service |
d40955 |
} RecoveryCompletion;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Convert a generic completion to a RecoveryCompletion.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param completion The completion to convert
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The RecoveryCompletion
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result))
|
|
Packit Service |
d40955 |
static inline RecoveryCompletion *
|
|
Packit Service |
d40955 |
asRecoveryCompletion(VDOCompletion *completion)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
STATIC_ASSERT(offsetof(RecoveryCompletion, completion) == 0);
|
|
Packit Service |
d40955 |
assertCompletionType(completion->type, RECOVERY_COMPLETION);
|
|
Packit Service |
d40955 |
return (RecoveryCompletion *) completion;
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Allocate and initialize a RecoveryCompletion.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param vdo The VDO in question
|
|
Packit Service |
d40955 |
* @param recoveryPtr A pointer to hold the new RecoveryCompletion
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return VDO_SUCCESS or a status code
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
int makeRecoveryCompletion(VDO *vdo, RecoveryCompletion **recoveryPtr)
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result));
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Free a RecoveryCompletion and all underlying structures.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param recoveryPtr A pointer to the recovery completion to free
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
void freeRecoveryCompletion(RecoveryCompletion **recoveryPtr);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#endif // VDO_RECOVERY_INTERNALS_H
|