include/iocache.h File Reference


Detailed Description

I/O Caching Helper Subsystem.

The IO Cache abstracts caching of disk sectors away from the device driver to reduce code duplication and allow a central location for disk cache management that can be flushed simply by the kernel, without having to ask each driver to do it indivitually.

Go to the source code of this file.

Typedefs

typedef struct sIOCache tIOCache
 IO Cache Handle.
typedef int(* tIOCache_WriteCallback )(Uint32 ID, Uint64 Sector, void *Buffer)
 Write Callback.

Enumerations

enum  eIOCache_Modess { IOCACHE_WRITEBACK, IOCACHE_DELAYWRITE, IOCACHE_VIRTUAL }
 

I/O Cache handling modes.

More...

Functions

tIOCacheIOCache_Create (tIOCache_WriteCallback Write, Uint32 ID, int SectorSize, int CacheSize)
 Creates a new IO Cache.
int IOCache_Read (tIOCache *Cache, Uint64 Sector, void *Buffer)
 Reads from a cached sector.
int IOCache_Add (tIOCache *Cache, Uint64 Sector, void *Buffer)
 Adds a sector to the cache.
int IOCache_Write (tIOCache *Cache, Uint64 Sector, void *Buffer)
 Writes to a cached sector.
void IOCache_Flush (tIOCache *Cache)
 Flush altered sectors out to the device.
void IOCache_Destroy (tIOCache *Cache)
 Flushes the cache and then removes it.

Typedef Documentation

typedef int(* tIOCache_WriteCallback)(Uint32 ID, Uint64 Sector, void *Buffer)

Write Callback.

Called to write a sector back to the device


Enumeration Type Documentation

I/O Cache handling modes.

Enumerator:
IOCACHE_WRITEBACK 

Writeback.

Transparently writes data straight to the device when the cache is written to.

IOCACHE_DELAYWRITE 

Delay Write.

Only writes when instructed to (by IOCache_Flush) or when a cached sector is being reallocated.

IOCACHE_VIRTUAL 

Virtual - No Writes.

Changes to the cache contents are only reflected in memory, any calls to IOCache_Flush will silently return without doing anything and if a sector is reallocated, all changes will be lost


Function Documentation

int IOCache_Add ( tIOCache Cache,
Uint64  Sector,
void *  Buffer 
)

Adds a sector to the cache.

Parameters:
Cache Cache handle returned by IOCache_Create
Sector Sector's ID number
Buffer Data to cache
Returns:
1 on success, 0 if the sector is already cached, -1 on error
tIOCache* IOCache_Create ( tIOCache_WriteCallback  Write,
Uint32  ID,
int  SectorSize,
int  CacheSize 
)

Creates a new IO Cache.

Parameters:
Write Function to call to write a sector to the device
ID ID to pass to Write
SectorSize Size of a cached sector
CacheSize Maximum number of objects that can be in the cache at one time
void IOCache_Destroy ( tIOCache Cache  ) 

Flushes the cache and then removes it.

Parameters:
Cache Cache handle returned by IOCache_Create
Note:
After this is called Cache is no longer valid

IOCache_Destroy writes all changed sectors to the device and then deallocates the cache for other systems to use.

void IOCache_Flush ( tIOCache Cache  ) 

Flush altered sectors out to the device.

Parameters:
Cache Cache handle returned by IOCache_Create

This will call the cache's write callback on each altered sector to flush the write cache.

int IOCache_Read ( tIOCache Cache,
Uint64  Sector,
void *  Buffer 
)

Reads from a cached sector.

Parameters:
Cache Cache handle returned by IOCache_Create
Sector Sector's ID number
Buffer Destination for the data read
Returns:
1 if the data was read, 0 if the sector is not cached, -1 on error
int IOCache_Write ( tIOCache Cache,
Uint64  Sector,
void *  Buffer 
)

Writes to a cached sector.

Parameters:
Cache Cache handle returned by IOCache_Create
Sector Sector's ID number
Buffer Data to write to the cache
Returns:
1 if the data was read, 0 if the sector is not cached, -1 on error

If the sector is in the cache, it is updated. Wether the Write callback is called depends on the selected caching behaviour.

Generated on Mon Feb 14 15:21:30 2011 for Acess2 by  doxygen 1.6.3