|
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/referenceOperation.h#1 $
|
|
Packit Service |
d40955 |
*/
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#ifndef REFERENCE_OPERATION_H
|
|
Packit Service |
d40955 |
#define REFERENCE_OPERATION_H
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "types.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
typedef struct referenceOperation ReferenceOperation;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Get the PBNLock associated with a ReferenceOperation.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param operation The ReferenceOperation
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The PBNLock on the block of a ReferenceOperation or NULL if there
|
|
Packit Service |
d40955 |
* isn't one
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
typedef PBNLock *PBNLockGetter(ReferenceOperation operation);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* The current operation on a physical block (from the point of view of the
|
|
Packit Service |
d40955 |
* DataVIO doing the operation)
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
struct referenceOperation {
|
|
Packit Service |
d40955 |
/** The operation being performed */
|
|
Packit Service |
d40955 |
JournalOperation type;
|
|
Packit Service |
d40955 |
/** The PBN of the block being operated on */
|
|
Packit Service |
d40955 |
PhysicalBlockNumber pbn;
|
|
Packit Service |
d40955 |
/** The mapping state of the block being operated on */
|
|
Packit Service |
d40955 |
BlockMappingState state;
|
|
Packit Service |
d40955 |
/** A function to use to get any PBNLock associated with this operation */
|
|
Packit Service |
d40955 |
PBNLockGetter *lockGetter;
|
|
Packit Service |
d40955 |
/** The context to pass to the PBNLockGetter */
|
|
Packit Service |
d40955 |
void *context;
|
|
Packit Service |
d40955 |
};
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Get the PBNLock associated with the current ReferenceOperation.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param operation The reference operation
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @return The PBNLock on the block of the current operation or NULL if there
|
|
Packit Service |
d40955 |
* isn't one
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
__attribute__((warn_unused_result))
|
|
Packit Service |
d40955 |
static inline
|
|
Packit Service |
d40955 |
PBNLock *getReferenceOperationPBNLock(ReferenceOperation operation)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
return ((operation.lockGetter == NULL)
|
|
Packit Service |
d40955 |
? NULL : operation.lockGetter(operation));
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Set up a ReferenceOperation for which we already have the lock.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param type The type of operation
|
|
Packit Service |
d40955 |
* @param pbn The PBN of the block on which to operate
|
|
Packit Service |
d40955 |
* @param state The mapping state of the block on which to operate
|
|
Packit Service |
d40955 |
* @param lock The PBNLock to associate with the operation
|
|
Packit Service |
d40955 |
* @param operation The ReferenceOperation to set up
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
void setUpReferenceOperationWithLock(JournalOperation type,
|
|
Packit Service |
d40955 |
PhysicalBlockNumber pbn,
|
|
Packit Service |
d40955 |
BlockMappingState state,
|
|
Packit Service |
d40955 |
PBNLock *lock,
|
|
Packit Service |
d40955 |
ReferenceOperation *operation);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**
|
|
Packit Service |
d40955 |
* Set up a ReferenceOperation for which we will need to look up the lock later.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* @param type The type of operation
|
|
Packit Service |
d40955 |
* @param pbn The PBN of the block on which to operate
|
|
Packit Service |
d40955 |
* @param state The mapping state of the block on which to operate
|
|
Packit Service |
d40955 |
* @param zone The PhysicalZone from which the PBNLock can be retrieved
|
|
Packit Service |
d40955 |
* when needed
|
|
Packit Service |
d40955 |
* @param operation The ReferenceOperation to set up
|
|
Packit Service |
d40955 |
**/
|
|
Packit Service |
d40955 |
void setUpReferenceOperationWithZone(JournalOperation type,
|
|
Packit Service |
d40955 |
PhysicalBlockNumber pbn,
|
|
Packit Service |
d40955 |
BlockMappingState state,
|
|
Packit Service |
d40955 |
PhysicalZone *zone,
|
|
Packit Service |
d40955 |
ReferenceOperation *operation);
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#endif // REFERENCE_OPERATION_H
|