2012-04-01 12:01:08

by Yongqiang Yang

[permalink] [raw]
Subject: [PATCH 1/2] ext4: teach resize report old blocks count correctly

o_blocks_count should not be changed, becasuse it is used later when
reporting old blocks count in debug mode.

Signed-off-by: Yongqiang Yang <[email protected]>
---
fs/ext4/resize.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 59fa0be..601fea1 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1654,8 +1654,7 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
es->s_log_groups_per_flex)
flexbg_size = 1 << es->s_log_groups_per_flex;

- o_blocks_count = ext4_blocks_count(es);
- if (o_blocks_count == n_blocks_count)
+ if (ext4_blocks_count(es) == n_blocks_count)
goto out;

flex_gd = alloc_flex_gd(flexbg_size);
--
1.7.5.1



2012-04-01 12:01:10

by Yongqiang Yang

[permalink] [raw]
Subject: [PATCH 2/2] ext4: ignore last group without enough space when resizing

If last gtoup has no enough space for group tables, then we
just ignore it.

Reported-by: Daniel Drake <[email protected]>
Signed-off-by: Yongqiang Yang <[email protected]>
---
fs/ext4/resize.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 601fea1..7a961cc 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -199,7 +199,7 @@ static void free_flex_gd(struct ext4_new_flex_group_data *flex_gd)
*
* @sb: super block of fs to which the groups belongs
*/
-static void ext4_alloc_group_tables(struct super_block *sb,
+static int ext4_alloc_group_tables(struct super_block *sb,
struct ext4_new_flex_group_data *flex_gd,
int flexbg_size)
{
@@ -224,6 +224,8 @@ static void ext4_alloc_group_tables(struct super_block *sb,
(last_group & ~(flexbg_size - 1))));
next_group:
group = group_data[0].group;
+ if (src_group >= group_data[0].group + flex_gd->count)
+ return -EINVAL;
start_blk = ext4_group_first_block_no(sb, src_group);
last_blk = start_blk + group_data[src_group - group].blocks_count;

@@ -233,7 +235,6 @@ next_group:

start_blk += overhead;

- BUG_ON(src_group >= group_data[0].group + flex_gd->count);
/* We collect contiguous blocks as much as possible. */
src_group++;
for (; src_group <= last_group; src_group++)
@@ -298,6 +299,7 @@ next_group:
group_data[i].free_blocks_count);
}
}
+ return 0;
}

static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
@@ -1668,7 +1670,11 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
*/
while (ext4_setup_next_flex_gd(sb, flex_gd, n_blocks_count,
flexbg_size)) {
- ext4_alloc_group_tables(sb, flex_gd, flexbg_size);
+ err = ext4_alloc_group_tables(sb, flex_gd, flexbg_size);
+ if (err == -EINVAL) {
+ err = 0;
+ break;
+ }
err = ext4_flex_group_add(sb, resize_inode, flex_gd);
if (unlikely(err))
break;
--
1.7.5.1


2012-04-02 15:04:11

by Daniel Drake

[permalink] [raw]
Subject: Re: [PATCH 2/2] ext4: ignore last group without enough space when resizing

Hi,

On Tue, Jan 31, 2012 at 9:01 PM, Yongqiang Yang <[email protected]> wrote:
> If last gtoup has no enough space for group tables, then we
> just ignore it.
>
> Reported-by: Daniel Drake <[email protected]>
> Signed-off-by: Yongqiang Yang <[email protected]>

Thanks, this fixes the crash.

Am I right in thinking that the companion patch "[PATCH] resize2fs:
let online resizing report new blocks count right" is only needed for
cosmetic reasons; the resize operation will be successful even without
that patch applied to resize2fs?

Thanks,
Daniel

2012-04-02 15:06:57

by Yongqiang Yang

[permalink] [raw]
Subject: Re: [PATCH 2/2] ext4: ignore last group without enough space when resizing

On Mon, Apr 2, 2012 at 11:04 PM, Daniel Drake <[email protected]> wrote:
> Hi,
>
> On Tue, Jan 31, 2012 at 9:01 PM, Yongqiang Yang <[email protected]> wrote:
>> If last gtoup has no enough space for group tables, then we
>> just ignore it.
>>
>> Reported-by: Daniel Drake <[email protected]>
>> Signed-off-by: Yongqiang Yang <[email protected]>
>
> Thanks, this fixes the crash.
>
> Am I right in thinking that the companion patch "[PATCH] resize2fs:
> let online resizing report new blocks count right" is only needed for
> cosmetic reasons; the resize operation will be successful even without
> that patch applied to resize2fs?
Yep, that patch just lets resize2fs report right size of resized filesytems.

Thanks,
Yongqiang.
>
> Thanks,
> Daniel



--
Best Wishes
Yongqiang Yang

2012-05-10 13:15:42

by Yongqiang Yang

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: teach resize report old blocks count correctly

ping?

The 2nd patch of the series fixes a bug which I meet again when
testing 64bit feature.


Yongqiang.

On Wed, Feb 1, 2012 at 11:01 AM, Yongqiang Yang <[email protected]> wrote:
> o_blocks_count should not be changed, becasuse it is used later when
> reporting old blocks count in debug mode.
>
> Signed-off-by: Yongqiang Yang <[email protected]>
> ---
> ?fs/ext4/resize.c | ? ?3 +--
> ?1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
> index 59fa0be..601fea1 100644
> --- a/fs/ext4/resize.c
> +++ b/fs/ext4/resize.c
> @@ -1654,8 +1654,7 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
> ? ? ? ? ? ?es->s_log_groups_per_flex)
> ? ? ? ? ? ? ? ?flexbg_size = 1 << es->s_log_groups_per_flex;
>
> - ? ? ? o_blocks_count = ext4_blocks_count(es);
> - ? ? ? if (o_blocks_count == n_blocks_count)
> + ? ? ? if (ext4_blocks_count(es) == n_blocks_count)
> ? ? ? ? ? ? ? ?goto out;
>
> ? ? ? ?flex_gd = alloc_flex_gd(flexbg_size);
> --
> 1.7.5.1
>



--
Best Wishes
Yongqiang Yang