Fix failure in opening files with O_NOATIME

If we try to open a file with O_NOATIME and it fails, turn off
O_NOATIME and try again.  This occurs if the user does not own
the file and is unprivileged.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 5134fdb..6c24151 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -234,6 +234,7 @@
 	if (f->filetype != FIO_TYPE_FILE)
 		flags |= O_NOATIME;
 
+open_again:
 	if (td_write(td)) {
 		assert(!read_only);
 
@@ -262,6 +263,11 @@
 		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);