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