|
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/volumeStore.h#2 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef VOLUME_STORE_H
|
|
Packit Service |
310c69 |
#define VOLUME_STORE_H
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "common.h"
|
|
Packit Service |
310c69 |
#include "compiler.h"
|
|
Packit Service |
310c69 |
#include "memoryAlloc.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifdef __KERNEL__
|
|
Packit Service |
310c69 |
#include <linux/dm-bufio.h>
|
|
Packit Service |
310c69 |
#else
|
|
Packit Service |
310c69 |
#include "ioRegion.h"
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
struct geometry;
|
|
Packit Service |
310c69 |
struct indexLayout;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
struct volume_store {
|
|
Packit Service |
310c69 |
#ifdef __KERNEL__
|
|
Packit Service |
310c69 |
struct dm_bufio_client *vs_client;
|
|
Packit Service |
310c69 |
#else
|
|
Packit Service |
310c69 |
IORegion *vs_region;
|
|
Packit Service |
310c69 |
size_t vs_bytesPerPage;
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
struct volume_page {
|
|
Packit Service |
310c69 |
#ifdef __KERNEL__
|
|
Packit Service |
310c69 |
struct dm_buffer *vp_buffer;
|
|
Packit Service |
310c69 |
#else
|
|
Packit Service |
310c69 |
byte *vp_data;
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Close a volume store.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void closeVolumeStore(struct volume_store *volumeStore);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Uninitialize a volume page buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void destroyVolumePage(struct volume_page *volumePage);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get a pointer to the data contained in a volume page buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return the address of the data
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
static INLINE byte *getPageData(const struct volume_page *volumePage)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
#ifdef __KERNEL__
|
|
Packit Service |
310c69 |
return dm_bufio_get_block_data(volumePage->vp_buffer);
|
|
Packit Service |
310c69 |
#else
|
|
Packit Service |
310c69 |
return volumePage->vp_data;
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Initialize a volume page buffer.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param geometry The volume geometry
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error status
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int initializeVolumePage(const struct geometry *geometry,
|
|
Packit Service |
310c69 |
struct volume_page *volumePage)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Open a volume store.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
* @param layout The index layout
|
|
Packit Service |
310c69 |
* @param reservedBuffers The number of buffers that can be reserved
|
|
Packit Service |
310c69 |
* @param bytesPerPage The number of bytes in a volume page
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int openVolumeStore(struct volume_store *volumeStore,
|
|
Packit Service |
310c69 |
struct indexLayout *layout,
|
|
Packit Service |
310c69 |
unsigned int reservedBuffers,
|
|
Packit Service |
310c69 |
size_t bytesPerPage)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Prefetch volume pages into memory.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
* @param physicalPage The volume page number of the first desired page
|
|
Packit Service |
310c69 |
* @param pageCount The number of volume pages to prefetch
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void prefetchVolumePages(const struct volume_store *volumeStore,
|
|
Packit Service |
310c69 |
unsigned int physicalPage,
|
|
Packit Service |
310c69 |
unsigned int pageCount);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Prepare a buffer to write a page to the volume.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
* @param physicalPage The volume page number of the desired page
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int prepareToWriteVolumePage(const struct volume_store *volumeStore,
|
|
Packit Service |
310c69 |
unsigned int physicalPage,
|
|
Packit Service |
310c69 |
struct volume_page *volumePage)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Read a page from a volume store.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
* @param physicalPage The volume page number of the desired page
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int readVolumePage(const struct volume_store *volumeStore,
|
|
Packit Service |
310c69 |
unsigned int physicalPage,
|
|
Packit Service |
310c69 |
struct volume_page *volumePage)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Release a volume page buffer, because it will no longer be accessed before a
|
|
Packit Service |
310c69 |
* call to readVolumePage or prepareToWriteVolumePage.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void releaseVolumePage(struct volume_page *volumePage);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Swap volume pages. This is used to put the contents of a newly written
|
|
Packit Service |
310c69 |
* index page (in the scratch page) into the page cache.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumePage1 The volume page buffer
|
|
Packit Service |
310c69 |
* @param volumePage2 The volume page buffer
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
void swapVolumePages(struct volume_page *volumePage1,
|
|
Packit Service |
310c69 |
struct volume_page *volumePage2);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Sync the volume store to storage.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int syncVolumeStore(const struct volume_store *volumeStore)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Write a page to a volume store.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param volumeStore The volume store
|
|
Packit Service |
310c69 |
* @param physicalPage The volume page number of the desired page
|
|
Packit Service |
310c69 |
* @param volumePage The volume page buffer
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return UDS_SUCCESS or an error code
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
int writeVolumePage(const struct volume_store *volumeStore,
|
|
Packit Service |
310c69 |
unsigned int physicalPage,
|
|
Packit Service |
310c69 |
struct volume_page *volumePage)
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#endif /* VOLUME_STORE_H */
|