aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-08-13 21:44:34 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-08-13 21:44:34 -0400
commitb4df2030858bde986cb6ff2e4b45945f84649e32 (patch)
tree3f078df884f234383c6708ddc54695700f270417 /fs/ext4
parentbf068ee266f9dbaa6dacb8433a366bb399e7ae5b (diff)
downloadkernel_samsung_aries-b4df2030858bde986cb6ff2e4b45945f84649e32.zip
kernel_samsung_aries-b4df2030858bde986cb6ff2e4b45945f84649e32.tar.gz
kernel_samsung_aries-b4df2030858bde986cb6ff2e4b45945f84649e32.tar.bz2
ext4: Fix potential truncate BUG due to i_prealloc_list being non-empty
We need to call ext4_discard_reservation() earlier in ext4_truncate(), to avoid a BUG() in ext4_mb_return_to_preallocation(), which is called (ultimately) by ext4_free_blocks(). So we must ditch the blocks on i_prealloc_list before we start freeing the data blocks. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/inode.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index a1c7d76..2d54c82 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3494,6 +3494,9 @@ void ext4_truncate(struct inode *inode)
* modify the block allocation tree.
*/
down_write(&ei->i_data_sem);
+
+ ext4_discard_reservation(inode);
+
/*
* The orphan list entry will now protect us from any crash which
* occurs before the truncate completes, so it is now safe to propagate
@@ -3563,8 +3566,6 @@ do_indirects:
;
}
- ext4_discard_reservation(inode);
-
up_write(&ei->i_data_sem);
inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
ext4_mark_inode_dirty(handle, inode);