* [PATCH] ext4:Fix credits computing for indirect mapped files.
@ 2011-03-25 13:10 Yongqiang Yang
2011-04-04 19:39 ` Ted Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Yongqiang Yang @ 2011-03-25 13:10 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4, Yongqiang Yang
Either the first block or the last one could be not aligned with
block boundary, 1 block is needed to fix it.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
fs/ext4/inode.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 67e7a3c..7193f23 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5380,11 +5380,11 @@ static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks,
if (chunk) {
/*
* With N contiguous data blocks, it need at most
- * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) indirect blocks
+ * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks
* 2 dindirect blocks
* 1 tindirect block
*/
- indirects = nrblocks / EXT4_ADDR_PER_BLOCK(inode->i_sb);
+ indirects = nrblocks / EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1;
return indirects + 3;
}
/*
--
1.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4:Fix credits computing for indirect mapped files.
2011-03-25 13:10 [PATCH] ext4:Fix credits computing for indirect mapped files Yongqiang Yang
@ 2011-04-04 19:39 ` Ted Ts'o
2011-04-05 5:02 ` Yongqiang Yang
0 siblings, 1 reply; 3+ messages in thread
From: Ted Ts'o @ 2011-04-04 19:39 UTC (permalink / raw)
To: Yongqiang Yang; +Cc: linux-ext4
On Fri, Mar 25, 2011 at 09:10:05PM +0800, Yongqiang Yang wrote:
> Either the first block or the last one could be not aligned with
> block boundary, 1 block is needed to fix it.
>
> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Thanks for the patch submission!
I further modified the patch to make the commit description a bit
clearer, and to fix an additional bug that I noticed while reviewing
your patch.
- Ted
>From fa0dfea6882a833a70f04b3089a751f75c0d03f6 Mon Sep 17 00:00:00 2001
From: Yongqiang Yang <xiaoqiangnk@gmail.com>
Date: Mon, 4 Apr 2011 15:38:38 -0400
Subject: [PATCH] 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>
---
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 1a86282..7d11e02 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,
/* 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
--
1.7.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4:Fix credits computing for indirect mapped files.
2011-04-04 19:39 ` Ted Ts'o
@ 2011-04-05 5:02 ` Yongqiang Yang
0 siblings, 0 replies; 3+ messages in thread
From: Yongqiang Yang @ 2011-04-05 5:02 UTC (permalink / raw)
To: Ted Ts'o; +Cc: linux-ext4
On Tue, Apr 5, 2011 at 3:39 AM, Ted Ts'o <tytso@mit.edu> wrote:
> On Fri, Mar 25, 2011 at 09:10:05PM +0800, Yongqiang Yang wrote:
>> Either the first block or the last one could be not aligned with
>> block boundary, 1 block is needed to fix it.
>>
>> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
>
> Thanks for the patch submission!
>
> I further modified the patch to make the commit description a bit
> clearer, and to fix an additional bug that I noticed while reviewing
> your patch.
Thank you.
Yongqiang.
>
> - Ted
>
> From fa0dfea6882a833a70f04b3089a751f75c0d03f6 Mon Sep 17 00:00:00 2001
> From: Yongqiang Yang <xiaoqiangnk@gmail.com>
> Date: Mon, 4 Apr 2011 15:38:38 -0400
> Subject: [PATCH] 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>
> ---
> 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 1a86282..7d11e02 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,
> /* 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
> --
> 1.7.3.1
>
>
--
Best Wishes
Yongqiang Yang
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-05 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-25 13:10 [PATCH] ext4:Fix credits computing for indirect mapped files Yongqiang Yang
2011-04-04 19:39 ` Ted Ts'o
2011-04-05 5:02 ` Yongqiang Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).