From: anand76 Date: Sat, 18 Sep 2021 16:31:57 +0000 (-0700) Subject: Add a gflag for IO uring enable/disable (#8931) X-Git-Tag: v6.25.1~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=99fe4c5005df69a25c05966b078e5af60495dc26;p=rocksdb.git 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 --- diff --git a/HISTORY.md b/HISTORY.md index 0cbf74ab4..97596eb15 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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. diff --git a/env/fs_posix.cc b/env/fs_posix.cc index 6e967b2ba..d321a746f 100644 --- a/env/fs_posix.cc +++ b/env/fs_posix.cc @@ -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 thread_local_io_urings_; diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 09848baf2..0fe1c1e93 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -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(