title: direct io - O_DIRECT seems not working when write to file
body: <p>On linux (<em>Linux 3.16.0-38-generic #52~14.04.1-Ubuntu x86_64 GNU/Linux</em>), When try to write to a file via direct io with <code>O_DIRECT</code> flag enabled, it seems after write, the file is still empty, please help.</p>
  
  <p>By the way, I am aware of direct io should normally be used with program level cache, following program just want to have a test on direct io.</p>
  
  <p><strong>direct_io_test.c:</strong></p>
  
  <pre><code>// direct io test
  
  #define _GNU_SOURCE
  #include &lt;stdio.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;string.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;fcntl.h&gt;
  
  int direct_io_test() {
      char *fp= "/tmp/direct_io.txt";
      int flag = O_RDWR | O_CREAT | O_APPEND | O_DIRECT;
      mode_t mode = 0644;
  
      int fd = open(fp, flag, mode);
      if (fd == -1) {
          printf("Failed to open file. Error: \t%s\n", strerror(errno));
          return errno;
      } else {
          printf("Succeed to open file, file descriptor: %d\n", fd);
      }
  
      // TODO ... seems didn't write to file,
      write(fd, "hello\n", 6);
  
      close(fd);
      return 0;
  }
  
  int main(int argc, char *argv[]) {
      direct_io_test();
  
      return 0;
  }
  </code></pre>