aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e3126c051006..a8f310b77f56 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4471,6 +4471,26 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
4471 */ 4471 */
4472void ext4_truncate(struct inode *inode) 4472void ext4_truncate(struct inode *inode)
4473{ 4473{
4474 trace_ext4_truncate_enter(inode);
4475
4476 if (!ext4_can_truncate(inode))
4477 return;
4478
4479 ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4480
4481 if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
4482 ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
4483
4484 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
4485 ext4_ext_truncate(inode);
4486 else
4487 ext4_ind_truncate(inode);
4488
4489 trace_ext4_truncate_exit(inode);
4490}
4491
4492void ext4_ind_truncate(struct inode *inode)
4493{
4474 handle_t *handle; 4494 handle_t *handle;
4475 struct ext4_inode_info *ei = EXT4_I(inode); 4495 struct ext4_inode_info *ei = EXT4_I(inode);
4476 __le32 *i_data = ei->i_data; 4496 __le32 *i_data = ei->i_data;
@@ -4484,22 +4504,6 @@ void ext4_truncate(struct inode *inode)
4484 ext4_lblk_t last_block, max_block; 4504 ext4_lblk_t last_block, max_block;
4485 unsigned blocksize = inode->i_sb->s_blocksize; 4505 unsigned blocksize = inode->i_sb->s_blocksize;
4486 4506
4487 trace_ext4_truncate_enter(inode);
4488
4489 if (!ext4_can_truncate(inode))
4490 return;
4491
4492 ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4493
4494 if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
4495 ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
4496
4497 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
4498 ext4_ext_truncate(inode);
4499 trace_ext4_truncate_exit(inode);
4500 return;
4501 }
4502
4503 handle = start_transaction(inode); 4507 handle = start_transaction(inode);
4504 if (IS_ERR(handle)) 4508 if (IS_ERR(handle))
4505 return; /* AKPM: return what? */ 4509 return; /* AKPM: return what? */