linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ye Bin <yebin10@huawei.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	jack@suse.cz
Subject: Re: [PATCH -next v3 2/5] ext4: compare to local seq and nodename when check conflict
Date: Tue, 19 Oct 2021 10:54:37 +0200	[thread overview]
Message-ID: <20211019085437.GB3255@quack2.suse.cz> (raw)
In-Reply-To: <20211019064959.625557-3-yebin10@huawei.com>

On Tue 19-10-21 14:49:56, Ye Bin wrote:
> As mmp and check_mmp is point to the same data, so there will never
> detect conflict.
> To solve this issue just compare to local data.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 404dd50856e5..9a487a558787 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2601,6 +2601,8 @@ struct ext4_features {
>  #define EXT4_MMP_SEQ_FSCK  0xE24D4D50U /* mmp_seq value when being fscked */
>  #define EXT4_MMP_SEQ_MAX   0xE24D4D4FU /* maximum valid mmp_seq value */
>  
> +#define EXT4_MMP_NODENAME_LEN   64 /* mmp_nodename length */
> +
>  struct mmp_struct {
>  	__le32	mmp_magic;		/* Magic number for MMP */
>  	__le32	mmp_seq;		/* Sequence no. updated periodically */
> @@ -2610,7 +2612,8 @@ struct mmp_struct {
>  	 * purposes and do not affect the correctness of the algorithm
>  	 */
>  	__le64	mmp_time;		/* Time last updated */
> -	char	mmp_nodename[64];	/* Node which last updated MMP block */
> +	/* Node which last updated MMP block */
> +	char	mmp_nodename[EXT4_MMP_NODENAME_LEN];
>  	char	mmp_bdevname[32];	/* Bdev which last updated MMP block */
>  
>  	/*
> diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
> index 11627ff002d3..4af8b99ade84 100644
> --- a/fs/ext4/mmp.c
> +++ b/fs/ext4/mmp.c
> @@ -138,6 +138,7 @@ static int kmmpd(void *data)
>  	unsigned mmp_check_interval;
>  	unsigned long last_update_time;
>  	unsigned long diff;
> +	char nodename[EXT4_MMP_NODENAME_LEN];
>  	int retval = 0;
>  
>  	mmp_block = le64_to_cpu(es->s_mmp_block);
> @@ -154,8 +155,8 @@ static int kmmpd(void *data)
>  	BUILD_BUG_ON(sizeof(mmp->mmp_bdevname) < BDEVNAME_SIZE);
>  	bdevname(bh->b_bdev, mmp->mmp_bdevname);
>  
> -	memcpy(mmp->mmp_nodename, init_utsname()->nodename,
> -	       sizeof(mmp->mmp_nodename));
> +	memcpy(nodename, init_utsname()->nodename, sizeof(nodename));
> +	memcpy(mmp->mmp_nodename, nodename, sizeof(mmp->mmp_nodename));
>  
>  	while (!kthread_should_stop() && !sb_rdonly(sb)) {
>  		if (!ext4_has_feature_mmp(sb)) {
> @@ -207,8 +208,8 @@ static int kmmpd(void *data)
>  			}
>  
>  			mmp_check = (struct mmp_struct *)(bh_check->b_data);
> -			if (mmp->mmp_seq != mmp_check->mmp_seq ||
> -			    memcmp(mmp->mmp_nodename, mmp_check->mmp_nodename,
> +			if (seq != mmp_check->mmp_seq ||
> +			    memcmp(nodename, mmp_check->mmp_nodename,
>  				   sizeof(mmp->mmp_nodename))) {
>  				dump_mmp_msg(sb, mmp_check,
>  					     "Error while updating MMP info. "
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2021-10-19  8:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19  6:49 [PATCH -next v3 0/5] Fix some issues about mmp Ye Bin
2021-10-19  6:49 ` [PATCH -next v3 1/5] ext4: init 'seq' with the value which set in 'ext4_multi_mount_protect' Ye Bin
2021-10-19  8:53   ` Jan Kara
2021-10-19  6:49 ` [PATCH -next v3 2/5] ext4: compare to local seq and nodename when check conflict Ye Bin
2021-10-19  8:54   ` Jan Kara [this message]
2021-10-19  6:49 ` [PATCH -next v3 3/5] ext4: get buffer head before read_mmp_block Ye Bin
2021-10-19  9:12   ` Jan Kara
2021-10-19  6:49 ` [PATCH -next v3 4/5] ext4: simplify read_mmp_block fucntion Ye Bin
2021-10-19 13:13   ` kernel test robot
2021-10-19  6:49 ` [PATCH -next v3 5/5] ext4: avoid to re-read mmp check data get from page cache Ye Bin
2021-10-19  9:10   ` Jan Kara

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=20211019085437.GB3255@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yebin10@huawei.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).