summaryrefslogtreecommitdiff
path: root/fs/ext4/inode.c
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/inode.c
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/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)
*/
void ext4_truncate(struct inode *inode)
{
+ trace_ext4_truncate_enter(inode);
+
+ if (!ext4_can_truncate(inode))
+ return;
+
+ ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
+
+ if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
+ ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
+
+ if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+ ext4_ext_truncate(inode);
+ else
+ ext4_ind_truncate(inode);
+
+ trace_ext4_truncate_exit(inode);
+}
+
+void ext4_ind_truncate(struct inode *inode)
+{
handle_t *handle;
struct ext4_inode_info *ei = EXT4_I(inode);
__le32 *i_data = ei->i_data;
@@ -4484,22 +4504,6 @@ void ext4_truncate(struct inode *inode)
ext4_lblk_t last_block, max_block;
unsigned blocksize = inode->i_sb->s_blocksize;
- trace_ext4_truncate_enter(inode);
-
- if (!ext4_can_truncate(inode))
- return;
-
- ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
-
- if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
- ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
-
- if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
- ext4_ext_truncate(inode);
- trace_ext4_truncate_exit(inode);
- return;
- }
-
handle = start_transaction(inode);
if (IS_ERR(handle))
return; /* AKPM: return what? */