filesetup: keep OS_O_DIRECT flag when pre-allocating file
authorweiping zhang <zhangweiping@didichuxing.com>
Sat, 29 Jul 2017 08:47:59 +0000 (16:47 +0800)
committerweiping zhang <zhangweiping@didichuxing.com>
Sun, 30 Jul 2017 12:07:32 +0000 (20:07 +0800)
When direct=1 the file open for pre-allocation should also set OS_O_DIRECT so
we fail earlier if the filesystem/file doesn't support direct operations.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
filesetup.c

index 839aefc..0e5599a 100644 (file)
@@ -146,6 +146,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                flags |= O_CREAT;
        if (new_layout)
                flags |= O_TRUNC;
+       if (td->o.odirect)
+               flags |= OS_O_DIRECT;
 
 #ifdef WIN32
        flags |= _O_BINARY;