linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH v3 2/3] e2fsprogs/tune2fs: rewrite metadata checksums when resizing inode size
Date: Fri, 14 Nov 2014 15:10:10 -0800	[thread overview]
Message-ID: <20141114231010.GK10043@birch.djwong.org> (raw)
In-Reply-To: <1415956537-11212-2-git-send-email-wangxg.fnst@cn.fujitsu.com>

On Fri, Nov 14, 2014 at 05:15:36PM +0800, Xiaoguang Wang wrote:
> When we use tune2fs -I new_ino_size to change inode size, if everything is OK,
> the corresponding ext4_group_desc.bg_free_blocks_count will be decreased, so
> obviously, we need to re-compute the group descriptor checksums, and the inode
> 's size has also changed, we also need to recompute the checksums of inodes for
> metadata_csum filesystem, so here we choose to call a rewrite_metadata_checksums(),
> this will fix checksum issues.
> 
> Meanwhile, the patch will trigger an existing memory write overflow, which will
> casue segfault, please see the next patch.
> 
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  misc/tune2fs.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/misc/tune2fs.c b/misc/tune2fs.c
> index 065b483..91dc7c1 100644
> --- a/misc/tune2fs.c
> +++ b/misc/tune2fs.c
> @@ -2908,8 +2908,7 @@ retry_open:
>  				EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
>  			rewrite_checksums = 1;
>  	}
> -	if (rewrite_checksums)
> -		rewrite_metadata_checksums(fs);
> +
>  	if (I_flag) {
>  		if (mount_flags & EXT2_MF_MOUNTED) {
>  			fputs(_("The inode size may only be "
> @@ -2935,6 +2934,7 @@ retry_open:
>  		if (resize_inode(fs, new_inode_size) == 0) {

Come to think of it, if we're enabling metadata_csum /and/ resizing the inode,
we have to set EXT2_FLAG_IGNORE_CSUM_ERRORS before calling resize_inode.  If we
don't, the library calls that resize_inode() makes will try to verify the
checksums (which haven't been set yet) and the operation will fail.

Will send patch, but at this point I'm wondering if it doesn't make more sense
for me to incorporate them into my patchbomb rather than let this series get
lost in the blizzard...

--D

>  			printf(_("Setting inode size %lu\n"),
>  							new_inode_size);
> +			rewrite_checksums = 1;
>  		} else {
>  			printf("%s", _("Failed to change inode size\n"));
>  			rc = 1;
> @@ -2942,6 +2942,9 @@ retry_open:
>  		}
>  	}
>  
> +	if (rewrite_checksums)
> +		rewrite_metadata_checksums(fs);
> +
>  	if (l_flag)
>  		list_super(sb);
>  	if (stride_set) {
> -- 
> 1.8.2.1
> 
> --
> 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

  reply	other threads:[~2014-11-14 23:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12  9:49 [PATCH v2 1/3] e2fsprogs/tune2fs: fix memory leak in inode_scan_and_fix() Xiaoguang Wang
2014-11-12  9:49 ` [PATCH v2 2/3] e2fsprogs/tune2fs: rewrite metadata checksums when resizing inode size Xiaoguang Wang
2014-11-12 22:39   ` Darrick J. Wong
2014-11-14  8:57     ` Xiaoguang Wang
2014-11-12  9:49 ` [PATCH v2 3/3] e2fsprogs/tune2fs: fix memory write overflow Xiaoguang Wang
2014-11-14  9:15   ` [PATCH v3 1/3] e2fsprogs/tune2fs: fix memory leak in inode_scan_and_fix() Xiaoguang Wang
2014-11-14  9:15     ` [PATCH v3 2/3] e2fsprogs/tune2fs: rewrite metadata checksums when resizing inode size Xiaoguang Wang
2014-11-14 23:10       ` Darrick J. Wong [this message]
2014-11-17  1:56         ` Xiaoguang Wang
2014-11-17 19:10         ` [PATCH] tune2fs: disable csum verification before resizing inode Darrick J. Wong
2014-12-03  3:33           ` Theodore Ts'o
2014-12-03  3:46           ` Theodore Ts'o
2014-12-03  5:39             ` Darrick J. Wong
2014-12-03 14:34               ` Theodore Ts'o
2014-12-03  3:30       ` [PATCH v3 2/3] e2fsprogs/tune2fs: rewrite metadata checksums when resizing inode size Theodore Ts'o
2014-11-14  9:15     ` [PATCH v3 3/3] e2fsprogs/tune2fs: fix memory write overflow Xiaoguang Wang
2014-11-14 18:58       ` Darrick J. Wong
2014-12-03  3:32       ` Theodore Ts'o
2014-12-03  2:07     ` [PATCH v3 1/3] e2fsprogs/tune2fs: fix memory leak in inode_scan_and_fix() 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=20141114231010.GK10043@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=wangxg.fnst@cn.fujitsu.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).