Coda Distributed File System
Public Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
CacheFile Class Reference

#include <fso_cachefile.h>

Inheritance diagram for CacheFile:
Inheritance graph
[legend]

Public Member Functions

 CacheFile (int i, int recoverable=1, int partial=0) REQUIRES_TRANSACTION
 
 CacheFile ()
 
 ~CacheFile ()
 
void Create (int newlength=0) REQUIRES_TRANSACTION
 
int Open (int flags)
 
int Close (int fd)
 
FILE * FOpen (const char *mode)
 
int FClose (FILE *f)
 
void Validate () EXCLUDES_TRANSACTION
 
void Reset () EXCLUDES_TRANSACTION
 
int Copy (CacheFile *destination) REQUIRES_TRANSACTION
 
int Copy (char *destname, int recovering=0)
 
void IncRef ()
 
int DecRef ()
 
void Stat (struct stat *tstat)
 
void Utimes (const struct timeval times[2])
 
void Truncate (uint64_t newlen) REQUIRES_TRANSACTION
 
void SetLength (uint64_t newlen) REQUIRES_TRANSACTION
 
void SetValidData (uint64_t len) REQUIRES_TRANSACTION
 
void SetValidData (uint64_t start, int64_t len) REQUIRES_TRANSACTION
 
CacheChunkListGetHoles (uint64_t start, int64_t len)
 
CacheChunkListGetValidChunks (uint64_t start, int64_t len)
 
char * Name ()
 
uint64_t Length ()
 
uint64_t ValidData ()
 
uint64_t ConsecutiveValidData ()
 
int IsComplete ()
 
bool IsPartial ()
 
void SetPartial (bool is_partial) REQUIRES_TRANSACTION
 
void print ()
 
void print (FILE *fp)
 
void print (int fdes)
 

Static Protected Member Functions

static int64_t CopySegment (CacheFile *from, CacheFile *to, uint64_t pos, int64_t count) REQUIRES_TRANSACTION
 

Protected Attributes

char name [CACHEFILENAMELEN]
 

Friends

class SegmentedCacheFile
 

Constructor & Destructor Documentation

◆ CacheFile() [1/2]

CacheFile::CacheFile ( int  i,
int  recoverable = 1,
int  partial = 0 
)

Constructor

Parameters
iCacheFile index
recoverableset cachefile to be recoverable from RVM
partialset cachefile to be partially cached

◆ CacheFile() [2/2]

CacheFile::CacheFile ( )

Constructor

◆ ~CacheFile()

CacheFile::~CacheFile ( )

Destructor

Member Function Documentation

◆ Close()

int CacheFile::Close ( int  fd)

Close the container file

Parameters
fdfile descriptor of the opened file
Returns
zero on success or -1 on error

◆ ConsecutiveValidData()

uint64_t CacheFile::ConsecutiveValidData ( void  )

Get the amount of consecutive valid data starting from beginning of the file

Returns
amount of valid data of the cache file in bytes

◆ Copy() [1/2]

int CacheFile::Copy ( CacheFile destination)

Copy the container file and metadata to another object

Parameters
destinationdestination cache file object
Returns
zero on success or -1 on error

◆ Copy() [2/2]

int CacheFile::Copy ( char *  destname,
int  recovering = 0 
)

Copy the container file (only) to a specified location

Parameters
destnamedestination cache file location
recoveringflag if the cache file is being recovered
Returns
zero on success or -1 on error

◆ CopySegment()

int64_t CacheFile::CopySegment ( CacheFile from,
CacheFile to,
uint64_t  pos,
int64_t  count 
)
staticprotected

Copy the segment of a cache file to another

Parameters
fromsource cache file pointer
todestination cache file pointer
posoffset within the file
countamount of bytes to be copied
Returns
amount of bytes copied

◆ Create()

void CacheFile::Create ( int  newlength = 0)

Create and initialize a new cachefile (container file will be also created)

Parameters
newlengthlength of the container file in bytes

◆ DecRef()

int CacheFile::DecRef ( )

Decrements reference counter

Returns
reference counter value (unlinks if it becomes 0)

