Add a gflag for IO uring enable/disable (#8931)

Summary:
In case of IO uring bugs, we need to provide a way for users to turn it off.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8931

Test Plan: Manually run db_bench with/without the option and verify the behavior

Reviewed By: pdillinger

Differential Revision: D31040252

Pulled By: anand1976

fbshipit-source-id: 56f2537d6ac8488c9e126296d8190ad9e0158f70
This commit is contained in:
anand76 2021-09-18 09:31:57 -07:00 committed by Facebook GitHub Bot
parent 1c290c785d
commit 99fe4c5005
3 changed files with 17 additions and 1 deletions

View File

@ -12,6 +12,7 @@
* Fix the implementation of `prepopulate_block_cache = kFlushOnly` to only apply to flushes rather than to all generated files.
* Fix WAL log data corruption when using DBOptions.manual_wal_flush(true) and WriteOptions.sync(true) together. The sync WAL should work with locked log_write_mutex_.
* Add checks for validity of the IO uring completion queue entries, and fail the BlockBasedTableReader MultiGet sub-batch if there's an invalid completion
* Add an interface RocksDbIOUringEnable() that, if defined by the user, will allow them to enable/disable the use of IO uring by RocksDB
### New Features
* RemoteCompaction's interface now includes `db_name`, `db_id`, `session_id`, which could help the user uniquely identify compaction job between db instances and sessions.

14
env/fs_posix.cc vendored
View File

@ -73,6 +73,8 @@
#define EXT4_SUPER_MAGIC 0xEF53
#endif
extern "C" bool RocksDbIOUringEnable() __attribute__((__weak__));
namespace ROCKSDB_NAMESPACE {
namespace {
@ -267,7 +269,7 @@ class PosixFileSystem : public FileSystem {
options
#if defined(ROCKSDB_IOURING_PRESENT)
,
thread_local_io_urings_.get()
!IsIOUringEnabled() ? nullptr : thread_local_io_urings_.get()
#endif
));
}
@ -1025,6 +1027,16 @@ class PosixFileSystem : public FileSystem {
#endif
}
#ifdef ROCKSDB_IOURING_PRESENT
bool IsIOUringEnabled() {
if (RocksDbIOUringEnable && RocksDbIOUringEnable()) {
return true;
} else {
return false;
}
}
#endif // ROCKSDB_IOURING_PRESENT
#if defined(ROCKSDB_IOURING_PRESENT)
// io_uring instance
std::unique_ptr<ThreadLocalPtr> thread_local_io_urings_;

View File

@ -1021,6 +1021,9 @@ DEFINE_string(block_cache_trace_file, "", "Block cache trace file path.");
DEFINE_int32(trace_replay_threads, 1,
"The number of threads to replay, must >=1.");
DEFINE_bool(io_uring_enabled, true,
"If true, enable the use of IO uring if the platform supports it");
extern "C" bool RocksDbIOUringEnable() { return FLAGS_io_uring_enabled; }
#endif // ROCKSDB_LITE
static enum ROCKSDB_NAMESPACE::CompressionType StringToCompressionType(