From 5bdc45228a8cc99bb0f88565ddc12c6fdf7a9cdc Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 12 Feb 2018 10:13:04 -0700 Subject: [PATCH] filesetup: convert root flush warning to fio_did_warn() Signed-off-by: Jens Axboe --- debug.h | 4 ++++ filesetup.c | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/debug.h b/debug.h index 68a5adca..7e8c2240 100644 --- a/debug.h +++ b/debug.h @@ -39,6 +39,10 @@ static inline bool fio_did_warn(unsigned int mask) return false; } +enum { + FIO_WARN_ROOT_FLUSH = 1, +}; + #ifdef FIO_INC_DEBUG struct debug_level { const char *name; diff --git a/filesetup.c b/filesetup.c index 3cda6063..cced5561 100644 --- a/filesetup.c +++ b/filesetup.c @@ -20,8 +20,6 @@ #include #endif -static int root_warn; - static FLIST_HEAD(filename_list); /* @@ -516,10 +514,9 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, ret = blockdev_invalidate_cache(f); } if (ret < 0 && errno == EACCES && geteuid()) { - if (!root_warn) { + if (!fio_did_warn(FIO_WARN_ROOT_FLUSH)) { log_err("fio: only root may flush block " "devices. Cache flush bypassed!\n"); - root_warn = 1; } ret = 0; } -- 2.25.1