Only do the root warning once per thread
authorJens Axboe <jens.axboe@oracle.com>
Mon, 23 Jul 2007 12:36:00 +0000 (14:36 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 23 Jul 2007 12:36:00 +0000 (14:36 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index 7a9a2afed29b34d345e1628156c2d3ac6848163c..b742f82501f019befc3fbccdff382151d8a0f5af 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "fio.h"
 
+static int root_warn;
+
 static int extend_file(struct thread_data *td, struct fio_file *f)
 {
        int r, new_layout = 0, unlink_file = 0, flags;
@@ -178,7 +180,10 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
        else if (f->filetype == FIO_TYPE_BD) {
                ret = blockdev_invalidate_cache(f->fd);
                if (ret < 0 && errno == EACCES && geteuid()) {
-                       log_err("fio: only root may flush block devices. Cache flush bypassed!\n");
+                       if (!root_warn) {
+                               log_err("fio: only root may flush block devices. Cache flush bypassed!\n");
+                               root_warn = 1;
+                       }
                        ret = 0;
                }
        } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE)