From a1012b604d46c384eeeb76a43ea2bb48c6fedf06 Mon Sep 17 00:00:00 2001 From: Willem Jan Withagen Date: Wed, 7 Jul 2021 11:50:50 +0200 Subject: [PATCH] blk/kernel: Only use file hint capabilities if available. Without WRITE_LIFE capabilities, only one file is used. And rocksdb sets this value also to > 0, so we need to catch this here instead of trusting rocksdb to set write_hint. Signed-off-by: Willem Jan Withagen --- src/blk/kernel/KernelDevice.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 0592f571b8f40..304bcd732d43a 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -414,9 +414,15 @@ bool KernelDevice::get_thin_utilization(uint64_t *total, uint64_t *avail) const int KernelDevice::choose_fd(bool buffered, int write_hint) const { -assert(write_hint >= WRITE_LIFE_NOT_SET && write_hint < WRITE_LIFE_MAX); +#if defined(F_SET_FILE_RW_HINT) if (!enable_wrt) write_hint = WRITE_LIFE_NOT_SET; +#else + // Without WRITE_LIFE capabilities, only one file is used. + // And rocksdb sets this value also to > 0, so we need to catch this here + // instead of trusting rocksdb to set write_hint. + write_hint = WRITE_LIFE_NOT_SET; +#endif return buffered ? fd_buffereds[write_hint] : fd_directs[write_hint]; } -- 2.39.5