ext4: switch the guts of ->direct_IO() to iov_iter
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 5 Mar 2014 03:14:00 +0000 (22:14 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 6 May 2014 21:32:45 +0000 (17:32 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ext4/ext4.h
fs/ext4/indirect.c
fs/ext4/inode.c

index 66946aa621270716c580a2617bceecbcadb6bda7..9334f55dab6f8ab6590768d0a91a1bad871888c5 100644 (file)
@@ -2150,8 +2150,7 @@ 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,
-                               const struct iovec *iov, loff_t offset,
-                               unsigned long nr_segs);
+                               struct iov_iter *iter, loff_t offset);
 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 594009f5f523f0fd2228a72f1aa593a6f3ebf66f..eb5ae16902d0b9c77bd062253c341b11c7b9ccb8 100644 (file)
@@ -639,8 +639,7 @@ 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,
-                          const struct iovec *iov, loff_t offset,
-                          unsigned long nr_segs)
+                          struct iov_iter *iter, loff_t offset)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
@@ -648,7 +647,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_length(iov, nr_segs);
+       size_t count = iov_length(iter->iov, iter->nr_segs);
        int retries = 0;
 
        if (rw == WRITE) {
@@ -687,18 +686,18 @@ retry:
                        goto locked;
                }
                ret = __blockdev_direct_IO(rw, iocb, inode,
-                                inode->i_sb->s_bdev, iov,
-                                offset, nr_segs,
+                                inode->i_sb->s_bdev, iter->iov,
+                                offset, iter->nr_segs,
                                 ext4_get_block, NULL, NULL, 0);
                inode_dio_done(inode);
        } else {
 locked:
-               ret = blockdev_direct_IO(rw, iocb, inode, iov,
-                                offset, nr_segs, ext4_get_block);
+               ret = blockdev_direct_IO(rw, iocb, inode, iter->iov,
+                                offset, iter->nr_segs, ext4_get_block);
 
                if (unlikely((rw & WRITE) && ret < 0)) {
                        loff_t isize = i_size_read(inode);
-                       loff_t end = offset + iov_length(iov, nr_segs);
+                       loff_t end = offset + count;
 
                        if (end > isize)
                                ext4_truncate_failed_write(inode);
index f51db730da3900bbec98102cecfaf4184252b04f..29996c1b673ebd90d7e6e75f91d0e9964ef1c105 100644 (file)
@@ -3085,13 +3085,12 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
  *
  */
 static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
-                             const struct iovec *iov, loff_t offset,
-                             unsigned long nr_segs)
+                             struct iov_iter *iter, loff_t offset)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
        ssize_t ret;
-       size_t count = iov_length(iov, nr_segs);
+       size_t count = iov_length(iter->iov, iter->nr_segs);
        int overwrite = 0;
        get_block_t *get_block_func = NULL;
        int dio_flags = 0;
@@ -3100,7 +3099,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, iov, offset, nr_segs);
+               return ext4_ind_direct_IO(rw, iocb, iter, offset);
 
        BUG_ON(iocb->private == NULL);
 
@@ -3167,8 +3166,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, iov,
-                                  offset, nr_segs,
+                                  inode->i_sb->s_bdev, iter->iov,
+                                  offset, iter->nr_segs,
                                   get_block_func,
                                   ext4_end_io_dio,
                                   NULL,
@@ -3240,9 +3239,9 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
 
        trace_ext4_direct_IO_enter(inode, offset, iov_length(iter->iov, iter->nr_segs), rw);
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-               ret = ext4_ext_direct_IO(rw, iocb, iter->iov, offset, iter->nr_segs);
+               ret = ext4_ext_direct_IO(rw, iocb, iter, offset);
        else
-               ret = ext4_ind_direct_IO(rw, iocb, iter->iov, offset, iter->nr_segs);
+               ret = ext4_ind_direct_IO(rw, iocb, iter, offset);
        trace_ext4_direct_IO_exit(inode, offset,
                                iov_length(iter->iov, iter->nr_segs), rw, ret);
        return ret;