All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org,
	Yongqiang Yang <xiaoqiangnk@gmail.com>,
	Milan Broz <mbroz@redhat.com>
Subject: Re: [PATCH] ext4: fix resize when resizing within single group
Date: Mon, 20 Feb 2012 23:03:28 -0500	[thread overview]
Message-ID: <20120221040328.GF25249@thunk.org> (raw)
In-Reply-To: <1328173555-26452-1-git-send-email-lczerner@redhat.com>

On Thu, Feb 02, 2012 at 10:05:55AM +0100, Lukas Czerner wrote:
> When resizing file system in the way that the new size of the file
> system is still in the same group (no new groups are added), then we can
> hit a BUG_ON in ext4_alloc_group_tables()
> 
> BUG_ON(flex_gd->count == 0 || group_data == NULL);
> 
> because flex_gd->count is zero. The reason is the missing check for such
> case, so the code always extend the last group fully and then attempt to
> add more groups, but at that time n_blocks_count is actually smaller
> than o_blocks_count.
> 
> It can be easily reproduced like this:
> 
> mkfs.ext4 -b 4096 /dev/sda 30M
> mount /dev/sda /mnt/test
> resize2fs /dev/sda 50M
> 
> Fix this by checking whether the resize happens within the singe group
> and only add that many blocks into the last group to satisfy user
> request. Then o_blocks_count == n_blocks_count and the resize will exit
> successfully without and attempt to add more groups into the fs.
> 
> Also fix mixing together block number and blocks count which might be
> confusing and can easily lead to off-by-one errors (but it is actually
> not the case here since the two occurrence of this mix-up will cancel
> each other).
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> Reported-by: Milan Broz <mbroz@redhat.com>

Thanks, applied.

						- Ted

      parent reply	other threads:[~2012-02-21  4:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02  9:05 [PATCH] ext4: fix resize when resizing within single group Lukas Czerner
2012-02-03 11:13 ` Yongqiang Yang
2012-02-21  0:20 ` Eric Sandeen
2012-02-21  4:03 ` Ted Ts'o [this message]

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=20120221040328.GF25249@thunk.org \
    --to=tytso@mit.edu \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mbroz@redhat.com \
    --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.