aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@users.sf.net>2011-06-27 16:36:31 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-06-27 16:36:31 -0400
commitff9893dc8aa622a4f122293a6861566a284edea5 (patch)
treeca7d798360c32379fb4d3d0913d349ac79f55c6d /fs/ext4
parented7a7e16724a4123fce1fc0ff1f5131a0596f189 (diff)
ext4: split ext4_ind_truncate from ext4_truncate
We are about to move all indirect inode functions to a new file. Before we do that, let's split ext4_ind_truncate() out of ext4_truncate() leaving only generic code in the latter, so we will be able to move ext4_ind_truncate() to the new file. Signed-off-by: Amir Goldstein <amir73il@users.sf.net> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/ext4.h2
-rw-r--r--fs/ext4/inode.c36
2 files changed, 22 insertions, 16 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 1921392cd708..8532dd43d320 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1834,6 +1834,8 @@ extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
1834extern qsize_t *ext4_get_reserved_space(struct inode *inode); 1834extern qsize_t *ext4_get_reserved_space(struct inode *inode);
1835extern void ext4_da_update_reserve_space(struct inode *inode, 1835extern void ext4_da_update_reserve_space(struct inode *inode,
1836 int used, int quota_claim); 1836 int used, int quota_claim);
1837extern void ext4_ind_truncate(struct inode *inode);
1838
1837/* ioctl.c */ 1839/* ioctl.c */
1838extern long ext4_ioctl(struct file *, unsigned int, unsigned long); 1840extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
1839extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); 1841extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
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? */