![]() |
XRootD
|
Attaches/creates and detaches/deletes cache-io objects for disk based cache. More...
#include <XrdPfc.hh>
Public Member Functions | |
Cache (XrdSysLogger *logger, XrdOucEnv *env) | |
Constructor. | |
void | AddWriteTask (Block *b, bool from_read) |
Add downloaded block in write queue. | |
virtual XrdOucCacheIO * | Attach (XrdOucCacheIO *, int Options=0) |
bool | Config (const char *config_filename, const char *parameters) |
Parse configuration file. | |
virtual int | ConsiderCached (const char *url) |
bool | Decide (XrdOucCacheIO *) |
Makes decision if the original XrdOucCacheIO should be cached. | |
bool | DecideIfConsideredCached (long long file_size, long long bytes_on_disk) |
void | DeRegisterPrefetchFile (File *) |
long long | DetermineFullFileSize (const std::string &cinfo_fname) |
void | ExecuteCommandUrl (const std::string &command_url) |
void | FileSyncDone (File *, bool high_debug) |
File * | GetFile (const std::string &, IO *, long long off=0, long long filesize=0) |
XrdXrootdGStream * | GetGStream () |
XrdSysError * | GetLog () |
File * | GetNextFileToPrefetch () |
XrdOss * | GetOss () const |
XrdSysTrace * | GetTrace () |
bool | IsFileActiveOrPurgeProtected (const std::string &) |
virtual int | LocalFilePath (const char *url, char *buff=0, int blen=0, LFP_Reason why=ForAccess, bool forall=false) |
void | Prefetch () |
virtual int | Prepare (const char *url, int oflags, mode_t mode) |
void | ProcessWriteTasks () |
Separate task which writes blocks from ram to disk. | |
void | Purge () |
Thread function invoked to scan and purge files from disk when needed. | |
const Configuration & | RefConfiguration () const |
Reference XrdPfc configuration. | |
void | RegisterPrefetchFile (File *) |
void | ReleaseFile (File *, IO *) |
void | ReleaseRAM (char *buf, long long size) |
void | RemoveWriteQEntriesFor (File *f) |
Remove blocks from write queue which belong to given prefetch. This method is used at the time of File destruction. | |
char * | RequestRAM (long long size) |
void | ResourceMonitorHeartBeat () |
Thread function checking resource usage periodically. | |
void | ScheduleFileSync (File *f) |
virtual int | Stat (const char *url, struct stat &sbuff) |
virtual int | Unlink (const char *url) |
int | UnlinkFile (const std::string &f_name, bool fail_if_open) |
Remove cinfo and data files from cache. | |
void | WriteFileSizeXAttr (int cinfo_fd, long long file_size) |
![]() | |
XrdOucCache (const char *ctype) | |
virtual | ~XrdOucCache () |
Destructor. | |
virtual int | Rename (const char *oldp, const char *newp) |
virtual int | Rmdir (const char *dirp) |
virtual int | Truncate (const char *path, off_t size) |
virtual int | Xeq (XeqCmd cmd, char *arg, int arglen) |
Static Public Member Functions | |
static const Configuration & | Conf () |
static Cache & | CreateInstance (XrdSysLogger *logger, XrdOucEnv *env) |
Singleton creation. | |
static Cache & | GetInstance () |
Singleton access. | |
static const Cache & | TheOne () |
static bool | VCheck (XrdVersionInfo &urVersion) |
Version check. | |
Static Public Attributes | |
static XrdScheduler * | schedP = 0 |
![]() | |
static const int | optFIS = 0x0001 |
File is structured (e.g. root file) | |
static const int | optNEW = 0x0014 |
File is new -> optRW (o/w read or write) | |
static const int | optRW = 0x0004 |
File is read/write (o/w read/only) | |
static const int | optWIN = 0x0024 |
File is new -> optRW use write-in cache. | |
Additional Inherited Members | |
![]() | |
enum | LFP_Reason { ForAccess =0 , ForInfo , ForPath } |
enum | XeqCmd { xeqNoop = 0 } |
![]() | |
const char | CacheType [8] |
A 1-to-7 character cache type identifier (usually pfc or rmc). | |
XrdOucCacheStats | Statistics |
Attaches/creates and detaches/deletes cache-io objects for disk based cache.
Cache::Cache | ( | XrdSysLogger * | logger, |
XrdOucEnv * | env ) |
Constructor.
Definition at line 188 of file XrdPfc.cc.
References XrdSysTrace::What.
Referenced by CreateInstance().
void Cache::AddWriteTask | ( | Block * | b, |
bool | from_read ) |
Add downloaded block in write queue.
Definition at line 256 of file XrdPfc.cc.
References XrdPfc::Block::get_file(), XrdPfc::Block::get_size(), XrdPfc::File::GetLocalPath(), XrdSysCondVar::Lock(), XrdPfc::Block::m_offset, XrdSysCondVar::Signal(), TRACE, and XrdSysCondVar::UnLock().
|
virtual |
Implements XrdOucCache.
Definition at line 214 of file XrdPfc.cc.
References Debug, Decide(), Error, GetInstance(), XrdPfc::IOFile::HasFile(), XrdOucCacheIO::Location(), obfuscateAuth(), XrdOucCacheIO::Path(), RefConfiguration(), TRACE, and TRACE_PC.
|
static |
Definition at line 165 of file XrdPfc.cc.
References RefConfiguration().
Referenced by XrdPfc::FPurgeState::CheckFile().
bool Cache::Config | ( | const char * | config_filename, |
const char * | parameters ) |
Parse configuration file.
config_filename | path to configuration file |
parameters | optional parameters to be passed |
Definition at line 351 of file XrdPfcConfiguration.cc.
References XrdOuca2x::a2ll(), XrdOuca2x::a2sz(), Config(), XrdPfc::CSChk_Both, XrdPfc::CSChk_None, XrdSysError::Emsg(), Error, XrdOucEnv::Export(), XrdOucEnv::GetPtr(), XrdPfc::Configuration::is_cschk_cache(), XrdPfc::Configuration::is_cschk_net(), XrdPfc::Configuration::is_dir_stat_reporting_on(), XrdOfsConfigPI::Load(), XrdPfc::Configuration::m_accHistorySize, XrdPfc::Configuration::m_allow_xrdpfc_command, XrdPfc::Configuration::m_bufferSize, XrdPfc::Configuration::m_cs_Chk, XrdPfc::Configuration::m_cs_ChkTLS, XrdPfc::Configuration::m_cs_UVKeep, XrdPfc::Configuration::m_data_space, XrdPfc::Configuration::m_dirStatsDirGlobs, XrdPfc::Configuration::m_dirStatsDirs, XrdPfc::Configuration::m_dirStatsMaxDepth, XrdPfc::Configuration::m_dirStatsStoreDepth, XrdPfc::Configuration::m_diskTotalSpace, XrdPfc::Configuration::m_diskUsageHWM, XrdPfc::TmpConfiguration::m_diskUsageHWM, XrdPfc::Configuration::m_diskUsageLWM, XrdPfc::TmpConfiguration::m_diskUsageLWM, XrdPfc::Configuration::m_fileUsageBaseline, XrdPfc::TmpConfiguration::m_fileUsageBaseline, XrdPfc::Configuration::m_fileUsageMax, XrdPfc::TmpConfiguration::m_fileUsageMax, XrdPfc::Configuration::m_fileUsageNominal, XrdPfc::TmpConfiguration::m_fileUsageNominal, XrdPfc::Configuration::m_flushCnt, XrdPfc::TmpConfiguration::m_flushRaw, XrdPfc::Configuration::m_hdfsbsize, XrdPfc::Configuration::m_hdfsmode, XrdPfc::Configuration::m_meta_space, XrdPfc::Configuration::m_onlyIfCachedMinFrac, XrdPfc::Configuration::m_onlyIfCachedMinSize, XrdPfc::Configuration::m_prefetch_max_blocks, XrdPfc::Configuration::m_purgeColdFilesAge, XrdPfc::Configuration::m_purgeInterval, XrdPfc::Configuration::m_RamAbsAvailable, XrdPfc::Configuration::m_RamKeepStdBlocks, XrdPfc::Configuration::m_username, XrdPfc::Configuration::m_wqueue_blocks, XrdPfc::Configuration::m_wqueue_threads, XrdOfsConfigPI::New(), open, XrdOfsConfigPI::Parse(), XrdOfsConfigPI::Plugin(), XrdOfsConfigPI::Push(), XrdOucEnv::Put(), XrdPfc::Info::s_maxNumAccess, XrdSysError::Say(), XrdOss::StatVS(), XrdOfsConfigPI::theOssLib, XrdOssVSInfo::Total, TRACE, XrdOucUtils::UserName(), XrdSysTrace::What, and XrdOucGetCache().
Referenced by Config(), and XrdOucGetCache().
|
virtual |
Definition at line 994 of file XrdPfc.cc.
References Debug, DecideIfConsideredCached(), DetermineFullFileSize(), XrdPfc::File::Fstat(), XrdCl::URL::GetPath(), XrdPfc::Info::s_infoExtension, XrdOss::Stat(), stat, TRACE, and XrdOssOK.
Referenced by XrdPfcFSctl::FSctl().
|
static |
Singleton creation.
Definition at line 156 of file XrdPfc.cc.
References Cache().
Referenced by XrdOucGetCache().
bool Cache::Decide | ( | XrdOucCacheIO * | io | ) |
Makes decision if the original XrdOucCacheIO should be cached.
& | URL of file |
Definition at line 167 of file XrdPfc.cc.
References XrdPfc::Decision::Decide(), XrdCl::URL::GetPath(), and XrdOucCacheIO::Path().
Referenced by Attach().
bool Cache::DecideIfConsideredCached | ( | long long | file_size, |
long long | bytes_on_disk ) |
Definition at line 961 of file XrdPfc.cc.
References XrdPfc::Configuration::m_onlyIfCachedMinFrac, and XrdPfc::Configuration::m_onlyIfCachedMinSize.
Referenced by ConsiderCached(), and Stat().
void Cache::DeRegisterPrefetchFile | ( | File * | file | ) |
Definition at line 713 of file XrdPfc.cc.
References XrdSysCondVar::Lock(), and XrdSysCondVar::UnLock().
long long Cache::DetermineFullFileSize | ( | const std::string & | cinfo_fname | ) |
Definition at line 928 of file XrdPfc.cc.
References Debug, XrdSysXAttr::Get(), XrdPfc::Info::GetFileSize(), XrdOss::Lfn2Pfn(), XrdPfc::Configuration::m_username, XrdOss::newFile(), XrdOssDF::Open(), XrdPfc::Info::Read(), TRACE, and XrdSysXAttrActive.
Referenced by ConsiderCached(), and Stat().
void Cache::ExecuteCommandUrl | ( | const std::string & | command_url | ) |
Definition at line 48 of file XrdPfcCommand.cc.
References XrdOuca2x::a2i(), XrdOuca2x::a2sz(), XrdOssDF::Close(), Create, Debug, ERRNO_AND_ERRSTR, Error, XrdPfc::SplitParser::fill_argv(), XrdPfc::SplitParser::get_reminder(), XrdPfc::SplitParser::get_reminder_with_delim(), XrdPfc::SplitParser::get_token(), XrdOucArgs::getarg(), XrdOssDF::getFD(), XrdOucArgs::getopt(), GetOss(), XrdPfc::Configuration::m_bufferSize, XrdPfc::Configuration::m_data_space, XrdPfc::Configuration::m_meta_space, XrdPfc::Configuration::m_username, MAX_ACCESSES, XrdOss::newFile(), ONE_GB, ONE_MB, XrdOssDF::Open(), XrdOucEnv::Put(), XrdPfc::Info::s_infoExtension, XrdSysError::Say(), XrdOucArgs::Set(), XrdPfc::Info::SetAllBitsSynced(), XrdPfc::Info::SetBufferSizeFileSizeAndCreationTime(), Stat, stat, TRACE, UnlinkFile(), usage(), XrdPfc::Info::Write(), XrdPfc::Info::WriteIOStatSingle(), XRDOSS_mkpath, and XrdOssOK.
void Cache::FileSyncDone | ( | File * | f, |
bool | high_debug ) |
File * Cache::GetFile | ( | const std::string & | path, |
IO * | io, | ||
long long | off = 0, | ||
long long | filesize = 0 ) |
Definition at line 415 of file XrdPfc.cc.
References XrdPfc::File::AddIO(), XrdSysCondVar::Broadcast(), Debug, Error, XrdPfc::File::FileOpen(), XrdOucCacheIO::Fstat(), stat, TRACE, and XrdSysCondVar::Wait().
Referenced by XrdPfc::IOFile::IOFile().
|
inline |
|
static |
Singleton access.
Definition at line 163 of file XrdPfc.cc.
Referenced by XrdPfc::IOFile::IOFile(), XrdPfc::IOFileBlock::IOFileBlock(), Attach(), XrdPfc::IOFile::DetachFinalize(), XrdPfc::File::GetLog(), XrdPfc::File::GetTrace(), XrdPfc::GetTrace(), PrefetchThread(), ProcessWriteTaskThread(), PurgeThread(), ResourceMonitorHeartBeatThread(), XrdPfc::File::Sync(), and XrdPfc::File::WriteBlockToDisk().
|
inline |
Definition at line 401 of file XrdPfc.hh.
Referenced by XrdPfc::File::GetLog().
File * Cache::GetNextFileToPrefetch | ( | ) |
Definition at line 735 of file XrdPfc.cc.
References XrdSysCondVar::Lock(), XrdSysCondVar::UnLock(), and XrdSysCondVar::Wait().
Referenced by Prefetch().
|
inline |
Definition at line 389 of file XrdPfc.hh.
Referenced by ExecuteCommandUrl().
|
inline |
Definition at line 402 of file XrdPfc.hh.
Referenced by XrdPfc::File::GetTrace(), XrdPfc::GetTrace(), and XrdPfc::IO::GetTrace().
bool Cache::IsFileActiveOrPurgeProtected | ( | const std::string & | path | ) |
Definition at line 684 of file XrdPfc.cc.
Referenced by Purge().
|
virtual |
Get the path to a file that is complete in the local cache. By default, the file must be complete in the cache (i.e. no blocks are missing). This can be overridden. This path can be used to access the file on the local node.
Reimplemented from XrdOucCache.
Definition at line 796 of file XrdPfc.cc.
References XrdOss::Chmod(), XrdOssDF::Close(), Debug, XrdOucCache::ForAccess, XrdOucCache::ForInfo, XrdOucCache::ForPath, XrdPfc::Info::GetFileSize(), XrdCl::URL::GetPath(), XrdPfc::Info::IsComplete(), XrdOss::Lfn2Pfn(), XrdSysCondVar::Lock(), XrdPfc::Configuration::m_username, XrdOss::newFile(), XrdOssDF::Open(), XrdPfc::Info::Read(), XrdPfc::Info::s_infoExtension, XrdOss::Stat(), stat, TRACE, XrdSysCondVar::UnLock(), XrdPfc::Info::Write(), XrdPfc::Info::WriteIOStatSingle(), and XrdOssOK.
void Cache::Prefetch | ( | ) |
Definition at line 754 of file XrdPfc.cc.
References GetNextFileToPrefetch(), XrdSysMutex::Lock(), XrdPfc::Configuration::m_RamAbsAvailable, XrdPfc::File::Prefetch(), XrdSysMutex::UnLock(), and XrdSysTimer::Wait().
Referenced by PrefetchThread().
|
virtual |
Preapare the cache for a file open request. This method is called prior to actually opening a file. This method is meant to allow defering an open request or implementing the full I/O stack in the cache layer.
Reimplemented from XrdOucCache.
Definition at line 1054 of file XrdPfc.cc.
References XrdCl::URL::GetPath(), XrdPfc::Configuration::m_allow_xrdpfc_command, XrdPfc::Info::s_infoExtension, schedP, XrdScheduler::Schedule(), XrdOss::Stat(), stat, TRACE, and XrdOssOK.
void Cache::ProcessWriteTasks | ( | ) |
Separate task which writes blocks from ram to disk.
Definition at line 308 of file XrdPfc.cc.
References XrdPfc::Block::get_size(), XrdSysCondVar::Lock(), XrdPfc::File::lPath(), XrdPfc::Block::m_file, XrdPfc::Configuration::m_wqueue_blocks, TRACE, XrdSysCondVar::UnLock(), XrdSysCondVar::Wait(), and XrdPfc::File::WriteBlockToDisk().
Referenced by ProcessWriteTaskThread().
void XrdPfc::Cache::Purge | ( | ) |
Thread function invoked to scan and purge files from disk when needed.
Definition at line 698 of file XrdPfcPurge.cc.
References XrdPfc::Configuration::are_file_usage_limits_set(), XrdPfc::FPurgeState::begin_traversal(), XrdPfc::Configuration::calculate_fractional_usages(), XrdOssDF::Close(), Debug, XrdPfc::DataFsState::dump_recursively(), XrdPfc::FPurgeState::end_traversal(), Error, XrdOssVSInfo::Free, fstat, XrdPfc::DataFsState::get_root(), XrdPfc::FPurgeState::getMinTime(), XrdPfc::FPurgeState::getNBytesTotal(), XrdPfc::Configuration::is_age_based_purge_in_effect(), XrdPfc::Configuration::is_dir_stat_reporting_on(), XrdPfc::Configuration::is_uvkeep_purge_in_effect(), IsFileActiveOrPurgeProtected(), XrdPfc::Configuration::m_cs_UVKeep, XrdPfc::Configuration::m_data_space, XrdPfc::Configuration::m_diskUsageHWM, XrdPfc::Configuration::m_diskUsageLWM, XrdPfc::Configuration::m_fileUsageBaseline, XrdPfc::Configuration::m_fileUsageNominal, XrdPfc::FPurgeState::m_fmap, XrdPfc::Configuration::m_purgeAgeBasedPeriod, XrdPfc::Configuration::m_purgeColdFilesAge, XrdPfc::Configuration::m_purgeInterval, XrdPfc::Configuration::m_username, XrdPfc::FPurgeState::MoveListEntriesToMap(), XrdOss::newDir(), XrdOssDF::Opendir(), XrdPfc::Info::s_infoExtension, XrdPfc::FPurgeState::setMinTime(), XrdPfc::FPurgeState::setUVKeepMinTime(), XrdOss::Stat(), stat, XrdOss::StatVS(), XrdOssVSInfo::Total, TRACE, XrdPfc::FPurgeState::TraverseNamespace(), XrdOss::Unlink(), XrdPfc::DataFsState::upward_propagate_usage_purged(), and XrdOssOK.
Referenced by PurgeThread().
|
inline |
Reference XrdPfc configuration.
Definition at line 319 of file XrdPfc.hh.
Referenced by XrdPfc::IOFileBlock::IOFileBlock(), Attach(), Conf(), XrdPfc::File::WriteBlockToDisk(), and XrdOucGetCache().
void Cache::RegisterPrefetchFile | ( | File * | file | ) |
Definition at line 697 of file XrdPfc.cc.
References XrdSysCondVar::Lock(), XrdSysCondVar::Signal(), and XrdSysCondVar::UnLock().
Definition at line 497 of file XrdPfc.cc.
References Debug, XrdPfc::File::GetLocalPath(), XrdPfc::File::RemoveIO(), and TRACE.
Referenced by XrdPfc::IOFile::DetachFinalize(), and XrdPfc::IOFileBlock::DetachFinalize().
void Cache::ReleaseRAM | ( | char * | buf, |
long long | size ) |
Definition at line 397 of file XrdPfc.cc.
References XrdPfc::Configuration::m_bufferSize, and XrdPfc::Configuration::m_RamKeepStdBlocks.
void Cache::RemoveWriteQEntriesFor | ( | File * | f | ) |
Remove blocks from write queue which belong to given prefetch. This method is used at the time of File destruction.
Definition at line 275 of file XrdPfc.cc.
References XrdPfc::File::BlocksRemovedFromWriteQ(), XrdSysCondVar::Lock(), XrdPfc::File::lPath(), TRACE, and XrdSysCondVar::UnLock().
Referenced by UnlinkFile().
char * Cache::RequestRAM | ( | long long | size | ) |
Definition at line 357 of file XrdPfc.cc.
References XrdSysMutex::Lock(), XrdPfc::Configuration::m_bufferSize, XrdPfc::Configuration::m_RamAbsAvailable, and XrdSysMutex::UnLock().
void XrdPfc::Cache::ResourceMonitorHeartBeat | ( | ) |
Thread function checking resource usage periodically.
Definition at line 606 of file XrdPfcPurge.cc.
References XrdOucCacheStats::CacheStats::DiskSize, XrdOucCacheStats::Lock(), XrdPfc::Configuration::m_diskTotalSpace, XrdPfc::Configuration::m_RamAbsAvailable, XrdOucCacheStats::CacheStats::MemSize, XrdOucCacheStats::CacheStats::MemUsed, XrdOucCacheStats::CacheStats::MemWriteQ, XrdOucCache::Statistics, XrdOucCacheStats::UnLock(), and XrdOucCacheStats::X.
Referenced by ResourceMonitorHeartBeatThread().
|
inline |
|
virtual |
Reimplemented from XrdOucCache.
Definition at line 1105 of file XrdPfc.cc.
References Debug, DecideIfConsideredCached(), DetermineFullFileSize(), XrdPfc::File::Fstat(), XrdCl::URL::GetPath(), XrdPfc::Info::s_infoExtension, XrdOss::Stat(), TRACE, and XrdOssOK.
|
static |
|
virtual |
Reimplemented from XrdOucCache.
Definition at line 1161 of file XrdPfc.cc.
References XrdCl::URL::GetPath(), and UnlinkFile().
int Cache::UnlinkFile | ( | const std::string & | f_name, |
bool | fail_if_open ) |
Remove cinfo and data files from cache.
Definition at line 1171 of file XrdPfc.cc.
References Debug, XrdPfc::File::initiate_emergency_shutdown(), RemoveWriteQEntriesFor(), XrdPfc::Info::s_infoExtension, TRACE, and XrdOss::Unlink().
Referenced by ExecuteCommandUrl(), XrdPfcFSctl::FSctl(), XrdPfc::File::Sync(), and Unlink().
|
inlinestatic |
void Cache::WriteFileSizeXAttr | ( | int | cinfo_fd, |
long long | file_size ) |
Definition at line 913 of file XrdPfc.cc.
References Debug, XrdSysXAttr::Set(), TRACE, and XrdSysXAttrActive.
|
static |
Definition at line 408 of file XrdPfc.hh.
Referenced by XrdPfc::IO::Detach(), Prepare(), and XrdOucGetCache().