From 38bf569ee71f46758e38ff298435470bc26219bb Mon Sep 17 00:00:00 2001 From: lhsoft Date: Tue, 23 Aug 2022 15:00:14 -0700 Subject: [PATCH] Fix build error with NIOSTATS_CONTEXT (#10506) Summary: Fix https://github.com/facebook/rocksdb/issues/10475 Pull Request resolved: https://github.com/facebook/rocksdb/pull/10506 Reviewed By: hx235 Differential Revision: D38549337 Pulled By: ajkr fbshipit-source-id: fba864fba1b584c41419ca6015d5d62051539812 --- logging/env_logger.h | 4 ++-- monitoring/iostats_context_imp.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/logging/env_logger.h b/logging/env_logger.h index b9099a8347..8164945cfa 100644 --- a/logging/env_logger.h +++ b/logging/env_logger.h @@ -57,12 +57,12 @@ class EnvLogger : public Logger { // Preserve iostats not to pollute writes from user writes. We might // need a better solution than this. SetPerfLevel(PerfLevel::kDisable); - iostats_context.disable_iostats = true; + IOSTATS_SET_DISABLE(true); logger.mutex_.Lock(); } ~FileOpGuard() { logger_.mutex_.Unlock(); - iostats_context.disable_iostats = false; + IOSTATS_SET_DISABLE(false); SetPerfLevel(prev_perf_level_); } diff --git a/monitoring/iostats_context_imp.h b/monitoring/iostats_context_imp.h index 42b8a82fc5..a0b4292dfd 100644 --- a/monitoring/iostats_context_imp.h +++ b/monitoring/iostats_context_imp.h @@ -43,6 +43,8 @@ extern thread_local IOStatsContext iostats_context; PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \ iostats_step_timer_##metric.Start(); +#define IOSTATS_SET_DISABLE(disable) (iostats_context.disable_iostats = disable) + #else // !NIOSTATS_CONTEXT #define IOSTATS_ADD(metric, value) @@ -52,6 +54,7 @@ extern thread_local IOStatsContext iostats_context; #define IOSTATS_SET_THREAD_POOL_ID(value) #define IOSTATS_THREAD_POOL_ID() #define IOSTATS(metric) 0 +#define IOSTATS_SET_DISABLE(disable) #define IOSTATS_TIMER_GUARD(metric) #define IOSTATS_CPU_TIMER_GUARD(metric, clock) static_cast(clock)