CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PosixCacheManager Class Reference

#include <cache_posix.h>

Inheritance diagram for PosixCacheManager:
Collaboration diagram for PosixCacheManager:

Classes

struct  Transaction
 

Public Types

enum  CacheModes { kCacheReadWrite = 0, kCacheReadOnly }
 
enum  RenameWorkarounds { kRenameNormal = 0, kRenameLink, kRenameSamedir }
 
- Public Types inherited from CacheManager
enum  ObjectType { kTypeRegular = 0, kTypeCatalog, kTypePinned, kTypeVolatile }
 

Public Member Functions

virtual CacheManagerIds id ()
 
virtual std::string Describe ()
 
virtual ~PosixCacheManager ()
 
virtual bool AcquireQuotaManager (QuotaManager *quota_mgr)
 
virtual int Open (const BlessedObject &object)
 
virtual int64_t GetSize (int fd)
 
virtual int Close (int fd)
 
virtual int64_t Pread (int fd, void *buf, uint64_t size, uint64_t offset)
 
virtual int Dup (int fd)
 
virtual int Readahead (int fd)
 
virtual uint32_t SizeOfTxn ()
 
virtual int StartTxn (const shash::Any &id, uint64_t size, void *txn)
 
virtual void CtrlTxn (const ObjectInfo &object_info, const int flags, void *txn)
 
virtual int64_t Write (const void *buf, uint64_t size, void *txn)
 
virtual int Reset (void *txn)
 
virtual int OpenFromTxn (void *txn)
 
virtual int AbortTxn (void *txn)
 
virtual int CommitTxn (void *txn)
 
virtual void Spawn ()
 
virtual manifest::Breadcrumb LoadBreadcrumb (const std::string &fqrn)
 
virtual bool StoreBreadcrumb (const manifest::Manifest &manifest)
 
bool StoreBreadcrumb (std::string fqrn, manifest::Breadcrumb breadcrumb)
 
void TearDown2ReadOnly ()
 
CacheModes cache_mode ()
 
bool alien_cache ()
 
std::string cache_path ()
 
- Public Member Functions inherited from CacheManager
virtual ~CacheManager ()
 
int OpenPinned (const shash::Any &id, const std::string &description, bool is_catalog)
 
int ChecksumFd (int fd, shash::Any *id)
 
bool Open2Mem (const shash::Any &id, const std::string &description, unsigned char **buffer, uint64_t *size)
 
bool CommitFromMem (const shash::Any &id, const unsigned char *buffer, const uint64_t size, const std::string &description)
 
QuotaManagerquota_mgr ()
 
void * SaveState (const int fd_progress)
 
int RestoreState (const int fd_progress, void *state)
 
void FreeState (const int fd_progress, void *state)
 

Static Public Member Functions

static PosixCacheManagerCreate (const std::string &cache_path, const bool alien_cache, const RenameWorkarounds rename_workaround=kRenameNormal)
 
- Static Public Member Functions inherited from CacheManager
static BlessedObject Bless (const shash::Any &id)
 
static BlessedObject Bless (const shash::Any &id, const ObjectInfo &info)
 
static BlessedObject Bless (const shash::Any &id, ObjectType type)
 
static BlessedObject Bless (const shash::Any &id, const std::string &description)
 
static BlessedObject Bless (const shash::Any &id, ObjectType type, const std::string &description)
 

Static Public Attributes

static const uint64_t kBigFile = 25 * 1024 * 1024
 
- Static Public Attributes inherited from CacheManager
static const uint64_t kSizeUnknown = uint64_t(-1)
 

Protected Member Functions

virtual void * DoSaveState ()
 
virtual int DoRestoreState (void *data)
 
virtual bool DoFreeState (void *data)
 
- Protected Member Functions inherited from CacheManager
 CacheManager ()
 

Private Member Functions

 FRIEND_TEST (T_CacheManager, CommitTxnQuotaNotifications)
 
 FRIEND_TEST (T_CacheManager, CommitTxnRenameFail)
 
 FRIEND_TEST (T_CacheManager, Open)
 
 FRIEND_TEST (T_CacheManager, OpenFromTxn)
 
 FRIEND_TEST (T_CacheManager, OpenPinned)
 
 FRIEND_TEST (T_CacheManager, Rename)
 
 FRIEND_TEST (T_CacheManager, StartTxn)
 
 FRIEND_TEST (T_CacheManager, TearDown2ReadOnly)
 
 PosixCacheManager (const std::string &cache_path, const bool alien_cache)
 
std::string GetPathInCache (const shash::Any &id)
 
int Rename (const char *oldpath, const char *newpath)
 
int Flush (Transaction *transaction)
 

Private Attributes

std::string cache_path_
 
std::string txn_template_path_
 
bool alien_cache_
 
RenameWorkarounds rename_workaround_
 
CacheModes cache_mode_
 
