diff options
author | Yongqiang Yang <xiaoqiangnk@gmail.com> | 2011-04-04 15:40:24 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-04-04 15:40:24 -0400 |
commit | 5b41395fcc0265fc9f193aef9df39ce49d64677c (patch) | |
tree | 3e9ce0bc590399f78808fce8279d04c61301beb8 /fs | |
parent | 21f976975cbecbdaf23ceeacc1cab2b1c05a028e (diff) |
ext4: fix credits computing for indirect mapped files
When writing a contiguous set of blocks, two indirect blocks could be
needed depending on how the blocks are aligned, so we need to increase
the number of credits needed by one.
[ Also fixed a another bug which could further underestimate the
number of journal credits needed by 1; the code was using integer
division instead of DIV_ROUND_UP() -- tytso]
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/inode.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 1a86282b9024..7d11e02ad01d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -5398,13 +5398,12 @@ static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks, | |||
5398 | /* if nrblocks are contiguous */ | 5398 | /* if nrblocks are contiguous */ |
5399 | if (chunk) { | 5399 | if (chunk) { |
5400 | /* | 5400 | /* |
5401 | * With N contiguous data blocks, it need at most | 5401 | * With N contiguous data blocks, we need at most |
5402 | * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) indirect blocks | 5402 | * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks, |
5403 | * 2 dindirect blocks | 5403 | * 2 dindirect blocks, and 1 tindirect block |
5404 | * 1 tindirect block | ||
5405 | */ | 5404 | */ |
5406 | indirects = nrblocks / EXT4_ADDR_PER_BLOCK(inode->i_sb); | 5405 | return DIV_ROUND_UP(nrblocks, |
5407 | return indirects + 3; | 5406 | EXT4_ADDR_PER_BLOCK(inode->i_sb)) + 4; |
5408 | } | 5407 | } |
5409 | /* | 5408 | /* |
5410 | * if nrblocks are not contiguous, worse case, each block touch | 5409 | * if nrblocks are not contiguous, worse case, each block touch |