in util/FileByteSource.cpp [18:58]
int FileUtil::openForRead(ThreadCtx &threadCtx, const std::string &filename,
const bool isDirectReads) {
int openFlags = O_RDONLY;
if (isDirectReads) {
#ifdef O_DIRECT
// no need to change any flags if we are using F_NOCACHE
openFlags |= O_DIRECT;
#endif
}
if (threadCtx.getOptions().close_on_exec) {
#ifdef O_CLOEXEC
openFlags |= O_CLOEXEC;
#endif
}
int fd;
{
PerfStatCollector statCollector(threadCtx, PerfStatReport::FILE_OPEN);
fd = ::open(filename.c_str(), openFlags);
}
if (fd >= 0) {
if (isDirectReads) {
#ifndef O_DIRECT
#ifdef F_NOCACHE
WVLOG(1) << "O_DIRECT not found, using F_NOCACHE instead "
<< "for " << filename;
int ret = fcntl(fd, F_NOCACHE, 1);
if (ret) {
WPLOG(ERROR) << "Not able to set F_NOCACHE";
}
#else
WDT_CHECK(false)
<< "Direct read enabled, but both O_DIRECT and F_NOCACHE not defined "
<< filename;
#endif
#endif
}
} else {
WPLOG(ERROR) << "Error opening file " << filename;
}
return fd;
}