aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/ext4.h3
-rw-r--r--fs/ext4/indirect.c15
-rw-r--r--fs/ext4/inode.c15
3 files changed, 15 insertions, 18 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 66946aa62127..9334f55dab6f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2150,8 +2150,7 @@ extern void ext4_da_update_reserve_space(struct inode *inode,
2150extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, 2150extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
2151 struct ext4_map_blocks *map, int flags); 2151 struct ext4_map_blocks *map, int flags);
2152extern ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, 2152extern ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
2153 const struct iovec *iov, loff_t offset, 2153 struct iov_iter *iter, loff_t offset);
2154 unsigned long nr_segs);
2155extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock); 2154extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock);
2156extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks); 2155extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks);
2157extern void ext4_ind_truncate(handle_t *, struct inode *inode); 2156extern void ext4_ind_truncate(handle_t *, struct inode *inode);
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 594009f5f523..eb5ae16902d0 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -639,8 +639,7 @@ out:
639 * VFS code falls back into buffered path in that case so we are safe. 639 * VFS code falls back into buffered path in that case so we are safe.
640 */ 640 */
641ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, 641ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
642 const struct iovec *iov, loff_t offset, 642 struct iov_iter *iter, loff_t offset)
643 unsigned long nr_segs)
644{ 643{
645 struct file *file = iocb->ki_filp; 644 struct file *file = iocb->ki_filp;
646 struct inode *inode = file->f_mapping->host; 645 struct inode *inode = file->f_mapping->host;
@@ -648,7 +647,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
648 handle_t *handle; 647 handle_t *handle;
649 ssize_t ret; 648 ssize_t ret;
650 int orphan = 0; 649 int orphan = 0;
651 size_t count = iov_length(iov, nr_segs); 650 size_t count = iov_length(iter->iov, iter->nr_segs);
652 int retries = 0; 651 int retries = 0;
653 652
654 if (rw == WRITE) { 653 if (rw == WRITE) {
@@ -687,18 +686,18 @@ retry:
687 goto locked; 686 goto locked;
688 } 687 }
689 ret = __blockdev_direct_IO(rw, iocb, inode, 688 ret = __blockdev_direct_IO(rw, iocb, inode,
690 inode->i_sb->s_bdev, iov, 689 inode->i_sb->s_bdev, iter->iov,
691 offset, nr_segs, 690 offset, iter->nr_segs,
692 ext4_get_block, NULL, NULL, 0); 691 ext4_get_block, NULL, NULL, 0);
693 inode_dio_done(inode); 692 inode_dio_done(inode);
694 } else { 693 } else {
695locked: 694locked:
696 ret = blockdev_direct_IO(rw, iocb, inode, iov, 695 ret = blockdev_direct_IO(rw, iocb, inode, iter->iov,
697 offset, nr_segs, ext4_get_block); 696 offset, iter->nr_segs, ext4_get_block);
698 697
699 if (unlikely((rw & WRITE) && ret < 0)) { 698 if (unlikely((rw & WRITE) && ret < 0)) {
700 loff_t isize = i_size_read(inode); 699 loff_t isize = i_size_read(inode);
701 loff_t end = offset + iov_length(iov, nr_segs); 700 loff_t end = offset + count;
702 701
703 if (end > isize) 702 if (end > isize)
704 ext4_truncate_failed_write(inode); 703 ext4_truncate_failed_write(inode);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f51db730da39..29996c1b673e 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3085,13 +3085,12 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
3085 * 3085 *
3086 */ 3086 */
3087static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, 3087static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3088 const struct iovec *iov, loff_t offset, 3088 struct iov_iter *iter, loff_t offset)
3089 unsigned long nr_segs)
3090{ 3089{
3091 struct file *file = iocb->ki_filp; 3090 struct file *file = iocb->ki_filp;
3092 struct inode *inode = file->f_mapping->host; 3091 struct inode *inode = file->f_mapping->host;
3093 ssize_t ret; 3092 ssize_t ret;
3094 size_t count = iov_length(iov, nr_segs); 3093 size_t count = iov_length(iter->iov, iter->nr_segs);
3095 int overwrite = 0; 3094 int overwrite = 0;
3096 get_block_t *get_block_func = NULL; 3095 get_block_t *get_block_func = NULL;
3097 int dio_flags = 0; 3096 int dio_flags = 0;
@@ -3100,7 +3099,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3100 3099
3101 /* Use the old path for reads and writes beyond i_size. */ 3100 /* Use the old path for reads and writes beyond i_size. */
3102 if (rw != WRITE || final_size > inode->i_size) 3101 if (rw != WRITE || final_size > inode->i_size)
3103 return ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs); 3102 return ext4_ind_direct_IO(rw, iocb, iter, offset);
3104 3103
3105 BUG_ON(iocb->private == NULL); 3104 BUG_ON(iocb->private == NULL);
3106 3105
@@ -3167,8 +3166,8 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3167 dio_flags = DIO_LOCKING; 3166 dio_flags = DIO_LOCKING;
3168 } 3167 }
3169 ret = __blockdev_direct_IO(rw, iocb, inode, 3168 ret = __blockdev_direct_IO(rw, iocb, inode,
3170 inode->i_sb->s_bdev, iov, 3169 inode->i_sb->s_bdev, iter->iov,
3171 offset, nr_segs, 3170 offset, iter->nr_segs,
3172 get_block_func, 3171 get_block_func,
3173 ext4_end_io_dio, 3172 ext4_end_io_dio,
3174 NULL, 3173 NULL,
@@ -3240,9 +3239,9 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
3240 3239
3241 trace_ext4_direct_IO_enter(inode, offset, iov_length(iter->iov, iter->nr_segs), rw); 3240 trace_ext4_direct_IO_enter(inode, offset, iov_length(iter->iov, iter->nr_segs), rw);
3242 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) 3241 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
3243 ret = ext4_ext_direct_IO(rw, iocb, iter->iov, offset, iter->nr_segs); 3242 ret = ext4_ext_direct_IO(rw, iocb, iter, offset);
3244 else 3243 else
3245 ret = ext4_ind_direct_IO(rw, iocb, iter->iov, offset, iter->nr_segs); 3244 ret = ext4_ind_direct_IO(rw, iocb, iter, offset);
3246 trace_ext4_direct_IO_exit(inode, offset, 3245 trace_ext4_direct_IO_exit(inode, offset,
3247 iov_length(iter->iov, iter->nr_segs), rw, ret); 3246 iov_length(iter->iov, iter->nr_segs), rw, ret);
3248 return ret; 3247 return ret;