aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorYongqiang Yang <xiaoqiangnk@gmail.com>2011-12-28 12:02:13 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-12-28 12:02:13 -0500
commit2aff57b0c052344e8401a8b4a33c2a1ecb0f627c (patch)
tree48713b187d571baab9951dace5b8ace86289a654 /fs/ext4/inode.c
parent22cdfca5641817060dd724a9c30442f5c0675fcd (diff)
ext4: allocate delalloc blocks before changing journal mode
delalloc blocks should be allocated before changing journal mode, otherwise they can not be allocated and even more truncate on delalloc blocks could triggre BUG by flushing delalloc buffers. Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 92655fd89657..cb0ba9d77a8e 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4647,6 +4647,17 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
4647 return 0; 4647 return 0;
4648 if (is_journal_aborted(journal)) 4648 if (is_journal_aborted(journal))
4649 return -EROFS; 4649 return -EROFS;
4650 /* We have to allocate physical blocks for delalloc blocks
4651 * before flushing journal. otherwise delalloc blocks can not
4652 * be allocated any more. even more truncate on delalloc blocks
4653 * could trigger BUG by flushing delalloc blocks in journal.
4654 * There is no delalloc block in non-journal data mode.
4655 */
4656 if (val && test_opt(inode->i_sb, DELALLOC)) {
4657 err = ext4_alloc_da_blocks(inode);
4658 if (err < 0)
4659 return err;
4660 }
4650 4661
4651 jbd2_journal_lock_updates(journal); 4662 jbd2_journal_lock_updates(journal);
4652 jbd2_journal_flush(journal); 4663 jbd2_journal_flush(journal);