diff options
author | Yongqiang Yang <xiaoqiangnk@gmail.com> | 2011-04-04 15:40:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-14 16:53:46 -0700 |
commit | f101d38dd375dc0ade6b9c3fe4bf19812d9e14cc (patch) | |
tree | 08e428809e904f53ee6a3b85d46b3ef2bd9bb6c0 | |
parent | 975c07cc89c47f28bb83f2c7cc32a273c75add8a (diff) | |
download | linux-stable-f101d38dd375dc0ade6b9c3fe4bf19812d9e14cc.tar.gz linux-stable-f101d38dd375dc0ade6b9c3fe4bf19812d9e14cc.tar.bz2 linux-stable-f101d38dd375dc0ade6b9c3fe4bf19812d9e14cc.zip |
ext4: fix credits computing for indirect mapped files
commit 5b41395fcc0265fc9f193aef9df39ce49d64677c upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-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 1b23f9d2ef56..8572c791fd52 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5458,13 +5458,12 @@ static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks, /* if nrblocks are contiguous */ if (chunk) { /* - * With N contiguous data blocks, it need at most - * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) indirect blocks - * 2 dindirect blocks - * 1 tindirect block + * With N contiguous data blocks, we need at most + * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks, + * 2 dindirect blocks, and 1 tindirect block */ - indirects = nrblocks / EXT4_ADDR_PER_BLOCK(inode->i_sb); - return indirects + 3; + return DIV_ROUND_UP(nrblocks, + EXT4_ADDR_PER_BLOCK(inode->i_sb)) + 4; } /* * if nrblocks are not contiguous, worse case, each block touch |