ext4: use old legacy direct I/O interface for 3.18 backport
Theodore Ts'o [Thu, 22 Jan 2015 20:40:07 +0000 (15:40 -0500)]
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

fs/ext4/ext4.h
fs/ext4/indirect.c
fs/ext4/inode.c

index a2f4422..05abaf0 100644 (file)
@@ -2143,7 +2143,8 @@ extern void ext4_da_update_reserve_space(struct inode *inode,
 extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
                                struct ext4_map_blocks *map, int flags);
 extern ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
-                               struct iov_iter *iter, loff_t offset);
+                                 const struct iovec *iov, loff_t offset,
+                                 unsigned long nr_segs);
 extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock);
 extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks);
 extern void ext4_ind_truncate(handle_t *, struct inode *inode);
index 1136888..88d1ae3 100644 (file)
@@ -643,7 +643,8 @@ out:
  * VFS code falls back into buffered path in that case so we are safe.
  */
 ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
-                          struct iov_iter *iter, loff_t offset)
+                          const struct iovec *iov, loff_t offset,
+                          unsigned long nr_segs)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
@@ -651,7 +652,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
        handle_t *handle;
        ssize_t ret;
        int orphan = 0;
-       size_t count = iov_iter_count(iter);
+       size_t count = iov_length(iov, nr_segs);
        int retries = 0;
 
        if (rw == WRITE) {
@@ -690,13 +691,14 @@ retry:
                        goto locked;
                }
                ret = __blockdev_direct_IO(rw, iocb, inode,
-                                inode->i_sb->s_bdev, iter, offset,
+                                inode->i_sb->s_bdev, iov,
+                                          offset, nr_segs,
                                 ext4_get_block, NULL, NULL, 0);
                inode_dio_done(inode);
        } else {
 locked:
-               ret = blockdev_direct_IO(rw, iocb, inode, iter,
-                                offset, ext4_get_block);
+               ret = blockdev_direct_IO(rw, iocb, inode, iov,
+                                offset, nr_segs, ext4_get_block);
 
                if (unlikely((rw & WRITE) && ret < 0)) {
                        loff_t isize = i_size_read(inode);
index 8c43a61..28f98f2 100644 (file)
@@ -2977,12 +2977,13 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
  *
  */
 static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
-                             struct iov_iter *iter, loff_t offset)
+                             const struct iovec *iov, loff_t offset,
+                             unsigned long nr_segs)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
        ssize_t ret;
-       size_t count = iov_iter_count(iter);
+       size_t count = iov_length(iov, nr_segs);
        int overwrite = 0;
        get_block_t *get_block_func = NULL;
        int dio_flags = 0;
@@ -2991,7 +2992,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
 
        /* Use the old path for reads and writes beyond i_size. */
        if (rw != WRITE || final_size > inode->i_size)
-               return ext4_ind_direct_IO(rw, iocb, iter, offset);
+               return ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);
 
        BUG_ON(iocb->private == NULL);
 
@@ -3058,8 +3059,8 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
                dio_flags = DIO_LOCKING;
        }
        ret = __blockdev_direct_IO(rw, iocb, inode,
-                                  inode->i_sb->s_bdev, iter,
-                                  offset,
+                                  inode->i_sb->s_bdev, iov,
+                                  offset, nr_segs,
                                   get_block_func,
                                   ext4_end_io_dio,
                                   NULL,
@@ -3113,11 +3114,12 @@ retake_lock:
 }
 
 static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
-                             struct iov_iter *iter, loff_t offset)
+                             const struct iovec *iov, loff_t offset,
+                             unsigned long nr_segs)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
-       size_t count = iov_iter_count(iter);
+       size_t count = iov_length(iov, nr_segs);
        ssize_t ret;
 
        /*
@@ -3132,9 +3134,9 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
 
        trace_ext4_direct_IO_enter(inode, offset, count, rw);
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-               ret = ext4_ext_direct_IO(rw, iocb, iter, offset);
+               ret = ext4_ext_direct_IO(rw, iocb, iov, offset, nr_segs);
        else
-               ret = ext4_ind_direct_IO(rw, iocb, iter, offset);
+               ret = ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);
        trace_ext4_direct_IO_exit(inode, offset, count, rw, ret);
        return ret;
 }