diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2014-08-27 18:33:49 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-08-27 18:33:49 -0400 |
commit | 69dc9536405213c1d545fcace1fc15c481d00aae (patch) | |
tree | 97abd78ee9ec00fb80947ef0cb2955b0d28df8d8 /fs | |
parent | 4631dbf677ded0419fee35ca7408285dabfaef1a (diff) |
ext4: fix incorect journal credits reservation in ext4_zero_range
Currently we reserve only 4 blocks but in worst case scenario
ext4_zero_partial_blocks() may want to zeroout and convert two
non adjacent blocks.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/extents.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f0e6934291dd..0e9de2328bd2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -4731,6 +4731,7 @@ static long ext4_zero_range(struct file *file, loff_t offset, | |||
4731 | loff_t new_size = 0; | 4731 | loff_t new_size = 0; |
4732 | int ret = 0; | 4732 | int ret = 0; |
4733 | int flags; | 4733 | int flags; |
4734 | int credits; | ||
4734 | int partial; | 4735 | int partial; |
4735 | loff_t start, end; | 4736 | loff_t start, end; |
4736 | ext4_lblk_t lblk; | 4737 | ext4_lblk_t lblk; |
@@ -4830,8 +4831,14 @@ static long ext4_zero_range(struct file *file, loff_t offset, | |||
4830 | if (ret) | 4831 | if (ret) |
4831 | goto out_dio; | 4832 | goto out_dio; |
4832 | } | 4833 | } |
4833 | 4834 | /* | |
4834 | handle = ext4_journal_start(inode, EXT4_HT_MISC, 4); | 4835 | * In worst case we have to writeout two nonadjacent unwritten |
4836 | * blocks and update the inode | ||
4837 | */ | ||
4838 | credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1; | ||
4839 | if (ext4_should_journal_data(inode)) | ||
4840 | credits += 2; | ||
4841 | handle = ext4_journal_start(inode, EXT4_HT_MISC, credits); | ||
4835 | if (IS_ERR(handle)) { | 4842 | if (IS_ERR(handle)) { |
4836 | ret = PTR_ERR(handle); | 4843 | ret = PTR_ERR(handle); |
4837 | ext4_std_error(inode->i_sb, ret); | 4844 | ext4_std_error(inode->i_sb, ret); |