|
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/indexZone.h#2 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef INDEX_ZONE_H
|
|
Packit Service |
310c69 |
#define INDEX_ZONE_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "common.h"
|
|
Packit Service |
310c69 |
#include "openChapterZone.h"
|
|
Packit Service |
310c69 |
#include "request.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
typedef struct {
|
|
Packit Service |
310c69 |
struct index *index;
|
|
Packit Service |
310c69 |
OpenChapterZone *openChapter;
|
|
Packit Service |
310c69 |
OpenChapterZone *writingChapter;
|
|
Packit Service |
310c69 |
uint64_t oldestVirtualChapter;
|
|
Packit Service |
310c69 |
uint64_t newestVirtualChapter;
|
|
Packit Service |
310c69 |
unsigned int id;
|
|
Packit Service |
310c69 |
} IndexZone;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Allocate an index zone.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param index The index receiving the zone
|
|
Packit Service |
310c69 |
* @param zoneNumber The number of the zone to allocate
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int makeIndexZone(struct index *index, unsigned int zoneNumber)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Clean up an index zone.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The index zone to free
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void freeIndexZone(IndexZone *zone);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Check whether a chapter is sparse or dense based on the current state of
|
|
Packit Service |
310c69 |
* the index zone.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The index zone to check against
|
|
Packit Service |
310c69 |
* @param virtualChapter The virtual chapter number of the chapter to check
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return true if the chapter is in the sparse part of the volume
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
bool isZoneChapterSparse(const IndexZone *zone,
|
|
Packit Service |
310c69 |
uint64_t virtualChapter)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Set the active chapter numbers for a zone based on its index. The active
|
|
Packit Service |
310c69 |
* chapters consist of the range of chapters from the current oldest to
|
|
Packit Service |
310c69 |
* the current newest virtual chapter.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The zone to set
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void setActiveChapters(IndexZone *zone);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Dispatch a control request to an index zone.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param request The request to dispatch
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int dispatchIndexZoneControlRequest(Request *request)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Execute a sparse chapter index cache barrier control request on the zone
|
|
Packit Service |
310c69 |
* worker thread. This call into the sparse cache to coordinate the cache
|
|
Packit Service |
310c69 |
* update with the other zones.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The index zone receiving the barrier message
|
|
Packit Service |
310c69 |
* @param barrier The barrier control message data
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code if the chapter index could not be
|
|
Packit Service |
310c69 |
* read or decoded
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int executeSparseCacheBarrierMessage(IndexZone *zone,
|
|
Packit Service |
310c69 |
BarrierMessageData *barrier)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Open the next chapter.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The zone containing the open chapter
|
|
Packit Service |
310c69 |
* @param request The request which requires the next chapter to be
|
|
Packit Service |
310c69 |
* opened
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS if successful.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int openNextChapter(IndexZone *zone, Request *request)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Determine the IndexRegion in which a block was found.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The zone that was searched
|
|
Packit Service |
310c69 |
* @param virtualChapter The virtual chapter number
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return the IndexRegion of the chapter in which the block was found
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
IndexRegion computeIndexRegion(const IndexZone *zone,
|
|
Packit Service |
310c69 |
uint64_t virtualChapter);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a record from either the volume or the open chapter in a zone.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The index zone to query
|
|
Packit Service |
310c69 |
* @param request The request originating the query
|
|
Packit Service |
310c69 |
* @param found A pointer to a bool which will be set to
|
|
Packit Service |
310c69 |
* true if the record was found.
|
|
Packit Service |
310c69 |
* @param virtualChapter The chapter in which to search
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int getRecordFromZone(IndexZone *zone,
|
|
Packit Service |
310c69 |
Request *request,
|
|
Packit Service |
310c69 |
bool *found,
|
|
Packit Service |
310c69 |
uint64_t virtualChapter)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Put a record in the open chapter. If this fills the chapter, the chapter
|
|
Packit Service |
310c69 |
* will be closed and a new one will be opened.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param zone The index zone containing the chapter
|
|
Packit Service |
310c69 |
* @param request The request containing the name of the record
|
|
Packit Service |
310c69 |
* @param metadata The record metadata
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int putRecordInZone(IndexZone *zone,
|
|
Packit Service |
310c69 |
Request *request,
|
|
Packit Service |
310c69 |
const UdsChunkData *metadata)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Search the cached sparse chapter index, either for a cached sparse hook, or
|
|
Packit Service |
310c69 |
* as the last chance for finding the record named by a request.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] zone the index zone
|
|
Packit Service |
310c69 |
* @param [in] request the request originating the search
|
|
Packit Service |
310c69 |
* @param [in] virtualChapter if UINT64_MAX, search the entire cache;
|
|
Packit Service |
310c69 |
* otherwise search this chapter, if cached
|
|
Packit Service |
310c69 |
* @param [out] found A pointer to a bool which will be set to
|
|
Packit Service |
310c69 |
* true if the record was found
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int searchSparseCacheInZone(IndexZone *zone,
|
|
Packit Service |
310c69 |
Request *request,
|
|
Packit Service |
310c69 |
uint64_t virtualChapter,
|
|
Packit Service |
310c69 |
bool *found)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* INDEX_ZONE_H */
|