From c32504f7059789da7827e872afe83173d4618218 Mon Sep 17 00:00:00 2001 From: Vishesh Yadav Date: Tue, 12 Mar 2019 14:04:18 -0700 Subject: [PATCH] io: Add DISABLE_POSIX_KERNEL_AIO knob to use EIO instead of Kernel AIO - Some Linux filesystems don't support O_DIRECT which is required by Kernel AIO to function properly. Instead of using O_SYNC, EIO is much better options in terms of performance penalty. - Some systems may not support AIO at all. Eg. Windows Subsystem for Linux. FIXES #842 RELATED #274 --- fdbrpc/Net2FileSystem.cpp | 7 ++++++- flow/Knobs.cpp | 1 + flow/Knobs.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fdbrpc/Net2FileSystem.cpp b/fdbrpc/Net2FileSystem.cpp index 25c703e1bb..31ce9f6095 100644 --- a/fdbrpc/Net2FileSystem.cpp +++ b/fdbrpc/Net2FileSystem.cpp @@ -58,7 +58,12 @@ Future< Reference > Net2FileSystem::open( std::string filename Future> f; #ifdef __linux__ - if ( (flags & IAsyncFile::OPEN_UNBUFFERED) && !(flags & IAsyncFile::OPEN_NO_AIO) ) + // In the vast majority of cases, we wish to use Kernel AIO. However, some systems + // dont properly support don’t properly support kernel async I/O without O_DIRECT + // or AIO at all. In such cases, DISABLE_POSIX_KERNEL_AIO knob can be enabled to fallback to + // EIO instead of Kernel AIO. + if ((flags & IAsyncFile::OPEN_UNBUFFERED) && !(flags & IAsyncFile::OPEN_NO_AIO) && + !FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO) f = AsyncFileKAIO::open(filename, flags, mode, NULL); else #endif diff --git a/flow/Knobs.cpp b/flow/Knobs.cpp index 98f472a0bc..00151c43ed 100644 --- a/flow/Knobs.cpp +++ b/flow/Knobs.cpp @@ -79,6 +79,7 @@ FlowKnobs::FlowKnobs(bool randomize, bool isSimulated) { init( MIN_SUBMIT, 10 ); init( PAGE_WRITE_CHECKSUM_HISTORY, 0 ); if( randomize && BUGGIFY ) PAGE_WRITE_CHECKSUM_HISTORY = 10000000; + init( DISABLE_POSIX_KERNEL_AIO, 0 ); //AsyncFileNonDurable init( MAX_PRIOR_MODIFICATION_DELAY, 1.0 ); if( randomize && BUGGIFY ) MAX_PRIOR_MODIFICATION_DELAY = 10.0; diff --git a/flow/Knobs.h b/flow/Knobs.h index 22077dd6f1..e53120981f 100644 --- a/flow/Knobs.h +++ b/flow/Knobs.h @@ -98,6 +98,7 @@ public: int MIN_SUBMIT; int PAGE_WRITE_CHECKSUM_HISTORY; + int DISABLE_POSIX_KERNEL_AIO; //AsyncFileNonDurable double MAX_PRIOR_MODIFICATION_DELAY;