Disable status file updates on error
authorJens Axboe <axboe@fb.com>
Thu, 13 Mar 2014 14:49:28 +0000 (08:49 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 13 Mar 2014 14:49:28 +0000 (08:49 -0600)
If fio doesn't have permission to unlink() the status file,
it'll continually dump status updates. If this happens, stop
doing status updates and log an error indicating why.

Signed-off-by: Jens Axboe <axboe@fb.com>
stat.c

diff --git a/stat.c b/stat.c
index f018f33d029288ce24e224dcab1f7c0e6161a387..c2c717b56f80426519f3b9376425a2761d62b9ce 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1479,6 +1479,7 @@ void show_running_run_stats(void)
 
 static int status_interval_init;
 static struct timeval status_time;
+static int status_file_disabled;
 
 #define FIO_STATUS_FILE                "fio-dump-status"
 
@@ -1488,6 +1489,9 @@ static int check_status_file(void)
        const char *temp_dir;
        char fio_status_file_path[PATH_MAX];
 
+       if (status_file_disabled)
+               return 0;
+
        temp_dir = getenv("TMPDIR");
        if (temp_dir == NULL)
                temp_dir = getenv("TEMP");
@@ -1499,7 +1503,13 @@ static int check_status_file(void)
        if (stat(fio_status_file_path, &sb))
                return 0;
 
-       unlink(fio_status_file_path);
+       if (unlink(fio_status_file_path) < 0) {
+               log_err("fio: failed to unlink %s: %s\n", fio_status_file_path,
+                                                       strerror(errno));
+               log_err("fio: disabling status file updates\n");
+               status_file_disabled = 1;
+       }
+
        return 1;
 }