]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ext4: fake direct I/O mode for data=journal
authorTheodore Ts'o <tytso@mit.edu>
Mon, 22 Aug 2011 18:50:53 +0000 (14:50 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 22 Aug 2011 18:50:53 +0000 (14:50 -0400)
Currently attempts to open a file with O_DIRECT in data=journal mode
causes the open to fail with -EINVAL.  This makes it very hard to test
data=journal mode.  So we will let the open succeed, but then always
fall back to O_DSYNC buffered writes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/inode.c

index c4da98a959ae06deb04e25663ce8b697b0b31458..b77f20b6ea6a16bbfe8415a3552389645bea8c84 100644 (file)
@@ -2857,6 +2857,12 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
        struct inode *inode = file->f_mapping->host;
        ssize_t ret;
 
+       /*
+        * If we are doing data journalling we don't support O_DIRECT
+        */
+       if (ext4_should_journal_data(inode))
+               return 0;
+
        trace_ext4_direct_IO_enter(inode, offset, iov_length(iov, nr_segs), rw);
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
                ret = ext4_ext_direct_IO(rw, iocb, iov, offset, nr_segs);
@@ -2926,6 +2932,7 @@ static const struct address_space_operations ext4_journalled_aops = {
        .bmap                   = ext4_bmap,
        .invalidatepage         = ext4_invalidatepage,
        .releasepage            = ext4_releasepage,
+       .direct_IO              = ext4_direct_IO,
        .is_partially_uptodate  = block_is_partially_uptodate,
        .error_remove_page      = generic_error_remove_page,
 };