aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
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/inode.c
parentbf068ee266f9dbaa6dacb8433a366bb399e7ae5b (diff)
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/inode.c')
-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 a1c7d762321..2d54c822c4c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3494,6 +3494,9 @@ void ext4_truncate(struct inode *inode)
3494 * modify the block allocation tree. 3494 * modify the block allocation tree.
3495 */ 3495 */
3496 down_write(&ei->i_data_sem); 3496 down_write(&ei->i_data_sem);
3497
3498 ext4_discard_reservation(inode);
3499
3497 /* 3500 /*
3498 * The orphan list entry will now protect us from any crash which 3501 * The orphan list entry will now protect us from any crash which
3499 * occurs before the truncate completes, so it is now safe to propagate 3502 * occurs before the truncate completes, so it is now safe to propagate
@@ -3563,8 +3566,6 @@ do_indirects:
3563 ; 3566 ;
3564 } 3567 }
3565 3568
3566 ext4_discard_reservation(inode);
3567
3568 up_write(&ei->i_data_sem); 3569 up_write(&ei->i_data_sem);
3569 inode->i_mtime = inode->i_ctime = ext4_current_time(inode); 3570 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
3570 ext4_mark_inode_dirty(handle, inode); 3571 ext4_mark_inode_dirty(handle, inode);