#include <LocalFileSystem.h>
Classes | |
struct | FSInfo |
Information about file systems on this node. More... | |
Public Member Functions | |
std::string | findCachePath (const std::vector< std::string > &paths, double minFreeSpace) |
bool | isLocalPath (const std::string &path) |
void | issueWarning () |
LocalFileSystem (void) | |
~LocalFileSystem (void) | |
Private Member Functions | |
FSInfo * | findMount (const char *path, struct statfs *sfs, struct stat *s, std::vector< std::string > &) |
FSInfo * | initFSInfo (void *p) |
int | initFSList (void) |
LocalFileSystem (LocalFileSystem &) | |
void | operator= (LocalFileSystem &) |
int | readFSTypes (void) |
int | statFSInfo (FSInfo *i) |
Private Attributes | |
std::vector< FSInfo * > | fs_ |
std::vector< std::string > | fstypes_ |
std::string | unusable_dir_warnings_ |
Definition at line 10 of file LocalFileSystem.h.
LocalFileSystem::LocalFileSystem | ( | void | ) |
Initialise local file system status.
Definition at line 591 of file LocalFileSystem.cc.
References initFSList(), and readFSTypes().
LocalFileSystem::~LocalFileSystem | ( | void | ) |
Free local file system status resources.
Definition at line 601 of file LocalFileSystem.cc.
References alignCSCRings::e, fs_, and i.
|
private |
std::string LocalFileSystem::findCachePath | ( | const std::vector< std::string > & | paths, |
double | minFreeSpace | ||
) |
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 475 of file LocalFileSystem.cc.
References dtNoiseDBValidation_cfg::cerr, alignCSCRings::e, findMount(), LocalFileSystem::FSInfo::freespc, i, LocalFileSystem::FSInfo::local, contentValuesFiles::m, AlCaHLTBitMon_ParallelJobs::p, cmsHarvester::path, query::result, AlCaHLTBitMon_QueryRunRegistry::string, and unusable_dir_warnings_.
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 323 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::bind, dir, fs_, i, LocalFileSystem::FSInfo::origin, cmsHarvester::path, 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 142 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::bind, LocalFileSystem::FSInfo::checked, LocalFileSystem::FSInfo::dev, LocalFileSystem::FSInfo::dir, LocalFileSystem::FSInfo::freespc, LocalFileSystem::FSInfo::fsname, LocalFileSystem::FSInfo::fstype, fstypes_, i, j, LocalFileSystem::FSInfo::local, contentValuesFiles::m, LocalFileSystem::FSInfo::origin, AlCaHLTBitMon_ParallelJobs::p, and LocalFileSystem::FSInfo::type.
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 213 of file LocalFileSystem.cc.
References fs_, initFSInfo(), and contentValuesFiles::m.
Referenced by LocalFileSystem().
bool LocalFileSystem::isLocalPath | ( | const std::string & | path | ) |
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 418 of file LocalFileSystem.cc.
References findMount(), LocalFileSystem::FSInfo::local, and contentValuesFiles::m.
Referenced by StorageFactory::wrapNonLocalFile().
void LocalFileSystem::issueWarning | ( | ) |
Definition at line 582 of file LocalFileSystem.cc.
References unusable_dir_warnings_.
Referenced by StorageFactory::wrapNonLocalFile().
|
private |
|
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 60 of file LocalFileSystem.cc.
References assert(), fstypes_, geometryCSVtoXML::line, and run_regression::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 263 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::checked, LocalFileSystem::FSInfo::dev, LocalFileSystem::FSInfo::dir, LocalFileSystem::FSInfo::freespc, LocalFileSystem::FSInfo::fstype, and run_regression::ret.
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().
|
private |
Definition at line 30 of file LocalFileSystem.h.
Referenced by findCachePath(), and issueWarning().