From: Eric Sandeen <sandeen@redhat.com>
To: Yongqiang Yang <xiaoqiangnk@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] e2fsck: fix error in computing blocks of the ending group
Date: Tue, 19 Jul 2011 11:18:50 -0500 [thread overview]
Message-ID: <4E25AE6A.6090909@redhat.com> (raw)
In-Reply-To: <1311090411-13766-1-git-send-email-xiaoqiangnk@gmail.com>
On 07/19/2011 10:46 AM, Yongqiang Yang wrote:
> If the blocks of a filesystem is a multiple of blocks_per_group,
> blocks of the ending group is computed wrongly. This patch computes
> it by substracting blocks processed from blocks of the filesystem.
>
> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
> ---
> e2fsck/pass5.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
> index f9d746c..7c4e336 100644
> --- a/e2fsck/pass5.c
> +++ b/e2fsck/pass5.c
> @@ -227,7 +227,7 @@ redo_counts:
> if (group == (int)fs->group_desc_count - 1)
> cmp_block =
> EXT2FS_NUM_B2C(fs,
> - ext2fs_blocks_count(fs->super) % fs->super->s_blocks_per_group);
> + ext2fs_blocks_count(fs->super) - i);
> }
>
> bitmap = 0;
I think it would be clearer to just get the last group block count from
superblock information, rather than from using the loop counter.
For example resize does:
if (i == fs->group_desc_count-1) {
numblocks = (ext2fs_blocks_count(fs->super) -
fs->super->s_first_data_block) %
fs->super->s_blocks_per_group;
if (!numblocks)
numblocks = fs->super->s_blocks_per_group;
same as this function in alloc_sb.c:
if (group == fs->group_desc_count-1) {
num_blocks = (ext2fs_blocks_count(fs->super) -
fs->super->s_first_data_block) %
fs->super->s_blocks_per_group;
if (!num_blocks)
num_blocks = fs->super->s_blocks_per_group;
Hm, seems maybe an ext2fs_blocks_in_group() helper function might be
nice, since this is a little verbose, and is used fairly often.
-Eric
next prev parent reply other threads:[~2011-07-19 16:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-19 15:46 [PATCH] e2fsck: fix error in computing blocks of the ending group Yongqiang Yang
2011-07-19 16:18 ` Eric Sandeen [this message]
2011-07-20 21:46 ` [PATCH] e2fsprogs: add ext2fs_group_blocks_count helper Eric Sandeen
2011-07-20 21:57 ` [PATCH V2] " Eric Sandeen
2011-07-21 13:55 ` Eric Sandeen
2011-07-21 14:57 ` Yongqiang Yang
2011-07-21 15:06 ` Eric Sandeen
2011-07-21 18:15 ` [PATCH V3] " Eric Sandeen
2011-09-16 13:22 ` [V3] " Ted Ts'o
2011-07-21 14:54 ` [PATCH] " Yongqiang Yang
2011-07-21 17:40 ` [PATCH] e2fsck: fix error in computing blocks of the ending group Eric Sandeen
2011-07-22 4:18 ` [PATCH V2] " Eric Sandeen
2011-09-16 13:29 ` [V2] " Ted Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E25AE6A.6090909@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=xiaoqiangnk@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).