linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v3 5/9] xfs: split up allocation btree verifier
Date: Wed, 6 Feb 2019 10:15:06 -0800	[thread overview]
Message-ID: <20190206181506.GT7991@magnolia> (raw)
In-Reply-To: <20190204145231.47034-6-bfoster@redhat.com>

On Mon, Feb 04, 2019 at 09:52:27AM -0500, Brian Foster wrote:
> Similar to the inode btree verifier, the same allocation btree
> verifier structure is shared between the by-bno (bnobt) and by-size
> (cntbt) btrees. This prevents the ability to distinguish magic
> values between them. Separate the verifier into two, one for each
> tree, and assign them appropriately. No functional changes.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_ag.c          |  4 ++--
>  fs/xfs/libxfs/xfs_alloc_btree.c | 14 ++++++++++----
>  fs/xfs/libxfs/xfs_shared.h      |  3 ++-
>  fs/xfs/scrub/agheader_repair.c  |  4 ++--
>  fs/xfs/xfs_log_recover.c        |  6 ++++--
>  5 files changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
> index bde67ef3ff43..1ef8acf35e7d 100644
> --- a/fs/xfs/libxfs/xfs_ag.c
> +++ b/fs/xfs/libxfs/xfs_ag.c
> @@ -339,14 +339,14 @@ xfs_ag_init_headers(
>  	{ /* BNO root block */
>  		.daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_BNO_BLOCK(mp)),
>  		.numblks = BTOBB(mp->m_sb.sb_blocksize),
> -		.ops = &xfs_allocbt_buf_ops,
> +		.ops = &xfs_bnobt_buf_ops,
>  		.work = &xfs_bnoroot_init,
>  		.need_init = true
>  	},
>  	{ /* CNT root block */
>  		.daddr = XFS_AGB_TO_DADDR(mp, id->agno, XFS_CNT_BLOCK(mp)),
>  		.numblks = BTOBB(mp->m_sb.sb_blocksize),
> -		.ops = &xfs_allocbt_buf_ops,
> +		.ops = &xfs_cntbt_buf_ops,
>  		.work = &xfs_cntroot_init,
>  		.need_init = true
>  	},
> diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
> index 4e59cc8a2802..480d0f52da64 100644
> --- a/fs/xfs/libxfs/xfs_alloc_btree.c
> +++ b/fs/xfs/libxfs/xfs_alloc_btree.c
> @@ -377,13 +377,19 @@ xfs_allocbt_write_verify(
>  
>  }
>  
> -const struct xfs_buf_ops xfs_allocbt_buf_ops = {
> -	.name = "xfs_allocbt",
> +const struct xfs_buf_ops xfs_bnobt_buf_ops = {
> +	.name = "xfs_bnobt",
>  	.verify_read = xfs_allocbt_read_verify,
>  	.verify_write = xfs_allocbt_write_verify,
>  	.verify_struct = xfs_allocbt_verify,
>  };
>  
> +const struct xfs_buf_ops xfs_cntbt_buf_ops = {
> +	.name = "xfs_cntbt",
> +	.verify_read = xfs_allocbt_read_verify,
> +	.verify_write = xfs_allocbt_write_verify,
> +	.verify_struct = xfs_allocbt_verify,
> +};
>  
>  STATIC int
>  xfs_bnobt_keys_inorder(
> @@ -448,7 +454,7 @@ static const struct xfs_btree_ops xfs_bnobt_ops = {
>  	.init_rec_from_cur	= xfs_allocbt_init_rec_from_cur,
>  	.init_ptr_from_cur	= xfs_allocbt_init_ptr_from_cur,
>  	.key_diff		= xfs_bnobt_key_diff,
> -	.buf_ops		= &xfs_allocbt_buf_ops,
> +	.buf_ops		= &xfs_bnobt_buf_ops,
>  	.diff_two_keys		= xfs_bnobt_diff_two_keys,
>  	.keys_inorder		= xfs_bnobt_keys_inorder,
>  	.recs_inorder		= xfs_bnobt_recs_inorder,
> @@ -470,7 +476,7 @@ static const struct xfs_btree_ops xfs_cntbt_ops = {
>  	.init_rec_from_cur	= xfs_allocbt_init_rec_from_cur,
>  	.init_ptr_from_cur	= xfs_allocbt_init_ptr_from_cur,
>  	.key_diff		= xfs_cntbt_key_diff,
> -	.buf_ops		= &xfs_allocbt_buf_ops,
> +	.buf_ops		= &xfs_cntbt_buf_ops,
>  	.diff_two_keys		= xfs_cntbt_diff_two_keys,
>  	.keys_inorder		= xfs_cntbt_keys_inorder,
>  	.recs_inorder		= xfs_cntbt_recs_inorder,
> diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
> index 9855f4d2f98f..4e909791aeac 100644
> --- a/fs/xfs/libxfs/xfs_shared.h
> +++ b/fs/xfs/libxfs/xfs_shared.h
> @@ -25,7 +25,8 @@ extern const struct xfs_buf_ops xfs_agf_buf_ops;
>  extern const struct xfs_buf_ops xfs_agi_buf_ops;
>  extern const struct xfs_buf_ops xfs_agf_buf_ops;
>  extern const struct xfs_buf_ops xfs_agfl_buf_ops;
> -extern const struct xfs_buf_ops xfs_allocbt_buf_ops;
> +extern const struct xfs_buf_ops xfs_bnobt_buf_ops;
> +extern const struct xfs_buf_ops xfs_cntbt_buf_ops;
>  extern const struct xfs_buf_ops xfs_rmapbt_buf_ops;
>  extern const struct xfs_buf_ops xfs_refcountbt_buf_ops;
>  extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
> diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
> index 673be3cf7b8d..2799d1531639 100644
> --- a/fs/xfs/scrub/agheader_repair.c
> +++ b/fs/xfs/scrub/agheader_repair.c
> @@ -341,12 +341,12 @@ xrep_agf(
>  	struct xrep_find_ag_btree	fab[XREP_AGF_MAX] = {
>  		[XREP_AGF_BNOBT] = {
>  			.rmap_owner = XFS_RMAP_OWN_AG,
> -			.buf_ops = &xfs_allocbt_buf_ops,
> +			.buf_ops = &xfs_bnobt_buf_ops,
>  			.magic = XFS_ABTB_CRC_MAGIC,
>  		},
>  		[XREP_AGF_CNTBT] = {
>  			.rmap_owner = XFS_RMAP_OWN_AG,
> -			.buf_ops = &xfs_allocbt_buf_ops,
> +			.buf_ops = &xfs_cntbt_buf_ops,
>  			.magic = XFS_ABTC_CRC_MAGIC,

/me wonders if this part of repair ought to be refactored to pull the
magic number from the buf_ops, though that's a separate patch for after
all the buf ops have been modified to have magic numbers.

This patch looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  		},
>  		[XREP_AGF_RMAPBT] = {
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 228c754bb137..5ad42d598333 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -2439,10 +2439,12 @@ xlog_recover_validate_buf_type(
>  	case XFS_BLFT_BTREE_BUF:
>  		switch (magic32) {
>  		case XFS_ABTB_CRC_MAGIC:
> -		case XFS_ABTC_CRC_MAGIC:
>  		case XFS_ABTB_MAGIC:
> +			bp->b_ops = &xfs_bnobt_buf_ops;
> +			break;
> +		case XFS_ABTC_CRC_MAGIC:
>  		case XFS_ABTC_MAGIC:
> -			bp->b_ops = &xfs_allocbt_buf_ops;
> +			bp->b_ops = &xfs_cntbt_buf_ops;
>  			break;
>  		case XFS_IBT_CRC_MAGIC:
>  		case XFS_IBT_MAGIC:
> -- 
> 2.17.2
> 

  reply	other threads:[~2019-02-06 18:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 14:52 [PATCH v3 0/9] xfs: fix [f]inobt magic value verification Brian Foster
2019-02-04 14:52 ` [PATCH v3 1/9] xfs: set buffer ops when repair probes for btree type Brian Foster
2019-02-06 18:08   ` Darrick J. Wong
2019-02-06 18:40     ` Brian Foster
2019-02-04 14:52 ` [PATCH v3 2/9] xfs: always check magic values in on-disk byte order Brian Foster
2019-02-06 17:08   ` Darrick J. Wong
2019-02-04 14:52 ` [PATCH v3 3/9] xfs: create a separate finobt verifier Brian Foster
2019-02-06 18:09   ` Darrick J. Wong
2019-02-04 14:52 ` [PATCH v3 4/9] xfs: distinguish between inobt and finobt magic values Brian Foster
2019-02-06 18:12   ` Darrick J. Wong
2019-02-04 14:52 ` [PATCH v3 5/9] xfs: split up allocation btree verifier Brian Foster
2019-02-06 18:15   ` Darrick J. Wong [this message]
2019-02-04 14:52 ` [PATCH v3 6/9] xfs: distinguish between bnobt and cntbt magic values Brian Foster
2019-02-06 18:15   ` Darrick J. Wong
2019-02-04 14:52 ` [PATCH v3 7/9] xfs: use verifier magic field in dir2 leaf verifiers Brian Foster
2019-02-06 17:45   ` Darrick J. Wong
2019-02-06 18:41     ` Brian Foster
2019-02-06 19:03       ` Darrick J. Wong
2019-02-06 19:18         ` Brian Foster
2019-02-04 14:52 ` [PATCH v3 8/9] xfs: miscellaneous verifier magic value fixups Brian Foster
2019-02-06 17:52   ` Darrick J. Wong
2019-02-04 14:52 ` [PATCH v3 9/9] xfs: factor xfs_da3_blkinfo verification into common helper Brian Foster
2019-02-06 18:16   ` Darrick J. Wong
2019-02-06 18:23 ` [PATCH v3 0/9] xfs: fix [f]inobt magic value verification Darrick J. Wong
2019-02-06 18:50   ` Brian Foster
2019-02-06 19:05     ` Darrick J. Wong
2019-02-06 19:18       ` Brian Foster

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=20190206181506.GT7991@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=bfoster@redhat.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).