linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-ext4@vger.kernel.org
Subject: Re: [PATCH V3] resize2fs: clear uninit BG if allocating from new group
Date: Fri, 19 Feb 2016 16:21:52 -0600	[thread overview]
Message-ID: <56C79580.6030505@redhat.com> (raw)
In-Reply-To: <5697F69E.4090404@redhat.com>

On 1/14/16 1:27 PM, Eric Sandeen wrote:
> If resize2fs_get_alloc_block() allocates from a BLOCK_UNINIT
> group, nothing clears the UNINIT flag, so it is skipped when we
> go to write out modified bitmaps.  This leads to post-resize2fs
> e2fsck errors; used blocks in UNINIT groups, not marked in the
> block bitmap.  This was seen on r_ext4_small_bg.
> 
> This patch uses clear_block_uninit() to clear the flag,
> and my problem goes away.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> V2: don't cut and paste, sorry! 
> V3: ext2fs_* namespace for the exported function, thanks Darrick

Ted, any chance this could get merged?  It has 2 reviews now.

Thanks,
-Eric

> Thanks,
> -Eric
> 
> diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c
> index 86e7f99..ce59e85 100644
> --- a/lib/ext2fs/alloc.c
> +++ b/lib/ext2fs/alloc.c
> @@ -39,7 +39,7 @@
>  /*
>   * Clear the uninit block bitmap flag if necessary
>   */
> -static void clear_block_uninit(ext2_filsys fs, dgrp_t group)
> +void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group)
>  {
>  	if (!ext2fs_has_group_desc_csum(fs) ||
>  	    !(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
> @@ -183,7 +183,7 @@ allocated:
>  	if (retval)
>  		return retval;
>  
> -	clear_block_uninit(fs, ext2fs_group_of_blk2(fs, b));
> +	ext2fs_clear_block_uninit(fs, ext2fs_group_of_blk2(fs, b));
>  	*ret = b;
>  	return 0;
>  }
> @@ -455,7 +455,7 @@ errcode_t ext2fs_new_range(ext2_filsys fs, int flags, blk64_t goal,
>  allocated:
>  			for (b = start; b < end;
>  			     b += fs->super->s_blocks_per_group)
> -				clear_block_uninit(fs,
> +				ext2fs_clear_block_uninit(fs,
>  						ext2fs_group_of_blk2(fs, b));
>  			return 0;
>  		}
> diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
> index 86d860f..d5e9684 100644
> --- a/lib/ext2fs/ext2fs.h
> +++ b/lib/ext2fs/ext2fs.h
> @@ -647,6 +647,7 @@ static inline int ext2fs_needs_large_file_feature(unsigned long long file_size)
>  }
>  
>  /* alloc.c */
> +extern void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group);
>  extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode,
>  				  ext2fs_inode_bitmap map, ext2_ino_t *ret);
>  extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal,
> diff --git a/resize/resize2fs.c b/resize/resize2fs.c
> index 07c6a0c..42435b2 100644
> --- a/resize/resize2fs.c
> +++ b/resize/resize2fs.c
> @@ -1620,6 +1620,7 @@ static errcode_t resize2fs_get_alloc_block(ext2_filsys fs,
>  {
>  	ext2_resize_t rfs = (ext2_resize_t) fs->priv_data;
>  	blk64_t blk;
> +	int group;
>  
>  	blk = get_new_block(rfs);
>  	if (!blk)
> @@ -1632,6 +1633,12 @@ static errcode_t resize2fs_get_alloc_block(ext2_filsys fs,
>  
>  	ext2fs_mark_block_bitmap2(rfs->old_fs->block_map, blk);
>  	ext2fs_mark_block_bitmap2(rfs->new_fs->block_map, blk);
> +
> +	group = ext2fs_group_of_blk2(rfs->old_fs, blk);
> +	ext2fs_clear_block_uninit(rfs->old_fs, group);
> +	group = ext2fs_group_of_blk2(rfs->new_fs, blk);
> +	ext2fs_clear_block_uninit(rfs->new_fs, group);
> +
>  	*ret = (blk64_t) blk;
>  	return 0;
>  }
> 
> --
> 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
> 


  parent reply	other threads:[~2016-02-19 22:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-17 22:42 [PATCH] resize2fs: clear uninit BG if allocating from new group Eric Sandeen
2015-09-17 23:55 ` Darrick J. Wong
2015-09-18  0:54   ` Eric Sandeen
2015-09-18  3:19     ` Eric Sandeen
2016-01-14 14:09 ` Eric Sandeen
2016-01-14 17:20   ` Andreas Dilger
2016-01-14 18:46 ` [PATCH V2] " Eric Sandeen
2016-01-14 18:50   ` Darrick J. Wong
2016-01-14 19:26     ` Eric Sandeen
2016-01-14 19:27   ` [PATCH V3] " Eric Sandeen
2016-01-14 19:38     ` Darrick J. Wong
2016-01-14 19:39     ` Andreas Dilger
2016-01-14 19:57     ` Eric Sandeen
2016-02-19 22:21     ` Eric Sandeen [this message]
2016-03-07  2:51     ` Theodore 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=56C79580.6030505@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /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).