From: Ted Ts'o <tytso@mit.edu>
To: Yongqiang Yang <xiaoqiangnk@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH 2/3] e2fsprogs: move code computing old_desc_blocks to a function
Date: Mon, 23 Jan 2012 11:56:33 -0500 [thread overview]
Message-ID: <20120123165633.GC4439@thunk.org> (raw)
In-Reply-To: <1325674932-26069-2-git-send-email-xiaoqiangnk@gmail.com>
On Wed, Jan 04, 2012 at 07:02:11PM +0800, Yongqiang Yang wrote:
> diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c
> index 33da7d6..f1d5156 100644
> --- a/lib/ext2fs/blknum.c
> +++ b/lib/ext2fs/blknum.c
> @@ -98,6 +98,20 @@ blk64_t ext2fs_blocks_count(struct ext2_super_block *super)
> }
>
> /*
> + * Return the old desc blocks count
> + */
> +blk64_t ext2fs_old_desc_blocks_count(ext2_filsys fs)
> +{
> + blk64_t old_desc_blocks;
> +
> + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
> + if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG &&
> + old_desc_blocks > fs->super->s_first_meta_bg)
> + old_desc_blocks = fs->super->s_first_meta_bg;
> + return old_desc_blocks;
I'd prefer if you don't refactor code and change what it does at the
same time. That makes it harder later to figure out whether a bug is
introduced by the refactorization, or by the change in the
calculation. It's especially bad when there is no mention of the
change of the calculation in the commit description.
As I mentioned in my comments for your 3/3 patch, s_first_meta_bg
should *always* be less than old_desc_blocks, since it describes the
meta-blockgroup number where we start using the meta-blockgroup
layout. Since there the size of the meta-blockgroup is defined to be
the number of block groups descriptors that fit in a block, by
definition the meta_bg must be less than or equal to old_desc_blocks.
If it isn't the superblock must be corrupt.
I think it's much better to fix this by adding a check to open and
initialization functions.
- Ted
next prev parent reply other threads:[~2012-01-23 18:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-04 11:02 [PATCH V2 1/3] mke2fs: correct help text for option -G of mke2fs Yongqiang Yang
2012-01-04 11:02 ` [PATCH 2/3] e2fsprogs: move code computing old_desc_blocks to a function Yongqiang Yang
2012-01-23 16:56 ` Ted Ts'o [this message]
2012-01-04 11:02 ` [PATCH 3/3] e2fsprogs: add a function computing old desc blocks without reserved ones Yongqiang Yang
2012-01-23 16:45 ` Ted Ts'o
2012-01-23 16:47 ` [PATCH V2 1/3] mke2fs: correct help text for option -G of mke2fs 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=20120123165633.GC4439@thunk.org \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.