Net2FileSystem: Add guards to honor DISABLE_POSIX_KERNEL_AIO

- Adds some asserts in KAIO to ensure that when knob is set, we don't
end up using KAIO in any case.

- Fixes a bug where we initialize AsyncFileKAIO on Linux builds even
when KAIO is disabled. This can cause problems in systems such as
Windows Subsystem for Linux where KAIO is not supported.

FIXES #2382
This commit is contained in:
Vishesh Yadav 2020-03-27 01:49:35 -07:00
parent a6fe8c1d1f
commit 1901f49b97
2 changed files with 6 additions and 1 deletions

View File

@ -97,6 +97,7 @@ public:
#endif
static Future<Reference<IAsyncFile>> open( std::string filename, int flags, int mode, void* ignore ) {
ASSERT( !FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO );
ASSERT( flags & OPEN_UNBUFFERED );
if (flags & OPEN_LOCK)
@ -153,6 +154,7 @@ public:
}
static void init( Reference<IEventFD> ev, double ioTimeout ) {
ASSERT( !FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO );
if( !g_network->isSimulated() ) {
ctx.countAIOSubmit.init(LiteralStringRef("AsyncFile.CountAIOSubmit"));
ctx.countAIOCollect.init(LiteralStringRef("AsyncFile.CountAIOCollect"));
@ -578,7 +580,7 @@ private:
static Context ctx;
explicit AsyncFileKAIO(int fd, int flags, std::string const& filename) : fd(fd), flags(flags), filename(filename), failed(false) {
ASSERT( !FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO );
if( !g_network->isSimulated() ) {
countFileLogicalWrites.init(LiteralStringRef("AsyncFile.CountFileLogicalWrites"), filename);
countFileLogicalReads.init( LiteralStringRef("AsyncFile.CountFileLogicalReads"), filename);

View File

@ -93,6 +93,9 @@ Net2FileSystem::Net2FileSystem(double ioTimeout, std::string fileSystemPath)
{
Net2AsyncFile::init();
#ifdef __linux__
if (FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO)
return;
AsyncFileKAIO::init( Reference<IEventFD>(N2::ASIOReactor::getEventFD()), ioTimeout );
if (fileSystemPath.empty()) {