linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 09/11] xfs: btree scrub should check minrecs
Date: Thu, 19 Apr 2018 08:55:55 -0400	[thread overview]
Message-ID: <20180419125555.GC25844@bfoster.bfoster> (raw)
In-Reply-To: <152401923232.11465.11554889141647009009.stgit@magnolia>

On Tue, Apr 17, 2018 at 07:40:32PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Strengthen the btree block header checks to detect the number of records
> being less than the btree type's minimum record count.  Certain blocks
> are allowed to violate this constraint -- specifically any btree block
> at the top of the tree can have fewer than minrecs records.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/scrub/btree.c |   40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> 
> diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
> index ea972da..2d29dce 100644
> --- a/fs/xfs/scrub/btree.c
> +++ b/fs/xfs/scrub/btree.c
> @@ -455,6 +455,44 @@ xfs_scrub_btree_check_owner(
>  }
>  
>  /*
> + * Check that this btree block has at least minrecs records or is one of the
> + * special blocks that don't require that.
> + */
> +STATIC void
> +xfs_scrub_btree_check_minrecs(
> +	struct xfs_scrub_btree	*bs,
> +	int			level,
> +	struct xfs_btree_block	*block)
> +{
> +	unsigned int		numrecs;
> +	int			ok_level;
> +
> +	numrecs = be16_to_cpu(block->bb_numrecs);
> +
> +	/* More records than minrecs means the block is ok. */
> +	if (numrecs >= bs->cur->bc_ops->get_minrecs(bs->cur, level))
> +		return;
> +
> +	/*
> +	 * Certain btree blocks /can/ have fewer than minrecs records.  Any
> +	 * level greater than or equal to the level of the highest dedicated
> +	 * btree block are allowed to violate this constraint.
> +	 *
> +	 * For a btree rooted in a block, the btree root can have fewer than
> +	 * minrecs records.  If the btree is rooted in an inode and does not
> +	 * store records in the root, the direct children of the root and the
> +	 * root itself can have fewer than minrecs records.
> +	 */
> +	ok_level = bs->cur->bc_nlevels - 1;
> +	if (bs->cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
> +		ok_level--;
> +	if (level >= ok_level)
> +		return;
> +
> +	xfs_scrub_btree_set_corrupt(bs->sc, bs->cur, level);
> +}
> +
> +/*
>   * Grab and scrub a btree block given a btree pointer.  Returns block
>   * and buffer pointers (if applicable) if they're ok to use.
>   */
> @@ -491,6 +529,8 @@ xfs_scrub_btree_get_block(
>  	if (*pbp)
>  		xfs_scrub_buffer_recheck(bs->sc, *pbp);
>  
> +	xfs_scrub_btree_check_minrecs(bs, level, *pblock);
> +
>  	/*
>  	 * Check the block's owner; this function absorbs error codes
>  	 * for us.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" 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:[~2018-04-19 12:55 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-18  2:39 [PATCH 00/11] xfs-4.18: online scrub fixes Darrick J. Wong
2018-04-18  2:39 ` [PATCH 01/11] xfs: skip scrub xref if corruption already noted Darrick J. Wong
2018-04-18 15:03   ` Brian Foster
2018-04-18 16:02     ` Darrick J. Wong
2018-04-18  2:39 ` [PATCH 02/11] xfs: create the XFS_QMOPT_QUOTIP_LOCKED flag Darrick J. Wong
2018-04-18 15:33   ` Brian Foster
2018-04-18 16:55     ` Darrick J. Wong
2018-04-18 17:09       ` Brian Foster
2018-04-19  8:32   ` Christoph Hellwig
2018-04-21 18:42     ` Darrick J. Wong
2018-04-18  2:39 ` [PATCH 03/11] xfs: report failing address when dquot verifier fails Darrick J. Wong
2018-04-18 18:33   ` Brian Foster
2018-04-18  2:40 ` [PATCH 04/11] xfs: refactor dquot iteration Darrick J. Wong
2018-04-18 18:34   ` Brian Foster
2018-04-18 22:20     ` Darrick J. Wong
2018-04-18  2:40 ` [PATCH 05/11] xfs: avoid ilock games in the quota scrubber Darrick J. Wong
2018-04-18 18:34   ` Brian Foster
2018-04-18  2:40 ` [PATCH 06/11] xfs: quota scrub should use bmapbtd scrubber Darrick J. Wong
2018-04-18 18:34   ` Brian Foster
2018-04-18 20:00     ` Darrick J. Wong
2018-04-19 11:20       ` Brian Foster
2018-04-18  2:40 ` [PATCH 07/11] xfs: superblock scrub should use uncached buffers Darrick J. Wong
2018-04-19 12:55   ` Brian Foster
2018-04-19 17:25     ` Darrick J. Wong
2018-04-19 18:57       ` Brian Foster
2018-04-20  0:07         ` Dave Chinner
2018-04-21  0:29           ` Darrick J. Wong
2018-04-20  0:05       ` Dave Chinner
2018-04-18  2:40 ` [PATCH 08/11] xfs: clean up scrub usage of KM_NOFS Darrick J. Wong
2018-04-19 12:55   ` Brian Foster
2018-04-18  2:40 ` [PATCH 09/11] xfs: btree scrub should check minrecs Darrick J. Wong
2018-04-19 12:55   ` Brian Foster [this message]
2018-04-18  2:40 ` [PATCH 10/11] xfs: refactor scrub transaction allocation function Darrick J. Wong
2018-04-19 12:56   ` Brian Foster
2018-04-18  2:40 ` [PATCH 11/11] xfs: avoid ABBA deadlock when scrubbing parent pointers Darrick J. Wong
2018-04-19 12:56   ` Brian Foster
2018-04-19 17:33     ` Darrick J. Wong
2018-04-19 18:58       ` Brian Foster
2018-04-19 19:06         ` Darrick J. Wong
2018-04-21  0:31           ` Darrick J. Wong

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=20180419125555.GC25844@bfoster.bfoster \
    --to=bfoster@redhat.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 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).