Fix failure in opening files with O_NOATIME
[fio.git] / filesetup.c
index 5134fdbb8af5a52e08e5ad8b60ea820e0caeab9f..6c241516ff9424f526e587b9acd620b817c9cdfb 100644 (file)
@@ -234,6 +234,7 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
        if (f->filetype != FIO_TYPE_FILE)
                flags |= O_NOATIME;
 
+open_again:
        if (td_write(td)) {
                assert(!read_only);
 
@@ -262,6 +263,11 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
                char buf[FIO_VERROR_SIZE];
                int __e = errno;
 
+               if (errno == EPERM && (flags & O_NOATIME)) {
+                       flags &= ~O_NOATIME;
+                       goto open_again;
+               }
+
                snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name);
 
                td_verror(td, __e, buf);