All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandan Rajendra <chandan@linux.ibm.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/4] xfs: validate the realtime geometry in xfs_validate_sb_common
Date: Wed, 01 Apr 2020 19:19:51 +0530	[thread overview]
Message-ID: <2265826.PVY0go2oF0@localhost.localdomain> (raw)
In-Reply-To: <158510668306.922633.16796248628127177511.stgit@magnolia>

On Wednesday, March 25, 2020 8:54 AM Darrick J. Wong wrote: 
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Validate the geometry of the realtime geometry when we mount the
> filesystem, so that we don't abruptly shut down the filesystem later on.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

The changes look logically correct.

Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>

> ---
>  fs/xfs/libxfs/xfs_sb.c |   35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 2f60fc3c99a0..dee0a1a594dc 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -328,6 +328,41 @@ xfs_validate_sb_common(
>  		return -EFSCORRUPTED;
>  	}
>  
> +	/* Validate the realtime geometry; stolen from xfs_repair */
> +	if (unlikely(
> +	    sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE	||
> +	    sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE)) {
> +		xfs_notice(mp,
> +			"realtime extent sanity check failed");
> +		return -EFSCORRUPTED;
> +	}
> +
> +	if (sbp->sb_rblocks == 0) {
> +		if (unlikely(
> +		    sbp->sb_rextents != 0				||
> +		    sbp->sb_rbmblocks != 0				||
> +		    sbp->sb_rextslog != 0				||
> +		    sbp->sb_frextents != 0)) {
> +			xfs_notice(mp,
> +				"realtime zeroed geometry sanity check failed");
> +			return -EFSCORRUPTED;
> +		}
> +	} else {
> +		xfs_rtblock_t	rexts;
> +		uint32_t	temp;
> +
> +		rexts = div_u64_rem(sbp->sb_rblocks, sbp->sb_rextsize, &temp);
> +		if (unlikely(
> +		    rexts != sbp->sb_rextents				||
> +		    sbp->sb_rextslog != xfs_highbit32(sbp->sb_rextents)	||
> +		    sbp->sb_rbmblocks != howmany(sbp->sb_rextents,
> +						NBBY * sbp->sb_blocksize))) {
> +			xfs_notice(mp,
> +				"realtime geometry sanity check failed");
> +			return -EFSCORRUPTED;
> +		}
> +	}
> +
>  	if (sbp->sb_unit) {
>  		if (!xfs_sb_version_hasdalign(sbp) ||
>  		    sbp->sb_unit > sbp->sb_width ||
> 
> 


-- 
chandan




  parent reply	other threads:[~2020-04-01 13:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  3:24 [PATCH 0/4] xfs: random fixes Darrick J. Wong
2020-03-25  3:24 ` [PATCH 1/4] xfs: prohibit fs freezing when using empty transactions Darrick J. Wong
2020-03-25  4:53   ` Dave Chinner
2020-03-25  5:56     ` Darrick J. Wong
2020-03-25  6:06   ` [PATCH v2 " Darrick J. Wong
2020-03-25 23:26     ` Dave Chinner
2020-04-01 11:22   ` [PATCH " Chandan Rajendra
2020-03-25  3:24 ` [PATCH 2/4] xfs: validate the realtime geometry in xfs_validate_sb_common Darrick J. Wong
2020-03-25  5:00   ` Dave Chinner
2020-03-25  5:53     ` Darrick J. Wong
2020-03-25  6:07   ` [PATCH v2 " Darrick J. Wong
2020-03-25 23:27     ` Dave Chinner
2020-04-01 13:49   ` Chandan Rajendra [this message]
2020-03-25  3:24 ` [PATCH 3/4] xfs: drop all altpath buffers at the end of the sibling check Darrick J. Wong
2020-03-25  5:04   ` Dave Chinner
2020-04-02  3:05   ` Chandan Rajendra
2020-03-25  3:24 ` [PATCH 4/4] xfs: directory bestfree check should release buffers Darrick J. Wong
2020-03-25  5:05   ` Dave Chinner

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=2265826.PVY0go2oF0@localhost.localdomain \
    --to=chandan@linux.ibm.com \
    --cc=darrick.wong@oracle.com \
    --cc=linux-xfs@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 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.