diff --git a/HISTORY.md b/HISTORY.md index 0cbf74ab4c..97596eb154 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 6e967b2bad..d321a746fe 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 09848baf27..0fe1c1e938 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(