CernVM-FS  2.12.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  SavedState
 
struct  Transaction
 

Public Types

enum  CacheModes { kCacheReadWrite = 0, kCacheReadOnly }
 
enum  RenameWorkarounds { kRenameNormal = 0, kRenameLink, kRenameSamedir }
 

Public Member Functions

virtual CacheManagerIds id ()
 
virtual std::string Describe ()
 
virtual ~PosixCacheManager ()
 
virtual bool AcquireQuotaManager (QuotaManager *quota_mgr)
 
virtual int Open (const LabeledObject &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 Label &label, 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 ()
 
bool is_tmpfs ()
 
bool do_refcount () const
 
- Public Member Functions inherited from CacheManager
virtual ~CacheManager ()
 
int ChecksumFd (int fd, shash::Any *id)
 
int OpenPinned (const LabeledObject &object)
 
bool Open2Mem (const LabeledObject &object, unsigned char **buffer, uint64_t *size)
 
bool CommitFromMem (const LabeledObject &object, const unsigned char *buffer, const uint64_t size)
 
QuotaManagerquota_mgr ()
 
void * SaveState (const int fd_progress)
 
int RestoreState (const int fd_progress, void *state)
 
void FreeState (const int fd_progress, void *state)
 
CacheManagerIds PeekState (void *state)
 

Static Public Member Functions

static PosixCacheManagerCreate (const std::string &cache_path, const bool alien_cache, const RenameWorkarounds rename_workaround=kRenameNormal, const bool do_refcount=false)
 

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)
 
static const int kLabelCatalog = 0x01
 
static const int kLabelPinned = 0x02
 
static const int kLabelVolatile = 0x04
 
static const int kLabelExternal = 0x08
 
static const int kLabelChunked = 0x10
 
static const int kLabelCertificate = 0x20
 
static const int kLabelMetainfo = 0x40
 
static const int kLabelHistory = 0x80
 

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)
 
bool InitCacheDirectory (const string &cache_path)
 
 PosixCacheManager (const std::string &cache_path, const bool alien_cache, const bool do_refcount=false)
 
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_
 
bool is_tmpfs_
 
bool do_refcount_
 
UniquePtr< FdRefcountMgrfd_mgr_
 

Static Private Attributes

static const char kMagicRefcount = 123
 
static const char kMagicNoRefcount = '\0'
 

Additional Inherited Members

- Protected Attributes inherited from CacheManager
QuotaManagerquota_mgr_
 

Detailed Description

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

Definition at line 40 of file cache_posix.h.

Member Enumeration Documentation

Enumerator
kCacheReadWrite 
kCacheReadOnly 

Definition at line 51 of file cache_posix.h.

Enumerator
kRenameNormal 
kRenameLink 
kRenameSamedir 

Definition at line 56 of file cache_posix.h.

Constructor & Destructor Documentation

virtual PosixCacheManager::~PosixCacheManager ( )
inlinevirtual

Definition at line 77 of file cache_posix.h.

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

Definition at line 142 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 call graph for this function:

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 106 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 105 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 107 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,
const bool  do_refcount = false 
)
static

Definition at line 272 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 Label label,
const int  flags,
void *  txn 
)
virtual

Implements CacheManager.

Definition at line 293 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 303 of file cache_posix.cc.

bool PosixCacheManager::do_refcount ( ) const
inline

Definition at line 109 of file cache_posix.h.

bool PosixCacheManager::DoFreeState ( void *  data)
protectedvirtual

Reimplemented from CacheManager.

Definition at line 361 of file cache_posix.cc.

Here is the call graph for this function:

int PosixCacheManager::DoRestoreState ( void *  data)
protectedvirtual

Reimplemented from CacheManager.

Definition at line 331 of file cache_posix.cc.

Here is the call graph for this function:

void * PosixCacheManager::DoSaveState ( )
protectedvirtual

If not refcounting, nothing to do, the kernel keeps the state of open file descriptors. Return a dummy memory location.

Reimplemented from CacheManager.

Definition at line 319 of file cache_posix.cc.

int PosixCacheManager::Dup ( int  fd)
virtual

Implements CacheManager.

Definition at line 376 of file cache_posix.cc.

int PosixCacheManager::Flush ( Transaction transaction)
private

Definition at line 384 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 400 of file cache_posix.cc.

int64_t PosixCacheManager::GetSize ( int  fd)
virtual

Implements CacheManager.

Definition at line 405 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 69 of file cache_posix.h.

bool PosixCacheManager::InitCacheDirectory ( const string &  cache_path)
private

Definition at line 231 of file cache_posix.cc.

Referenced by Create().

Here is the call graph for this function:

Here is the caller graph for this function:

bool PosixCacheManager::is_tmpfs ( )
inline

Definition at line 108 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 596 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 LabeledObject 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 414 of file cache_posix.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

int PosixCacheManager::OpenFromTxn ( void *  txn)
virtual

Implements CacheManager.

Definition at line 434 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 452 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.

No-op if the fd is to a file that is on a tmpfs, and so already in page cache

Implements CacheManager.

Definition at line 499 of file cache_posix.cc.

Here is the call graph for this function:

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

Definition at line 469 of file cache_posix.cc.

Here is the call graph for this function:

int PosixCacheManager::Reset ( void *  txn)
virtual

Implements CacheManager.

Definition at line 517 of file cache_posix.cc.

virtual uint32_t PosixCacheManager::SizeOfTxn ( )
inlinevirtual

Implements CacheManager.

Definition at line 87 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 98 of file cache_posix.h.

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

Implements CacheManager.

Definition at line 531 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 602 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 607 of file cache_posix.cc.

Here is the call graph for this function:

void PosixCacheManager::TearDown2ReadOnly ( )

Definition at line 613 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 624 of file cache_posix.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool PosixCacheManager::alien_cache_
private

Definition at line 164 of file cache_posix.h.

Referenced by alien_cache().

CacheModes PosixCacheManager::cache_mode_
private

Definition at line 166 of file cache_posix.h.

Referenced by cache_mode().

std::string PosixCacheManager::cache_path_
private

Definition at line 162 of file cache_posix.h.

Referenced by cache_path().

bool PosixCacheManager::do_refcount_
private

Refcount and return only unique file descriptors

Definition at line 198 of file cache_posix.h.

Referenced by do_refcount().

UniquePtr<FdRefcountMgr> PosixCacheManager::fd_mgr_
private

Definition at line 199 of file cache_posix.h.

bool PosixCacheManager::is_tmpfs_
private

True if posixcache is on tmpfs (and with this already in RAM)

Definition at line 194 of file cache_posix.h.

Referenced by is_tmpfs().

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 67 of file cache_posix.h.

const char PosixCacheManager::kMagicNoRefcount = '\0'
staticprivate

Definition at line 176 of file cache_posix.h.

const char PosixCacheManager::kMagicRefcount = 123
staticprivate

Definition at line 175 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 173 of file cache_posix.h.

Referenced by PosixCacheManager().

RenameWorkarounds PosixCacheManager::rename_workaround_
private

Definition at line 165 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 189 of file cache_posix.h.

std::string PosixCacheManager::txn_template_path_
private

Definition at line 163 of file cache_posix.h.


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