Open CAS Framework
Open source framework of Cache Acceleration Software
Data Structures | Macros | Typedefs | Functions | Variables
ocf_metadata.h File Reference

OCF metadata helper function. More...

Go to the source code of this file.

Data Structures

struct  ocf_atomic_metadata
 Atomic metadata for extended sector. More...
 
struct  ocf_metadata_probe_status
 Metadata probe status. More...
 

Macros

#define OCF_ATOMIC_METADATA_SIZE   sizeof(struct ocf_atomic_metadata)
 

Typedefs

typedef void(* ocf_metadata_probe_end_t) (void *priv, int error, struct ocf_metadata_probe_status *status)
 Metadata probe completion callback. More...
 
typedef void(* ocf_metadata_probe_cores_end_t) (void *priv, int error, unsigned int num_cores)
 Metadata probe for cores completion callback. More...
 

Functions

struct ocf_atomic_metadata __attribute__ ((packed))
 
int ocf_metadata_get_atomic_entry (ocf_cache_t cache, uint64_t addr, struct ocf_atomic_metadata *entry)
 Get metadata entry (cache mapping) for specified sector of cache device. More...
 
void ocf_metadata_probe (ocf_ctx_t ctx, ocf_volume_t volume, ocf_metadata_probe_end_t cmpl, void *priv)
 Probe cache device. More...
 
void ocf_metadata_probe_cores (ocf_ctx_t ctx, ocf_volume_t volume, struct ocf_volume_uuid *uuids, uint32_t uuid_count, ocf_metadata_probe_cores_end_t cmpl, void *priv)
 Probe cache device for associated cores. More...
 
int ocf_metadata_check_invalid_before (ocf_cache_t cache, uint64_t addr)
 Check if sectors in cache line before given address are invalid. More...
 
int ocf_metadata_check_invalid_after (ocf_cache_t cache, uint64_t addr, uint32_t bytes)
 Check if sectors in cache line after given end address are invalid. More...
 

Variables

uint64_t core_line
 
uint32_t core_seq_no
 
uint32_t valid
 
uint32_t dirty
 
struct ocf_metadata_probe_status __attribute__
 

Detailed Description

OCF metadata helper function.

Those functions can be used by volume implementation.

Typedef Documentation

◆ ocf_metadata_probe_cores_end_t

typedef void(* ocf_metadata_probe_cores_end_t) (void *priv, int error, unsigned int num_cores)

Metadata probe for cores completion callback.

Parameters
[in]privCompletion context
[in]errorError code (zero on success)
[in]num_coresNumber of cores in cache metadata

◆ ocf_metadata_probe_end_t

typedef void(* ocf_metadata_probe_end_t) (void *priv, int error, struct ocf_metadata_probe_status *status)

Metadata probe completion callback.

Parameters
[in]privCompletion context
[in]errorError code (zero on success)
[in]statusStructure describing metadata probe status

Function Documentation

◆ ocf_metadata_check_invalid_after()

int ocf_metadata_check_invalid_after ( ocf_cache_t  cache,
uint64_t  addr,
uint32_t  bytes 
)

Check if sectors in cache line after given end address are invalid.

It might be used by volume which supports atomic writes - (write of data and metadata in one buffer)

Parameters
[in]cacheOCF cache instance
[in]addrSector address in bytes
[in]bytesIO size in bytes
Return values
0Not all sectors after given end address are invalid
Non-zeroNumber of sectors after given end address

◆ ocf_metadata_check_invalid_before()

int ocf_metadata_check_invalid_before ( ocf_cache_t  cache,
uint64_t  addr 
)

Check if sectors in cache line before given address are invalid.

It might be used by volume which supports atomic writes - (write of data and metadata in one buffer)

Parameters
[in]cacheOCF cache instance
[in]addrSector address in bytes
Return values
0Not all sectors before given address are invalid
Non-zeroNumber of sectors before given address

◆ ocf_metadata_get_atomic_entry()

int ocf_metadata_get_atomic_entry ( ocf_cache_t  cache,
uint64_t  addr,
struct ocf_atomic_metadata entry 
)

Get metadata entry (cache mapping) for specified sector of cache device.

Metadata has sector granularity. It might be used by volume which supports atomic writes - (write of data and metadata in one buffer)

Parameters
[in]cacheOCF cache instance
[in]addrSector address in bytes
[out]entryMetadata entry
Return values
0Metadata retrieved successfully
Non-zeroError

◆ ocf_metadata_probe()

void ocf_metadata_probe ( ocf_ctx_t  ctx,
ocf_volume_t  volume,
ocf_metadata_probe_end_t  cmpl,
void *  priv 
)

Probe cache device.

Parameters
[in]ctxhandle to object designating ocf context
[in]volumeCache volume
[in]cmplCompletion callback
[in]privCompletion context

◆ ocf_metadata_probe_cores()

void ocf_metadata_probe_cores ( ocf_ctx_t  ctx,
ocf_volume_t  volume,
struct ocf_volume_uuid uuids,
uint32_t  uuid_count,
ocf_metadata_probe_cores_end_t  cmpl,
void *  priv 
)

Probe cache device for associated cores.

Parameters
[in]ctxhandle to object designating ocf context
[in]volumeCache volume
[in,out]uuidsArray of uuids
[in]uuid_countSize of array
[in]cmplCompletion callback
[in]privCompletion context

Variable Documentation

◆ core_line

uint64_t core_line

Core line of core (in cache line size unit) which are cached

◆ core_seq_no

uint32_t core_seq_no

Core sequence number to which this line belongs to

◆ dirty

uint32_t dirty

Set bit indicates that sector is dirty

◆ valid

uint32_t valid

Set bit indicates that given sector is valid (is cached)