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>

+3 -2
+3 -2
fs/ext4/inode.c
··· 3494 3494 * modify the block allocation tree. 3495 3495 */ 3496 3496 down_write(&ei->i_data_sem); 3497 + 3498 + ext4_discard_reservation(inode); 3499 + 3497 3500 /* 3498 3501 * The orphan list entry will now protect us from any crash which 3499 3502 * occurs before the truncate completes, so it is now safe to propagate ··· 3565 3562 case EXT4_TIND_BLOCK: 3566 3563 ; 3567 3564 } 3568 - 3569 - ext4_discard_reservation(inode); 3570 3565 3571 3566 up_write(&ei->i_data_sem); 3572 3567 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);