#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 592 of file LocalFileSystem.cc.
References initFSList(), and readFSTypes().
LocalFileSystem::~LocalFileSystem | ( | void | ) |
Free local file system status resources.
Definition at line 602 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 486 of file LocalFileSystem.cc.
References MessageLogger_cfi::cerr, MillePedeFileConverter_cfg::e, findMount(), LocalFileSystem::FSInfo::freespc, mps_fire::i, LocalFileSystem::FSInfo::local, funct::m, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, callgraph::path, mps_fire::result, 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 328 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::bind, LocalFileSystem::FSInfo::dev, LocalFileSystem::FSInfo::dir, fs_, mps_fire::i, LocalFileSystem::FSInfo::local, LocalFileSystem::FSInfo::origin, callgraph::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 143 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_, mps_fire::i, LocalFileSystem::FSInfo::local, funct::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 214 of file LocalFileSystem.cc.
References fs_, initFSInfo(), and funct::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 429 of file LocalFileSystem.cc.
References findMount(), LocalFileSystem::FSInfo::local, and funct::m.
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 61 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::fstype, fstypes_, and mps_splice::line.
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 265 of file LocalFileSystem.cc.
References LocalFileSystem::FSInfo::checked, LocalFileSystem::FSInfo::dev, LocalFileSystem::FSInfo::dir, LocalFileSystem::FSInfo::freespc, and LocalFileSystem::FSInfo::fstype.
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().