|
Packit Service |
b3514a |
/*
|
|
Packit Service |
b3514a |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
b3514a |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
b3514a |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
b3514a |
* of the License, or (at your option) any later version.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
b3514a |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
b3514a |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
b3514a |
* GNU General Public License for more details.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
b3514a |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
b3514a |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
b3514a |
* 02110-1301, USA.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/referenceOperation.h#1 $
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#ifndef REFERENCE_OPERATION_H
|
|
Packit Service |
b3514a |
#define REFERENCE_OPERATION_H
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "types.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
typedef struct referenceOperation ReferenceOperation;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the PBNLock associated with a ReferenceOperation.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param operation The ReferenceOperation
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The PBNLock on the block of a ReferenceOperation or NULL if there
|
|
Packit Service |
b3514a |
* isn't one
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
typedef PBNLock *PBNLockGetter(ReferenceOperation operation);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* The current operation on a physical block (from the point of view of the
|
|
Packit Service |
b3514a |
* DataVIO doing the operation)
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
struct referenceOperation {
|
|
Packit Service |
b3514a |
/** The operation being performed */
|
|
Packit Service |
b3514a |
JournalOperation type;
|
|
Packit Service |
b3514a |
/** The PBN of the block being operated on */
|
|
Packit Service |
b3514a |
PhysicalBlockNumber pbn;
|
|
Packit Service |
b3514a |
/** The mapping state of the block being operated on */
|
|
Packit Service |
b3514a |
BlockMappingState state;
|
|
Packit Service |
b3514a |
/** A function to use to get any PBNLock associated with this operation */
|
|
Packit Service |
b3514a |
PBNLockGetter *lockGetter;
|
|
Packit Service |
b3514a |
/** The context to pass to the PBNLockGetter */
|
|
Packit Service |
b3514a |
void *context;
|
|
Packit Service |
b3514a |
};
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Get the PBNLock associated with the current ReferenceOperation.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param operation The reference operation
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return The PBNLock on the block of the current operation or NULL if there
|
|
Packit Service |
b3514a |
* isn't one
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
__attribute__((warn_unused_result))
|
|
Packit Service |
b3514a |
static inline
|
|
Packit Service |
b3514a |
PBNLock *getReferenceOperationPBNLock(ReferenceOperation operation)
|
|
Packit Service |
b3514a |
{
|
|
Packit Service |
b3514a |
return ((operation.lockGetter == NULL)
|
|
Packit Service |
b3514a |
? NULL : operation.lockGetter(operation));
|
|
Packit Service |
b3514a |
}
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Set up a ReferenceOperation for which we already have the lock.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param type The type of operation
|
|
Packit Service |
b3514a |
* @param pbn The PBN of the block on which to operate
|
|
Packit Service |
b3514a |
* @param state The mapping state of the block on which to operate
|
|
Packit Service |
b3514a |
* @param lock The PBNLock to associate with the operation
|
|
Packit Service |
b3514a |
* @param operation The ReferenceOperation to set up
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void setUpReferenceOperationWithLock(JournalOperation type,
|
|
Packit Service |
b3514a |
PhysicalBlockNumber pbn,
|
|
Packit Service |
b3514a |
BlockMappingState state,
|
|
Packit Service |
b3514a |
PBNLock *lock,
|
|
Packit Service |
b3514a |
ReferenceOperation *operation);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Set up a ReferenceOperation for which we will need to look up the lock later.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param type The type of operation
|
|
Packit Service |
b3514a |
* @param pbn The PBN of the block on which to operate
|
|
Packit Service |
b3514a |
* @param state The mapping state of the block on which to operate
|
|
Packit Service |
b3514a |
* @param zone The PhysicalZone from which the PBNLock can be retrieved
|
|
Packit Service |
b3514a |
* when needed
|
|
Packit Service |
b3514a |
* @param operation The ReferenceOperation to set up
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void setUpReferenceOperationWithZone(JournalOperation type,
|
|
Packit Service |
b3514a |
PhysicalBlockNumber pbn,
|
|
Packit Service |
b3514a |
BlockMappingState state,
|
|
Packit Service |
b3514a |
PhysicalZone *zone,
|
|
Packit Service |
b3514a |
ReferenceOperation *operation);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#endif // REFERENCE_OPERATION_H
|