diff options
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5c5bc5dafff8..2c8caa51addb 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -193,7 +193,7 @@ static int try_to_extend_transaction(handle_t *handle, struct inode *inode) | |||
193 | * so before we call here everything must be consistently dirtied against | 193 | * so before we call here everything must be consistently dirtied against |
194 | * this transaction. | 194 | * this transaction. |
195 | */ | 195 | */ |
196 | int ext4_truncate_restart_trans(handle_t *handle, struct inode *inode, | 196 | int ext4_truncate_restart_trans(handle_t *handle, struct inode *inode, |
197 | int nblocks) | 197 | int nblocks) |
198 | { | 198 | { |
199 | int ret; | 199 | int ret; |
@@ -209,6 +209,7 @@ static int try_to_extend_transaction(handle_t *handle, struct inode *inode) | |||
209 | up_write(&EXT4_I(inode)->i_data_sem); | 209 | up_write(&EXT4_I(inode)->i_data_sem); |
210 | ret = ext4_journal_restart(handle, blocks_for_truncate(inode)); | 210 | ret = ext4_journal_restart(handle, blocks_for_truncate(inode)); |
211 | down_write(&EXT4_I(inode)->i_data_sem); | 211 | down_write(&EXT4_I(inode)->i_data_sem); |
212 | ext4_discard_preallocations(inode); | ||
212 | 213 | ||
213 | return ret; | 214 | return ret; |
214 | } | 215 | } |
@@ -3445,8 +3446,6 @@ out: | |||
3445 | return ret; | 3446 | return ret; |
3446 | } | 3447 | } |
3447 | 3448 | ||
3448 | /* Maximum number of blocks we map for direct IO at once. */ | ||
3449 | |||
3450 | static int ext4_get_block_dio_write(struct inode *inode, sector_t iblock, | 3449 | static int ext4_get_block_dio_write(struct inode *inode, sector_t iblock, |
3451 | struct buffer_head *bh_result, int create) | 3450 | struct buffer_head *bh_result, int create) |
3452 | { | 3451 | { |
@@ -3654,13 +3653,14 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, | |||
3654 | ext4_io_end_t *io_end = iocb->private; | 3653 | ext4_io_end_t *io_end = iocb->private; |
3655 | struct workqueue_struct *wq; | 3654 | struct workqueue_struct *wq; |
3656 | 3655 | ||
3656 | /* if not async direct IO or dio with 0 bytes write, just return */ | ||
3657 | if (!io_end || !size) | ||
3658 | return; | ||
3659 | |||
3657 | ext_debug("ext4_end_io_dio(): io_end 0x%p" | 3660 | ext_debug("ext4_end_io_dio(): io_end 0x%p" |
3658 | "for inode %lu, iocb 0x%p, offset %llu, size %llu\n", | 3661 | "for inode %lu, iocb 0x%p, offset %llu, size %llu\n", |
3659 | iocb->private, io_end->inode->i_ino, iocb, offset, | 3662 | iocb->private, io_end->inode->i_ino, iocb, offset, |
3660 | size); | 3663 | size); |
3661 | /* if not async direct IO or dio with 0 bytes write, just return */ | ||
3662 | if (!io_end || !size) | ||
3663 | return; | ||
3664 | 3664 | ||
3665 | /* if not aio dio with unwritten extents, just free io and return */ | 3665 | /* if not aio dio with unwritten extents, just free io and return */ |
3666 | if (io_end->flag != DIO_AIO_UNWRITTEN){ | 3666 | if (io_end->flag != DIO_AIO_UNWRITTEN){ |
@@ -3771,13 +3771,19 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, | |||
3771 | if (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) { | 3771 | if (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) { |
3772 | ext4_free_io_end(iocb->private); | 3772 | ext4_free_io_end(iocb->private); |
3773 | iocb->private = NULL; | 3773 | iocb->private = NULL; |
3774 | } else if (ret > 0) | 3774 | } else if (ret > 0 && (EXT4_I(inode)->i_state & |
3775 | EXT4_STATE_DIO_UNWRITTEN)) { | ||
3776 | int err; | ||
3775 | /* | 3777 | /* |
3776 | * for non AIO case, since the IO is already | 3778 | * for non AIO case, since the IO is already |
3777 | * completed, we could do the convertion right here | 3779 | * completed, we could do the convertion right here |
3778 | */ | 3780 | */ |
3779 | ret = ext4_convert_unwritten_extents(inode, | 3781 | err = ext4_convert_unwritten_extents(inode, |
3780 | offset, ret); | 3782 | offset, ret); |
3783 | if (err < 0) | ||
3784 | ret = err; | ||
3785 | EXT4_I(inode)->i_state &= ~EXT4_STATE_DIO_UNWRITTEN; | ||
3786 | } | ||
3781 | return ret; | 3787 | return ret; |
3782 | } | 3788 | } |
3783 | 3789 | ||