atomic_int32 no_inflight_txns_
 
bool reports_correct_filesize_
 

Additional Inherited Members

- Protected Attributes inherited from CacheManager
QuotaManagerquota_mgr_
 

Detailed Description

Cache manger implementation using a file system (cache directory) as a backing storage.

Definition at line 39 of file cache_posix.h.

Member Enumeration Documentation

Enumerator
kCacheReadWrite 
kCacheReadOnly 

Definition at line 50 of file cache_posix.h.

Enumerator
kRenameNormal 
kRenameLink 
kRenameSamedir 

Definition at line 55 of file cache_posix.h.

Constructor & Destructor Documentation

virtual PosixCacheManager::~PosixCacheManager ( )
inlinevirtual

Definition at line 75 of file cache_posix.h.

PosixCacheManager::PosixCacheManager ( const std::string &  cache_path,
const bool  alien_cache 
)
inlineprivate

Definition at line 136 of file cache_posix.h.

Member Function Documentation

int PosixCacheManager::AbortTxn ( void *  txn)
virtual

Implements CacheManager.

Definition at line 113 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_abort_txn(), and anonymous_namespace{cvmfs_cache_posix.cc}::posix_commit_txn().

Here is the caller graph for this function:

bool PosixCacheManager::AcquireQuotaManager ( QuotaManager quota_mgr)
virtual

This should only be used to replace the default NoopQuotaManager by a PosixQuotaManager. The cache manager takes the ownership of the passed quota manager.

Implements CacheManager.

Definition at line 131 of file cache_posix.cc.

bool PosixCacheManager::alien_cache ( )
inline

Definition at line 104 of file cache_posix.h.

Referenced by FileSystem::SetupNfsMaps().

Here is the caller graph for this function:

CacheModes PosixCacheManager::cache_mode ( )
inline

Definition at line 103 of file cache_posix.h.

Referenced by TalkManager::MainResponder().

Here is the caller graph for this function:

std::string PosixCacheManager::cache_path ( )
inline

Definition at line 105 of file cache_posix.h.

Referenced by FileSystem::SetupNfsMaps().

Here is the caller graph for this function:

int PosixCacheManager::Close ( int  fd)
virtual

Implements CacheManager.

Definition at line 140 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_chrefcnt().

Here is the caller graph for this function:

int PosixCacheManager::CommitTxn ( void *  txn)
virtual

Implements CacheManager.

Definition at line 148 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_commit_txn().

Here is the call graph for this function:

Here is the caller graph for this function:

PosixCacheManager * PosixCacheManager::Create ( const std::string &  cache_path,
const bool  alien_cache,
const RenameWorkarounds  rename_workaround = kRenameNormal 
)
static

Definition at line 230 of file cache_posix.cc.

Referenced by main(), and FileSystem::SetupPosixCacheMgr().

Here is the call graph for this function:

Here is the caller graph for this function:

void PosixCacheManager::CtrlTxn ( const ObjectInfo object_info,
const int  flags,
void *  txn 
)
virtual

Implements CacheManager.

Definition at line 277 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_start_txn().

Here is the caller graph for this function:

string PosixCacheManager::Describe ( )
virtual

Return a human readable description of the cache instance. Used in cvmfs_talk.

Implements CacheManager.

Definition at line 287 of file cache_posix.cc.

bool PosixCacheManager::DoFreeState ( void *  data)
protectedvirtual

Reimplemented from CacheManager.

Definition at line 311 of file cache_posix.cc.

int PosixCacheManager::DoRestoreState ( void *  data)
protectedvirtual

Reimplemented from CacheManager.

Definition at line 303 of file cache_posix.cc.

Here is the call graph for this function:

void * PosixCacheManager::DoSaveState ( )
protectedvirtual

Nothing to do, the kernel keeps the state of open file descriptors. Return a dummy memory location.

Reimplemented from CacheManager.

Definition at line 296 of file cache_posix.cc.

int PosixCacheManager::Dup ( int  fd)
virtual

Implements CacheManager.

Definition at line 318 of file cache_posix.cc.

int PosixCacheManager::Flush ( Transaction transaction)
private

Definition at line 326 of file cache_posix.cc.

PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
CommitTxnQuotaNotifications   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
CommitTxnRenameFail   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
Open   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
OpenFromTxn   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
OpenPinned   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
Rename   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
StartTxn   
)
private
PosixCacheManager::FRIEND_TEST ( T_CacheManager  ,
TearDown2ReadOnly   
)
private
string PosixCacheManager::GetPathInCache ( const shash::Any id)
inlineprivate

Definition at line 342 of file cache_posix.cc.

int64_t PosixCacheManager::GetSize ( int  fd)
virtual

Implements CacheManager.

Definition at line 347 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_chrefcnt(), and anonymous_namespace{cvmfs_cache_posix.cc}::posix_commit_txn().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual CacheManagerIds PosixCacheManager::id ( )
inlinevirtual