◆ FClose()

int CacheFile::FClose ( FILE *  f)

Close the container file

Parameters
fFILE structure fo the opened file
Returns
zero on success or errno otherwise

◆ FOpen()

FILE * CacheFile::FOpen ( const char *  mode)

Open the container file (with fopen sys call)

Parameters
modeopening mode (only "r" and "w" supported)
Returns
FILE structure of successfully opened file or NULL otherwise

◆ GetHoles()

CacheChunkList * CacheFile::GetHoles ( uint64_t  start,
int64_t  len 
)

Get the holes of the file within a range

Parameters
startstart of the search range
lenlength of the search range
Returns
holes list

◆ GetValidChunks()

CacheChunkList * CacheFile::GetValidChunks ( uint64_t  start,
int64_t  len 
)

Get the valid data of the file within a range

Parameters
startstart of the search range
lenlength of the search range
Returns
valid ranges chunks list

◆ IncRef()

void CacheFile::IncRef ( )
inline

Increment reference counter. Creation already does an implicit IncRef()

◆ IsComplete()

int CacheFile::IsComplete ( )
inline

Check if file is fully cached

Returns
zero if file isn't fully cached or not zero otherwise

◆ IsPartial()

bool CacheFile::IsPartial ( )
inline

Check if file is partially cached

Returns
true if file partially cached or false otherwise

◆ Length()

uint64_t CacheFile::Length ( )
inline

Get the length of the cache file

Returns
length of the cache file in bytes

◆ Name()

char * CacheFile::Name ( void  )
inline

Get the name of the container file

Returns
name of the container file

◆ Open()

int CacheFile::Open ( int  flags)

Open the container file (with open sys call)

Parameters
flagsopen flags
Returns
file descriptor of the file if opened successfully (Venus fails if container file couldn't be opened)

◆ print() [1/3]

void CacheFile::print ( void  )
inline

Print the metadata to the standard output

◆ print() [2/3]

void CacheFile::print ( FILE *  fp)
inline

Print the metadata to the specified file

Parameters
fpFILE structure of the output file

◆ print() [3/3]

void CacheFile::print ( int  fdes)

Print the metadata to the specified file

Parameters
fdesfile descriptor of the output file

◆ Reset()

void CacheFile::Reset ( )

Reset the container file to zero length and no data

◆ SetLength()

void CacheFile::SetLength ( uint64_t  newlen)

Set the cache file length without truncating the container file

Parameters
newlennew cache file metadata size

◆ SetPartial()

void CacheFile::SetPartial ( bool  is_partial)

Set the cache file to be partially cached

Parameters
is_partialpartial cache enable status

◆ SetValidData() [1/2]

void CacheFile::SetValidData ( uint64_t  len)

Set cache file's valid data (consecutive from beginning of the file)

Parameters
lenamount of valid data

◆ SetValidData() [2/2]

void CacheFile::SetValidData ( uint64_t  start,
int64_t  len 
)

Set cache file's valid data (within a range)

Parameters
startstart of the valid data's range
lenlength of the valid data's range

◆ Stat()

void CacheFile::Stat ( struct stat *  tstat)

Get container file's stat

Parameters
statoutput stat structure

◆ Truncate()

void CacheFile::Truncate ( uint64_t  newlen)

Truncate file to a new size

Parameters
newlensize to which the file will be truncated to

◆ Utimes()

void CacheFile::Utimes ( const struct timeval  times[2])

Change container file's last access and modification times

Parameters
timestime array of last access time and modification time, respectively.

◆ Validate()

void CacheFile::Validate ( )

Validate the container file (Resets the container file if invalid)

◆ ValidData()

uint64_t CacheFile::ValidData ( )
inline

Get the amount of valid data of the cache file

Returns
amount of valid data of the cache file in bytes

Friends And Related Function Documentation

◆ SegmentedCacheFile

friend class SegmentedCacheFile
friend

Member Data Documentation

◆ name

char CacheFile::name[CACHEFILENAMELEN]
protected

Container file path ("xx/xx/xx/xx")


The documentation for this class was generated from the following files: