ext4: pass in DIO_SKIP_DIO_COUNT to do_blockdev_direct_IO() i_dio_count
authorJens Axboe <axboe@fb.com>
Wed, 15 Apr 2015 21:51:12 +0000 (15:51 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 15 Apr 2015 21:57:26 +0000 (15:57 -0600)
For writes, ext4_ext_direct_IO() already holds the inode i_dio_count
elevated, so we don't need the extra inc/dec that is done in
do_blockdev_direct_IO(). Pass in DIO_SKIP_DIO_COUNT to tell it that.

Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/ext4/inode.c

index 62d4615aa9b07e65c7289b0f0c7392b4e8bc4528..2605355791a3529f481117d12997d6589fadb014 100644 (file)
@@ -2977,8 +2977,10 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
         * conversion. This also disallows race between truncate() and
         * overwrite DIO as i_dio_count needs to be incremented under i_mutex.
         */
-       if (rw == WRITE)
+       if (rw == WRITE) {
                inode_dio_inc(inode);
+               dio_flags |= DIO_SKIP_DIO_COUNT;
+       }
 
        /* If we do a overwrite dio, i_mutex locking can be released */
        overwrite = *((int *)iocb->private);
@@ -3032,7 +3034,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
                get_block_func = ext4_get_block_write_nolock;
        } else {
                get_block_func = ext4_get_block_write;
-               dio_flags = DIO_LOCKING;
+               dio_flags |= DIO_LOCKING;
        }
        if (IS_DAX(inode))
                ret = dax_do_io(rw, iocb, inode, iter, offset, get_block_func,