Implements CacheManager.

Definition at line 68 of file cache_posix.h.

manifest::Breadcrumb PosixCacheManager::LoadBreadcrumb ( const std::string &  )
virtual

While not strictly necessary, cache managers often have a directory associated with them. This directory is currently used to find the cached manifest copy, the cvmfschecksum.$reponame file. This is important to make pre-loaded alien caches work, even in a tiered setup.

Reimplemented from CacheManager.

Definition at line 522 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_breadcrumb_load().

Here is the call graph for this function:

Here is the caller graph for this function:

int PosixCacheManager::Open ( const BlessedObject object)
virtual

Opening an object might get it from a third-party source, e.g. when the tiered cache manager issues a copy-up operation. In this case it is beneficial to register the object with the accurate meta-data, in the same way it is done during transactions.

Implements CacheManager.

Definition at line 356 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_chrefcnt().

Here is the caller graph for this function:

int PosixCacheManager::OpenFromTxn ( void *  txn)
virtual

Implements CacheManager.

Definition at line 372 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_commit_txn().

Here is the caller graph for this function:

int64_t PosixCacheManager::Pread ( int  fd,
void *  buf,
uint64_t  size,
uint64_t  offset 
)
virtual

Implements CacheManager.

Definition at line 384 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_pread().

Here is the caller graph for this function:

int PosixCacheManager::Readahead ( int  fd)
virtual

Used by the sqlite vfs in order to preload file catalogs into the file system buffers.

Implements CacheManager.

Definition at line 428 of file cache_posix.cc.

int PosixCacheManager::Rename ( const char *  oldpath,
const char *  newpath 
)
private

Definition at line 401 of file cache_posix.cc.

int PosixCacheManager::Reset ( void *  txn)
virtual

Implements CacheManager.

Definition at line 443 of file cache_posix.cc.

virtual uint32_t PosixCacheManager::SizeOfTxn ( )
inlinevirtual

Implements CacheManager.

Definition at line 85 of file cache_posix.h.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_start_txn().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void PosixCacheManager::Spawn ( )
inlinevirtual

Implements CacheManager.

Definition at line 96 of file cache_posix.h.

int PosixCacheManager::StartTxn ( const shash::Any id,
uint64_t  size,
void *  txn 
)
virtual

Implements CacheManager.

Definition at line 457 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_start_txn().

Here is the call graph for this function:

Here is the caller graph for this function:

bool PosixCacheManager::StoreBreadcrumb ( const manifest::Manifest manifest)
virtual

Reimplemented from CacheManager.

Definition at line 528 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_breadcrumb_store().

Here is the call graph for this function:

Here is the caller graph for this function:

bool PosixCacheManager::StoreBreadcrumb ( std::string  fqrn,
manifest::Breadcrumb  breadcrumb 
)

Definition at line 533 of file cache_posix.cc.

Here is the call graph for this function:

void PosixCacheManager::TearDown2ReadOnly ( )

Definition at line 539 of file cache_posix.cc.

Referenced by FileSystem::TearDown2ReadOnly().

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t PosixCacheManager::Write ( const void *  buf,
uint64_t  size,
void *  txn 
)
virtual

Implements CacheManager.

Definition at line 550 of file cache_posix.cc.

Referenced by anonymous_namespace{cvmfs_cache_posix.cc}::posix_write_txn().

Here is the caller graph for this function:

Member Data Documentation

bool PosixCacheManager::alien_cache_
private

Definition at line 153 of file cache_posix.h.

Referenced by alien_cache(), and Create().

CacheModes PosixCacheManager::cache_mode_
private

Definition at line 155 of file cache_posix.h.

Referenced by cache_mode().

std::string PosixCacheManager::cache_path_
private

Definition at line 151 of file cache_posix.h.

Referenced by cache_path().

const uint64_t PosixCacheManager::kBigFile = 25 * 1024 * 1024
static

As of 25M, a file is considered a "big file", which means it is dangerous to apply asynchronous semantics. On start of a transaction with a big file the cache is cleaned up opportunistically.

Definition at line 66 of file cache_posix.h.

atomic_int32 PosixCacheManager::no_inflight_txns_
private

The cache can only degrade to a read-only cache once all writable file descriptors from transactions are closed. This is indicated by a zero value in this variable.

Definition at line 162 of file cache_posix.h.

Referenced by PosixCacheManager().

RenameWorkarounds PosixCacheManager::rename_workaround_
private

Definition at line 154 of file cache_posix.h.

Referenced by Create().

bool PosixCacheManager::reports_correct_filesize_
private

Hack for HDFS which writes file sizes asynchronously.

Definition at line 167 of file cache_posix.h.

std::string PosixCacheManager::txn_template_path_
private

Definition at line 152 of file cache_posix.h.


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