|
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/uds-releases/jasper/src/uds/uds-block.h#1 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* @file
|
|
Packit Service |
310c69 |
* @brief Definitions for the UDS block interface
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
#ifndef UDS_BLOCK_H
|
|
Packit Service |
310c69 |
#define UDS_BLOCK_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "uds.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** General UDS block constants. */
|
|
Packit Service |
310c69 |
enum {
|
|
Packit Service |
310c69 |
/** The maximum metadata size for a block. */
|
|
Packit Service |
310c69 |
UDS_MAX_BLOCK_DATA_SIZE = UDS_MAX_METADATA_SIZE
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Metadata to associate with a blockName.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
struct udsChunkData {
|
|
Packit Service |
310c69 |
unsigned char data[UDS_MAX_BLOCK_DATA_SIZE];
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Represents a block address on disk.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* #UdsBlockAddress objects allow the Application Software and UDS
|
|
Packit Service |
310c69 |
* to refer to specific disk blocks. It might be, for instance, the
|
|
Packit Service |
310c69 |
* logical block address divided by the block size.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* These objects are stored persistently in the index and are also cached.
|
|
Packit Service |
310c69 |
* Therefore, make every effort to ensure that these objects are as small as
|
|
Packit Service |
310c69 |
* possible.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
typedef void *UdsBlockAddress;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/** @{ */
|
|
Packit Service |
310c69 |
/** @name Deduplication */
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct udsRequest UdsRequest;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Callback function invoked to inform the Application Software that an
|
|
Packit Service |
310c69 |
* operation started by #udsStartChunkOperation has completed.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] request The operation that finished. When the callback
|
|
Packit Service |
310c69 |
* function is called, this UdsRequest structure can be
|
|
Packit Service |
310c69 |
* reused or freed.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
typedef void UdsChunkCallback(UdsRequest *request);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Request structure passed to #udsStartChunkOperation to begin an operation,
|
|
Packit Service |
310c69 |
* and returned to the Application Software when the callback function is
|
|
Packit Service |
310c69 |
* invoked.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
struct udsRequest {
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The name of the block.
|
|
Packit Service |
310c69 |
* Set before starting an operation.
|
|
Packit Service |
310c69 |
* Unchanged at time of callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
UdsChunkName chunkName;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The metadata found in the index that was associated with the block
|
|
Packit Service |
310c69 |
* (sometimes called the canonical address).
|
|
Packit Service |
310c69 |
* Set before the callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
struct udsChunkData oldMetadata;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The new metadata to associate with the name of the block (sometimes called
|
|
Packit Service |
310c69 |
* the duplicate address).
|
|
Packit Service |
310c69 |
* Set before starting a #UDS_POST or #UDS_QUERY operation.
|
|
Packit Service |
310c69 |
* Unchanged at time of callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
struct udsChunkData newMetadata;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The callback method to be invoked when the operation finishes.
|
|
Packit Service |
310c69 |
* Set before starting an operation.
|
|
Packit Service |
310c69 |
* Unchanged at time of callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
UdsChunkCallback *callback;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The index session.
|
|
Packit Service |
310c69 |
* Set before starting an operation.
|
|
Packit Service |
310c69 |
* Unchanged at time of callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
struct uds_index_session *session;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The operation type, which is one of #UDS_DELETE, #UDS_POST, #UDS_QUERY or
|
|
Packit Service |
310c69 |
* #UDS_UPDATE.
|
|
Packit Service |
310c69 |
* Set before starting an operation.
|
|
Packit Service |
310c69 |
* Unchanged at time of callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
UdsCallbackType type;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The operation status, which is either #UDS_SUCCESS or an error code.
|
|
Packit Service |
310c69 |
* Set before the callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
int status;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* If true, the name of the block was found in the index.
|
|
Packit Service |
310c69 |
* Set before the callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
bool found;
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* If true, move the entry to the end of the deduplication window.
|
|
Packit Service |
310c69 |
* Set before starting a #UDS_QUERY operation.
|
|
Packit Service |
310c69 |
* Unchanged at time of callback.
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
bool update;
|
|
Packit Service |
310c69 |
long private[25];
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Start a UDS index chunk operation. The request type field must
|
|
Packit Service |
310c69 |
* be set to the type of operation. This is an asynchronous interface to the
|
|
Packit Service |
310c69 |
* block-oriented UDS API. The callback is invoked upon completion.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* The #UDS_DELETE operation type deletes the mapping for a particular block.
|
|
Packit Service |
310c69 |
* #UDS_DELETE is typically used when UDS provides invalid advice.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* The #UDS_POST operation type indexes a block name and associates it with a
|
|
Packit Service |
310c69 |
* particular address. The caller provides the block's name. UDS then checks
|
|
Packit Service |
310c69 |
* this name against its index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* If the block is new, it is stored in the index.
|
|
Packit Service |
310c69 |
* If the block is a duplicate of an indexed block, UDS returns the
|
|
Packit Service |
310c69 |
* canonical block address via the callback.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* The #UDS_QUERY operation type checks to see if a block name exists in the
|
|
Packit Service |
310c69 |
* index. The caller provides the block's name. UDS then checks
|
|
Packit Service |
310c69 |
* this name against its index.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* If the block is new, no action is taken.
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
* If the block is a duplicate of an indexed block, UDS returns the
|
|
Packit Service |
310c69 |
* canonical block address via the callback. If the update
|
|
Packit Service |
310c69 |
* field is set, the entry is moved to the end of the deduplication
|
|
Packit Service |
310c69 |
* window.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* The #UDS_UPDATE operation type updates the mapping for a particular block.
|
|
Packit Service |
310c69 |
* #UDS_UPDATE is typically used if the callback function provides invalid
|
|
Packit Service |
310c69 |
* advice.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] request The operation. The type ,
|
|
Packit Service |
310c69 |
* chunkName , newMetadata ,
|
|
Packit Service |
310c69 |
* context , callback , and
|
|
Packit Service |
310c69 |
* update fields must be set. At callback
|
|
Packit Service |
310c69 |
* time, the oldMetadata ,
|
|
Packit Service |
310c69 |
* status , and found fields will
|
|
Packit Service |
310c69 |
* be set.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return Either #UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
UDS_ATTR_WARN_UNUSED_RESULT
|
|
Packit Service |
310c69 |
int udsStartChunkOperation(UdsRequest *request);
|
|
Packit Service |
310c69 |
/** @} */
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* UDS_BLOCK_H */
|