aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r--fs/ext4/extents.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 6b90b6825d32..686240e89df1 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3174,9 +3174,10 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
3174 * that this IO needs to convertion to written when IO is 3174 * that this IO needs to convertion to written when IO is
3175 * completed 3175 * completed
3176 */ 3176 */
3177 if (io) 3177 if (io && !(io->flag & EXT4_IO_END_UNWRITTEN)) {
3178 io->flag = EXT4_IO_END_UNWRITTEN; 3178 io->flag = EXT4_IO_END_UNWRITTEN;
3179 else 3179 atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
3180 } else
3180 ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); 3181 ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);
3181 if (ext4_should_dioread_nolock(inode)) 3182 if (ext4_should_dioread_nolock(inode))
3182 map->m_flags |= EXT4_MAP_UNINIT; 3183 map->m_flags |= EXT4_MAP_UNINIT;
@@ -3463,9 +3464,10 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
3463 * that we need to perform convertion when IO is done. 3464 * that we need to perform convertion when IO is done.
3464 */ 3465 */
3465 if ((flags & EXT4_GET_BLOCKS_PRE_IO)) { 3466 if ((flags & EXT4_GET_BLOCKS_PRE_IO)) {
3466 if (io) 3467 if (io && !(io->flag & EXT4_IO_END_UNWRITTEN)) {
3467 io->flag = EXT4_IO_END_UNWRITTEN; 3468 io->flag = EXT4_IO_END_UNWRITTEN;
3468 else 3469 atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
3470 } else
3469 ext4_set_inode_state(inode, 3471 ext4_set_inode_state(inode,
3470 EXT4_STATE_DIO_UNWRITTEN); 3472 EXT4_STATE_DIO_UNWRITTEN);
3471 } 3473 }
@@ -3627,14 +3629,15 @@ static void ext4_falloc_update_inode(struct inode *inode,
3627} 3629}
3628 3630
3629/* 3631/*
3630 * preallocate space for a file. This implements ext4's fallocate inode 3632 * preallocate space for a file. This implements ext4's fallocate file
3631 * operation, which gets called from sys_fallocate system call. 3633 * operation, which gets called from sys_fallocate system call.
3632 * For block-mapped files, posix_fallocate should fall back to the method 3634 * For block-mapped files, posix_fallocate should fall back to the method
3633 * of writing zeroes to the required new blocks (the same behavior which is 3635 * of writing zeroes to the required new blocks (the same behavior which is
3634 * expected for file systems which do not support fallocate() system call). 3636 * expected for file systems which do not support fallocate() system call).
3635 */ 3637 */
3636long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len) 3638long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
3637{ 3639{
3640 struct inode *inode = file->f_path.dentry->d_inode;
3638 handle_t *handle; 3641 handle_t *handle;
3639 loff_t new_size; 3642 loff_t new_size;
3640 unsigned int max_blocks; 3643 unsigned int max_blocks;
@@ -3645,7 +3648,7 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
3645 unsigned int credits, blkbits = inode->i_blkbits; 3648 unsigned int credits, blkbits = inode->i_blkbits;
3646 3649
3647 /* We only support the FALLOC_FL_KEEP_SIZE mode */ 3650 /* We only support the FALLOC_FL_KEEP_SIZE mode */
3648 if (mode && (mode != FALLOC_FL_KEEP_SIZE)) 3651 if (mode & ~FALLOC_FL_KEEP_SIZE)
3649 return -EOPNOTSUPP; 3652 return -EOPNOTSUPP;
3650 3653
3651 /* 3654 /*
@@ -3655,10 +3658,6 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
3655 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) 3658 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
3656 return -EOPNOTSUPP; 3659 return -EOPNOTSUPP;
3657 3660
3658 /* preallocation to directories is currently not supported */
3659 if (S_ISDIR(inode->i_mode))
3660 return -ENODEV;
3661
3662 map.m_lblk = offset >> blkbits; 3661 map.m_lblk = offset >> blkbits;
3663 /* 3662 /*
3664 * We can't just convert len to max_blocks because 3663 * We can't just convert len to max_blocks because