filesetup: convert root flush warning to fio_did_warn()
authorJens Axboe <axboe@kernel.dk>
Mon, 12 Feb 2018 17:13:04 +0000 (10:13 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 12 Feb 2018 17:13:04 +0000 (10:13 -0700)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
debug.h
filesetup.c

diff --git a/debug.h b/debug.h
index 68a5adca268e6b331433ffa58183c44b3b45ed67..7e8c22406450df9a8a905aba5ddbcc8c652e99ca 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -39,6 +39,10 @@ static inline bool fio_did_warn(unsigned int mask)
        return false;
 }
 
        return false;
 }
 
+enum {
+       FIO_WARN_ROOT_FLUSH     = 1,
+};
+
 #ifdef FIO_INC_DEBUG
 struct debug_level {
        const char *name;
 #ifdef FIO_INC_DEBUG
 struct debug_level {
        const char *name;
index 3cda60630d5d1f54ad1a7fa108b377e1da7c444e..cced5561b74ed84016b59606627ad9deb828720b 100644 (file)
@@ -20,8 +20,6 @@
 #include <linux/falloc.h>
 #endif
 
 #include <linux/falloc.h>
 #endif
 
-static int root_warn;
-
 static FLIST_HEAD(filename_list);
 
 /*
 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()) {
                        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");
                                log_err("fio: only root may flush block "
                                        "devices. Cache flush bypassed!\n");
-                               root_warn = 1;
                        }
                        ret = 0;
                }
                        }
                        ret = 0;
                }