diff options
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0afc8c1d8cf3..d6a7701018a6 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -3545,15 +3545,24 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, | |||
3545 | 3545 | ||
3546 | retry: | 3546 | retry: |
3547 | if (rw == READ && ext4_should_dioread_nolock(inode)) | 3547 | if (rw == READ && ext4_should_dioread_nolock(inode)) |
3548 | ret = blockdev_direct_IO_no_locking(rw, iocb, inode, | 3548 | ret = __blockdev_direct_IO(rw, iocb, inode, |
3549 | inode->i_sb->s_bdev, iov, | 3549 | inode->i_sb->s_bdev, iov, |
3550 | offset, nr_segs, | 3550 | offset, nr_segs, |
3551 | ext4_get_block, NULL); | 3551 | ext4_get_block, NULL, NULL, 0); |
3552 | else | 3552 | else { |
3553 | ret = blockdev_direct_IO(rw, iocb, inode, | 3553 | ret = blockdev_direct_IO(rw, iocb, inode, |
3554 | inode->i_sb->s_bdev, iov, | 3554 | inode->i_sb->s_bdev, iov, |
3555 | offset, nr_segs, | 3555 | offset, nr_segs, |
3556 | ext4_get_block, NULL); | 3556 | ext4_get_block, NULL); |
3557 | |||
3558 | if (unlikely((rw & WRITE) && ret < 0)) { | ||
3559 | loff_t isize = i_size_read(inode); | ||
3560 | loff_t end = offset + iov_length(iov, nr_segs); | ||
3561 | |||
3562 | if (end > isize) | ||
3563 | vmtruncate(inode, isize); | ||
3564 | } | ||
3565 | } | ||
3557 | if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) | 3566 | if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) |
3558 | goto retry; | 3567 | goto retry; |
3559 | 3568 | ||