linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 04/34] xfs: devirtualize ->node_hdr_to_disk
Date: Mon, 4 Nov 2019 10:39:58 -0800	[thread overview]
Message-ID: <20191104183958.GE4153244@magnolia> (raw)
In-Reply-To: <20191101220719.29100-5-hch@lst.de>

On Fri, Nov 01, 2019 at 03:06:49PM -0700, Christoph Hellwig wrote:
> Replace the ->node_hdr_to_disk dir ops method with a directly called
> xfs_da_node_hdr_to_disk helper that takes care of the v4 vs v5
> difference.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Nice substitution here too,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c |  2 +-
>  fs/xfs/libxfs/xfs_da_btree.c  | 39 ++++++++++++++++++++++++++++-------
>  fs/xfs/libxfs/xfs_da_btree.h  |  2 ++
>  fs/xfs/libxfs/xfs_da_format.c | 34 ------------------------------
>  fs/xfs/libxfs/xfs_dir2.h      |  2 --
>  5 files changed, 35 insertions(+), 44 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 131fef677896..1b0fbee21e14 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -1196,7 +1196,7 @@ xfs_attr3_leaf_to_node(
>  	btree[0].hashval = entries[icleafhdr.count - 1].hashval;
>  	btree[0].before = cpu_to_be32(blkno);
>  	icnodehdr.count = 1;
> -	dp->d_ops->node_hdr_to_disk(node, &icnodehdr);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node, &icnodehdr);
>  	xfs_trans_log_buf(args->trans, bp1, 0, args->geo->blksize - 1);
>  	error = 0;
>  out:
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index f7ddc91ed099..462a245fdad7 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -135,6 +135,31 @@ xfs_da3_node_hdr_from_disk(
>  	}
>  }
>  
> +void
> +xfs_da3_node_hdr_to_disk(
> +	struct xfs_mount		*mp,
> +	struct xfs_da_intnode		*to,
> +	struct xfs_da3_icnode_hdr	*from)
> +{
> +	if (xfs_sb_version_hascrc(&mp->m_sb)) {
> +		struct xfs_da3_intnode	*to3 = (struct xfs_da3_intnode *)to;
> +
> +		ASSERT(from->magic == XFS_DA3_NODE_MAGIC);
> +		to3->hdr.info.hdr.forw = cpu_to_be32(from->forw);
> +		to3->hdr.info.hdr.back = cpu_to_be32(from->back);
> +		to3->hdr.info.hdr.magic = cpu_to_be16(from->magic);
> +		to3->hdr.__count = cpu_to_be16(from->count);
> +		to3->hdr.__level = cpu_to_be16(from->level);
> +	} else {
> +		ASSERT(from->magic == XFS_DA_NODE_MAGIC);
> +		to->hdr.info.forw = cpu_to_be32(from->forw);
> +		to->hdr.info.back = cpu_to_be32(from->back);
> +		to->hdr.info.magic = cpu_to_be16(from->magic);
> +		to->hdr.__count = cpu_to_be16(from->count);
> +		to->hdr.__level = cpu_to_be16(from->level);
> +	}
> +}
> +
>  /*
>   * Verify an xfs_da3_blkinfo structure. Note that the da3 fields are only
>   * accessible on v5 filesystems. This header format is common across da node,
> @@ -385,7 +410,7 @@ xfs_da3_node_create(
>  	}
>  	ichdr.level = level;
>  
> -	dp->d_ops->node_hdr_to_disk(node, &ichdr);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node, &ichdr);
>  	xfs_trans_log_buf(tp, bp,
>  		XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
>  
> @@ -666,7 +691,7 @@ xfs_da3_root_split(
>  	btree[1].hashval = cpu_to_be32(blk2->hashval);
>  	btree[1].before = cpu_to_be32(blk2->blkno);
>  	nodehdr.count = 2;
> -	dp->d_ops->node_hdr_to_disk(node, &nodehdr);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
>  
>  #ifdef DEBUG
>  	if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
> @@ -891,11 +916,11 @@ xfs_da3_node_rebalance(
>  	/*
>  	 * Log header of node 1 and all current bits of node 2.
>  	 */
> -	dp->d_ops->node_hdr_to_disk(node1, &nodehdr1);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node1, &nodehdr1);
>  	xfs_trans_log_buf(tp, blk1->bp,
>  		XFS_DA_LOGRANGE(node1, &node1->hdr, dp->d_ops->node_hdr_size));
>  
> -	dp->d_ops->node_hdr_to_disk(node2, &nodehdr2);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node2, &nodehdr2);
>  	xfs_trans_log_buf(tp, blk2->bp,
>  		XFS_DA_LOGRANGE(node2, &node2->hdr,
>  				dp->d_ops->node_hdr_size +
> @@ -967,7 +992,7 @@ xfs_da3_node_add(
>  				tmp + sizeof(*btree)));
>  
>  	nodehdr.count += 1;
> -	dp->d_ops->node_hdr_to_disk(node, &nodehdr);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
>  	xfs_trans_log_buf(state->args->trans, oldblk->bp,
>  		XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
>  
> @@ -1403,7 +1428,7 @@ xfs_da3_node_remove(
>  	xfs_trans_log_buf(state->args->trans, drop_blk->bp,
>  	    XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));
>  	nodehdr.count -= 1;
> -	dp->d_ops->node_hdr_to_disk(node, &nodehdr);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
>  	xfs_trans_log_buf(state->args->trans, drop_blk->bp,
>  	    XFS_DA_LOGRANGE(node, &node->hdr, dp->d_ops->node_hdr_size));
>  
> @@ -1475,7 +1500,7 @@ xfs_da3_node_unbalance(
>  	memcpy(&save_btree[sindex], &drop_btree[0], tmp);
>  	save_hdr.count += drop_hdr.count;
>  
> -	dp->d_ops->node_hdr_to_disk(save_node, &save_hdr);
> +	xfs_da3_node_hdr_to_disk(dp->i_mount, save_node, &save_hdr);
>  	xfs_trans_log_buf(tp, save_blk->bp,
>  		XFS_DA_LOGRANGE(save_node, &save_node->hdr,
>  				dp->d_ops->node_hdr_size));
> diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
> index eb15b9e76bc8..69ebf6a50d85 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.h
> +++ b/fs/xfs/libxfs/xfs_da_btree.h
> @@ -217,6 +217,8 @@ void xfs_da_state_free(xfs_da_state_t *state);
>  
>  void	xfs_da3_node_hdr_from_disk(struct xfs_mount *mp,
>  		struct xfs_da3_icnode_hdr *to, struct xfs_da_intnode *from);
> +void	xfs_da3_node_hdr_to_disk(struct xfs_mount *mp,
> +		struct xfs_da_intnode *to, struct xfs_da3_icnode_hdr *from);
>  
>  extern struct kmem_zone *xfs_da_state_zone;
>  extern const struct xfs_nameops xfs_default_nameops;
> diff --git a/fs/xfs/libxfs/xfs_da_format.c b/fs/xfs/libxfs/xfs_da_format.c
> index 267aca857126..912096416a86 100644
> --- a/fs/xfs/libxfs/xfs_da_format.c
> +++ b/fs/xfs/libxfs/xfs_da_format.c
> @@ -510,35 +510,6 @@ xfs_da3_node_tree_p(struct xfs_da_intnode *dap)
>  	return ((struct xfs_da3_intnode *)dap)->__btree;
>  }
>  
> -static void
> -xfs_da2_node_hdr_to_disk(
> -	struct xfs_da_intnode		*to,
> -	struct xfs_da3_icnode_hdr	*from)
> -{
> -	ASSERT(from->magic == XFS_DA_NODE_MAGIC);
> -	to->hdr.info.forw = cpu_to_be32(from->forw);
> -	to->hdr.info.back = cpu_to_be32(from->back);
> -	to->hdr.info.magic = cpu_to_be16(from->magic);
> -	to->hdr.__count = cpu_to_be16(from->count);
> -	to->hdr.__level = cpu_to_be16(from->level);
> -}
> -
> -static void
> -xfs_da3_node_hdr_to_disk(
> -	struct xfs_da_intnode		*to,
> -	struct xfs_da3_icnode_hdr	*from)
> -{
> -	struct xfs_da3_node_hdr *hdr3 = (struct xfs_da3_node_hdr *)to;
> -
> -	ASSERT(from->magic == XFS_DA3_NODE_MAGIC);
> -	hdr3->info.hdr.forw = cpu_to_be32(from->forw);
> -	hdr3->info.hdr.back = cpu_to_be32(from->back);
> -	hdr3->info.hdr.magic = cpu_to_be16(from->magic);
> -	hdr3->__count = cpu_to_be16(from->count);
> -	hdr3->__level = cpu_to_be16(from->level);
> -}
> -
> -
>  /*
>   * Directory free space block operations
>   */
> @@ -698,7 +669,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
>  	.leaf_ents_p = xfs_dir2_leaf_ents_p,
>  
>  	.node_hdr_size = sizeof(struct xfs_da_node_hdr),
> -	.node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
>  	.node_tree_p = xfs_da2_node_tree_p,
>  
>  	.free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
> @@ -747,7 +717,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
>  	.leaf_ents_p = xfs_dir2_leaf_ents_p,
>  
>  	.node_hdr_size = sizeof(struct xfs_da_node_hdr),
> -	.node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
>  	.node_tree_p = xfs_da2_node_tree_p,
>  
>  	.free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
> @@ -796,7 +765,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
>  	.leaf_ents_p = xfs_dir3_leaf_ents_p,
>  
>  	.node_hdr_size = sizeof(struct xfs_da3_node_hdr),
> -	.node_hdr_to_disk = xfs_da3_node_hdr_to_disk,
>  	.node_tree_p = xfs_da3_node_tree_p,
>  
>  	.free_hdr_size = sizeof(struct xfs_dir3_free_hdr),
> @@ -810,13 +778,11 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
>  
>  static const struct xfs_dir_ops xfs_dir2_nondir_ops = {
>  	.node_hdr_size = sizeof(struct xfs_da_node_hdr),
> -	.node_hdr_to_disk = xfs_da2_node_hdr_to_disk,
>  	.node_tree_p = xfs_da2_node_tree_p,
>  };
>  
>  static const struct xfs_dir_ops xfs_dir3_nondir_ops = {
>  	.node_hdr_size = sizeof(struct xfs_da3_node_hdr),
> -	.node_hdr_to_disk = xfs_da3_node_hdr_to_disk,
>  	.node_tree_p = xfs_da3_node_tree_p,
>  };
>  
> diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> index 573043f59c85..c16efeae0f2b 100644
> --- a/fs/xfs/libxfs/xfs_dir2.h
> +++ b/fs/xfs/libxfs/xfs_dir2.h
> @@ -82,8 +82,6 @@ struct xfs_dir_ops {
>  		(*leaf_ents_p)(struct xfs_dir2_leaf *lp);
>  
>  	int	node_hdr_size;
> -	void	(*node_hdr_to_disk)(struct xfs_da_intnode *to,
> -				    struct xfs_da3_icnode_hdr *from);
>  	struct xfs_da_node_entry *
>  		(*node_tree_p)(struct xfs_da_intnode *dap);
>  
> -- 
> 2.20.1
> 

  reply	other threads:[~2019-11-04 18:40 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 22:06 remove m_dirops Christoph Hellwig
2019-11-01 22:06 ` [PATCH 01/34] xfs: move incore structures out of xfs_da_format.h Christoph Hellwig
2019-11-04 18:21   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 02/34] xfs: refactor btree node scrubbing Christoph Hellwig
2019-11-04 18:36   ` Darrick J. Wong
2019-11-05  1:35     ` Christoph Hellwig
2019-11-01 22:06 ` [PATCH 03/34] xfs: devirtualize ->node_hdr_from_disk Christoph Hellwig
2019-11-04 18:37   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 04/34] xfs: devirtualize ->node_hdr_to_disk Christoph Hellwig
2019-11-04 18:39   ` Darrick J. Wong [this message]
2019-11-01 22:06 ` [PATCH 05/34] xfs: add a btree entries pointer to struct xfs_da3_icnode_hdr Christoph Hellwig
2019-11-04 19:52   ` Darrick J. Wong
2019-11-05  1:38     ` Christoph Hellwig
2019-11-05  1:58       ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 06/34] xfs: move the node header size to struct xfs_da_geometry Christoph Hellwig
2019-11-04 19:58   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 07/34] xfs: devirtualize ->leaf_hdr_from_disk Christoph Hellwig
2019-11-04 19:59   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 08/34] xfs: devirtualize ->leaf_hdr_to_disk Christoph Hellwig
2019-11-04 20:00   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 09/34] xfs: add a entries pointer to struct xfs_dir3_icleaf_hdr Christoph Hellwig
2019-11-04 20:04   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 10/34] xfs: move the dir2 leaf header size to struct xfs_da_geometry Christoph Hellwig
2019-11-04 20:05   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 11/34] xfs: move the max dir2 leaf entries count " Christoph Hellwig
2019-11-04 20:07   ` Darrick J. Wong
2019-11-05  1:42     ` Christoph Hellwig
2019-11-05  1:58       ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 12/34] xfs: devirtualize ->free_hdr_from_disk Christoph Hellwig
2019-11-04 20:08   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 13/34] xfs: devirtualize ->free_hdr_to_disk Christoph Hellwig
2019-11-04 20:08   ` Darrick J. Wong
2019-11-01 22:06 ` [PATCH 14/34] xfs: make the xfs_dir3_icfree_hdr available to xfs_dir2_node_addname_int Christoph Hellwig
2019-11-04 20:25   ` Darrick J. Wong
2019-11-05  1:52     ` Christoph Hellwig
2019-11-05  1:59       ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 15/34] xfs: add a bests pointer to struct xfs_dir3_icfree_hdr Christoph Hellwig
2019-11-04 20:21   ` Darrick J. Wong
2019-11-05  1:44     ` Christoph Hellwig
2019-11-05  2:05       ` Darrick J. Wong
2019-11-05 16:44         ` Christoph Hellwig
2019-11-01 22:07 ` [PATCH 16/34] xfs: move the dir2 free header size to struct xfs_da_geometry Christoph Hellwig
2019-11-04 20:22   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 17/34] xfs: move the max dir2 free bests count " Christoph Hellwig
2019-11-04 20:23   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 18/34] xfs: devirtualize ->db_to_fdb and ->db_to_fdindex Christoph Hellwig
2019-11-04 20:26   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 19/34] xfs: devirtualize ->sf_get_parent_ino and ->sf_put_parent_ino Christoph Hellwig
2019-11-04 20:26   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 20/34] xfs: devirtualize ->sf_entsize and ->sf_nextentry Christoph Hellwig
2019-11-04 20:28   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 21/34] xfs: devirtualize ->sf_get_ino and ->sf_put_ino Christoph Hellwig
2019-11-04 20:33   ` Darrick J. Wong
2019-11-07  1:05     ` Darrick J. Wong
2019-11-07  8:29       ` Christoph Hellwig
2019-11-01 22:07 ` [PATCH 22/34] xfs: devirtualize ->sf_get_ftype and ->sf_put_ftype Christoph Hellwig
2019-11-04 20:34   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 23/34] xfs: remove the ->data_dot_entry_p and ->data_dotdot_entry_p methods Christoph Hellwig
2019-11-04 20:37   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 24/34] xfs: remove the unused ->data_first_entry_p method Christoph Hellwig
2019-11-04 20:38   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 25/34] xfs: remove the ->data_entry_entry_p method Christoph Hellwig
2019-11-04 20:41   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 26/34] xfs: devirtualize ->data_entsize Christoph Hellwig
2019-11-04 20:45   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 27/34] xfs: devirtualize ->data_entry_tag_p Christoph Hellwig
2019-11-04 20:45   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 28/34] xfs: move the dir2 data block fixed offsets to struct xfs_da_geometry Christoph Hellwig
2019-11-04 20:46   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 29/34] xfs: cleanup xfs_dir2_data_entsize Christoph Hellwig
2019-11-04 20:48   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 30/34] xfs: devirtualize ->data_bestfree_p Christoph Hellwig
2019-11-04 20:49   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 31/34] xfs: devirtualize ->data_get_ftype and ->data_put_ftype Christoph Hellwig
2019-11-04 20:50   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 32/34] xfs: remove the now unused dir ops infrastructure Christoph Hellwig
2019-11-04 20:50   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 33/34] xfs: merge xfs_dir2_data_freescan and xfs_dir2_data_freescan_int Christoph Hellwig
2019-11-04 20:51   ` Darrick J. Wong
2019-11-01 22:07 ` [PATCH 34/34] xfs: always pass a valid hdr to xfs_dir3_leaf_check_int Christoph Hellwig
2019-11-04 20:53   ` 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=20191104183958.GE4153244@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --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).