#include <LocalFileSystem.h>
Classes | |
struct | FSInfo |
Information about file systems on this node. More... | |
Public Member Functions | |
std::pair< std::string, std::string > | findCachePath (const std::vector< std::string > &paths, double minFreeSpace) const |
bool | isLocalPath (const std::string &path) const |
LocalFileSystem (void) | |
~LocalFileSystem (void) | |
Private Member Functions | |
FSInfo * | findMount (const char *path, struct statfs *sfs, struct stat *s, std::vector< std::string > &) const |
FSInfo * | initFSInfo (void *p) |
int | initFSList (void) |
LocalFileSystem (LocalFileSystem &)=delete | |
void | operator= (LocalFileSystem &)=delete |
int | readFSTypes (void) |
int | statFSInfo (FSInfo *i) const |
Private Attributes | |
std::vector< FSInfo * > | fs_ |
std::vector< std::string > | fstypes_ |
Definition at line 11 of file LocalFileSystem.h.
LocalFileSystem::LocalFileSystem | ( | void | ) |
Initialise local file system status.
Definition at line 512 of file LocalFileSystem.cc.
References initFSList(), and readFSTypes().
LocalFileSystem::~LocalFileSystem | ( | void | ) |
Free local file system status resources.
Definition at line 521 of file LocalFileSystem.cc.
References MillePedeFileConverter_cfg::e, fs_, and mps_fire::i.
|
privatedelete |
std::pair< std::string, std::string > LocalFileSystem::findCachePath | ( | const std::vector< std::string > & | paths, |
double | minFreeSpace | ||
) | const |
Find a writeable directory among paths which is known to be local and has at least minFreeSpace amount of free space in gigabytes.
The paths should contain list of relative or absolute candidate directories. If an entry starts with letter "$" then the value of that environment variable is used instead; if the value is $TMPDIR and the environment variable is empty, "/tmp" is used instead.
Returns the first path in paths which satisfies the criteria, expanded to environment variable value if appropriate, resolved to full absolute path. If no suitable path can be found, returns an empty string.
Does not throw exceptions. If any serious errors occur, the errors are reported as message logger warnings but the actual error is swallowed and the directory concerned is skipped. Non-existent and inaccessible directories are silently ignored without warning.
Definition at line 426 of file LocalFileSystem.cc.
References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, MillePedeFileConverter_cfg::e, findMount(), reco_skim_cfg_mod::fullpath, mps_fire::i, visualization-live-secondInstance_cfg::m, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, castor_dqm_sourceclient_file_cfg::path, Skims_PA_cff::paths, mps_fire::result, alignCSCRings::s, edm_modernize_messagelogger::stat, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by StorageFactory::setTempDir().
|
private |
Find the file system path was mounted from. The statfs() and stat() information for path should be in sfs and s, respectively.
Finds currently mounted file system that path is owned by, and returns the FSInfo object for it, or null if no matching live file system can be found. If the return value is non-null, then it is guaranteed path was on that file system.
A null return value is possible for certain paths which are not on any mounted file system (e.g. /dev or /selinux), or if the file system is unavailable or some other way dysfunctional, such as dead nfs mount or filesystem does not implement statfs().
Definition at line 289 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::bind, DeadROC_duringRun::dir, fs_, reco_skim_cfg_mod::fullpath, mps_fire::i, LocalFileSystem::FSInfo::origin, castor_dqm_sourceclient_file_cfg::path, alignCSCRings::s, indexGen::s2, edm_modernize_messagelogger::stat, and statFSInfo().
Referenced by findCachePath(), and isLocalPath().
|
private |
Initialise file system description from /etc/mtab info.
This function saves the information from getmntent(), matching the file system type to the known local ones. It only remembers the information from /etc/mtab, so the dev and fstype attributes are not yet valid; call statFSInfo() to fill those in. This avoids touching irrelevant filesystems unnecessarily; the file system may not be fully functional, or partially offline, or just very slow.
Definition at line 123 of file LocalFileSystem.cc.
References fstypes_, mps_fire::i, dqmiolumiharvest::j, visualization-live-secondInstance_cfg::m, and AlCaHLTBitMon_ParallelJobs::p.
Referenced by initFSList().
|
private |
Initialise the list of currently mounted file systems.
Reads /etc/mtab (or equivalent) to determine all currently mounted file systems, and initialises FSInfo structure for them. It does not yet call statFSInfo() on them, so the device and file type ids are not yet complete.
Definition at line 191 of file LocalFileSystem.cc.
References fs_, initFSInfo(), and visualization-live-secondInstance_cfg::m.
Referenced by LocalFileSystem().
bool LocalFileSystem::isLocalPath | ( | const std::string & | path | ) | const |
Determine if path is on a file system known to be local.
Returns true
if the path is definitely known to be local. Returns false
otherwise, including when it's not possible to determine anything about the path at all.
Does not throw exceptions. If any errors occur, the errors are reported as message logger warnings but the actual error is swallowed and the function simply returns false
.
Definition at line 377 of file LocalFileSystem.cc.
References findMount(), reco_skim_cfg_mod::fullpath, visualization-live-secondInstance_cfg::m, castor_dqm_sourceclient_file_cfg::path, alignCSCRings::s, and edm_modernize_messagelogger::stat.
Referenced by StorageFactory::wrapNonLocalFile().
|
privatedelete |
|
private |
Read /proc/filesystems to determine which filesystems are local, meaning access latency is tolerably small, and operating system buffer cache will likely do a good job at caching file contents and accelerate many small file operations reasonably well.
The /proc list enumerates all filesystems known by the kernel, except a few special ones like /dev and /selinux. The ones marked as "nodev" have unstable device definition, meaning they are some way or another "virtual" file systems. This labeling is used by kernel nfsd to determine which file systems are safe for exporting without help (fixing fsid), and turns out to be close enough to list of file systems that we can consider to be high-speed local, minus a few exceptions. Everything else we consider "remote" or "slow" file systems where application should prefer massive bulk streaming I/O for better performance.
The exceptions to /proc/filesystems list: lustre and fuse file systems are forced to remote status. Everything else like NFS, AFS, GPFS and various cluster-based systems are already remote.
Definition at line 58 of file LocalFileSystem.cc.
References cms::cuda::assert(), fstypes_, mps_splice::line, and runTheMatrix::ret.
Referenced by LocalFileSystem().
|
private |
Figure out file system device and type ids.
Calls stat() and statfs() on the file system to determine device and file system type ids. These are required to determine if two paths are actually on the same file system.
This function can be called any number of times. It only does the file system check the first time the function is called.
Definition at line 236 of file LocalFileSystem.cc.
References mps_fire::i, runTheMatrix::ret, alignCSCRings::s, and edm_modernize_messagelogger::stat.
Referenced by findMount().
|
private |
Definition at line 28 of file LocalFileSystem.h.
Referenced by findMount(), initFSList(), and ~LocalFileSystem().
|
private |
Definition at line 29 of file LocalFileSystem.h.
Referenced by initFSInfo(), and readFSTypes().