Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262082
b: refs/heads/master
c: ff9893d
h: refs/heads/master
v: v3
  • Loading branch information
Amir Goldstein authored and Theodore Ts'o committed Jun 27, 2011
1 parent db59262 commit 6dd0d5e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ed7a7e16724a4123fce1fc0ff1f5131a0596f189
refs/heads/master: ff9893dc8aa622a4f122293a6861566a284edea5
2 changes: 2 additions & 0 deletions trunk/fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,8 @@ extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
extern void ext4_da_update_reserve_space(struct inode *inode,
int used, int quota_claim);
extern void ext4_ind_truncate(struct inode *inode);

/* ioctl.c */
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
Expand Down
36 changes: 20 additions & 16 deletions trunk/fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4470,6 +4470,26 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
* ext4_truncate() run will find them and release them.
*/
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);
Expand All @@ -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? */
Expand Down

0 comments on commit 6dd0d5e

Please sign in to comment.