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
This commit is contained in:
parent
4631dbf677
commit
69dc953640
1 changed files with 9 additions and 2 deletions
|
@ -4731,6 +4731,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
|
||||||
loff_t new_size = 0;
|
loff_t new_size = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int flags;
|
int flags;
|
||||||
|
int credits;
|
||||||
int partial;
|
int partial;
|
||||||
loff_t start, end;
|
loff_t start, end;
|
||||||
ext4_lblk_t lblk;
|
ext4_lblk_t lblk;
|
||||||
|
@ -4830,8 +4831,14 @@ static long ext4_zero_range(struct file *file, loff_t offset,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_dio;
|
goto out_dio;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
handle = ext4_journal_start(inode, EXT4_HT_MISC, 4);
|
* In worst case we have to writeout two nonadjacent unwritten
|
||||||
|
* blocks and update the inode
|
||||||
|
*/
|
||||||
|
credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1;
|
||||||
|
if (ext4_should_journal_data(inode))
|
||||||
|
credits += 2;
|
||||||
|
handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
|
||||||
if (IS_ERR(handle)) {
|
if (IS_ERR(handle)) {
|
||||||
ret = PTR_ERR(handle);
|
ret = PTR_ERR(handle);
|
||||||
ext4_std_error(inode->i_sb, ret);
|
ext4_std_error(inode->i_sb, ret);
|
||||||
|
|
Loading…
Add table
Reference in a new issue