All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, hch@infradead.org
Subject: Re: [PATCH 04/14] xfs: pass the goal of the incore inode walk to xfs_inode_walk()
Date: Wed, 2 Jun 2021 11:42:52 +1000	[thread overview]
Message-ID: <20210602014252.GL664593@dread.disaster.area> (raw)
In-Reply-To: <162259517467.662681.7329146794207007368.stgit@locust>

On Tue, Jun 01, 2021 at 05:52:54PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> As part of removing the indirect calls and radix tag implementation
> details from the incore inode walk loop, create an enum to represent the
> goal of the inode iteration.  More immediately, this separate removes
> the need for the "ICI_NOTAG" define which makes little sense.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/xfs_icache.c |   51 +++++++++++++++++++++++++++++++++++++--------------
>  fs/xfs/xfs_icache.h |    9 ---------
>  2 files changed, 37 insertions(+), 23 deletions(-)
> 
> 
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index e70ce7868444..018b3f8bdd21 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -26,12 +26,35 @@
>  
>  #include <linux/iversion.h>
>  
> +/* Radix tree tags for incore inode tree. */
> +
> +/* inode is to be reclaimed */
> +#define XFS_ICI_RECLAIM_TAG	0
> +/* Inode has speculative preallocations (posteof or cow) to clean. */
> +#define XFS_ICI_BLOCKGC_TAG	1
> +
> +/*
> + * The goal for walking incore inodes.  These can correspond with incore inode
> + * radix tree tags when convenient.  Avoid existing XFS_IWALK namespace.
> + */
> +enum xfs_icwalk_goal {
> +	XFS_ICWALK_DQRELE	= -1,
> +	XFS_ICWALK_BLOCKGC	= XFS_ICI_BLOCKGC_TAG,
> +};
> +
> +/* Is there a radix tree tag for this goal? */
> +static inline bool
> +xfs_icwalk_tagged(enum xfs_icwalk_goal goal)
> +{
> +	return goal != XFS_ICWALK_DQRELE;
> +}

I think I'd rather the "non tag" types be explicitly defined to be
less than zero, and the tagged types be greater than zero and
(maybe) match the tag to be used for lookup. That way we end up
with:

static inline int
xfs_icwalk_tag(enum xfs_icwalk_goal goal)
{
	if (goal < 0)
		return -1;
	return goal;
}

And we have a mechanism that allows for us to have multiple goals
point at the same tag by replacing the 'return goal' with a switch
statement. THen...

> @@ -1650,7 +1673,7 @@ xfs_inode_walk_ag(
>  
>  		rcu_read_lock();
>  
> -		if (tag == XFS_ICI_NO_TAG)
> +		if (!xfs_icwalk_tagged(goal))
>  			nr_found = radix_tree_gang_lookup(&pag->pag_ici_root,
>  					(void **)batch, first_index,
>  					XFS_LOOKUP_BATCH);
> @@ -1658,7 +1681,7 @@ xfs_inode_walk_ag(
>  			nr_found = radix_tree_gang_lookup_tag(
>  					&pag->pag_ici_root,
>  					(void **) batch, first_index,
> -					XFS_LOOKUP_BATCH, tag);
> +					XFS_LOOKUP_BATCH, goal);

This becomes:

		tag = xfs_icwalk_tag(goal);
		if (tag < 0)
			/* do untagged lookup */
		else
			/* do tagged lookup w/ tag */
>  
>  		if (!nr_found) {
>  			rcu_read_unlock();
> @@ -1733,11 +1756,11 @@ static inline struct xfs_perag *
>  xfs_inode_walk_get_perag(
>  	struct xfs_mount	*mp,
>  	xfs_agnumber_t		agno,
> -	int			tag)
> +	enum xfs_icwalk_goal	goal)
>  {
> -	if (tag == XFS_ICI_NO_TAG)
> +	if (!xfs_icwalk_tagged(goal))
>  		return xfs_perag_get(mp, agno);
> -	return xfs_perag_get_tag(mp, agno, tag);
> +	return xfs_perag_get_tag(mp, agno, goal);
>  }
>  
>  /*
> @@ -1750,7 +1773,7 @@ xfs_inode_walk(
>  	int			iter_flags,
>  	int			(*execute)(struct xfs_inode *ip, void *args),
>  	void			*args,
> -	int			tag)
> +	enum xfs_icwalk_goal	goal)
>  {
>  	struct xfs_perag	*pag;
>  	int			error = 0;
> @@ -1758,9 +1781,9 @@ xfs_inode_walk(
>  	xfs_agnumber_t		ag;
>  
>  	ag = 0;
> -	while ((pag = xfs_inode_walk_get_perag(mp, ag, tag))) {
> +	while ((pag = xfs_inode_walk_get_perag(mp, ag, goal))) {
>  		ag = pag->pag_agno + 1;
> -		error = xfs_inode_walk_ag(pag, iter_flags, execute, args, tag);
> +		error = xfs_inode_walk_ag(pag, iter_flags, execute, args, goal);
>  		xfs_perag_put(pag);
>  		if (error) {
>  			last_error = error;

FYI, I'm soon going to be modifying this walk to separate it out
into for_each_perag() and for_each_perag_tagged() for shrink
protection. This becomes cleaner if we have a single xfs_icwalk_tag()
call here rather than hiding it inside xfs_inode_walk_get_perag().

Not something you need to address here, but I thought I'd mention
it so you can think about that while contemplating my suggestion
above...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2021-06-02  1:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  0:52 [PATCHSET v5 00/14] xfs: clean up incore inode walk functions Darrick J. Wong
2021-06-02  0:52 ` [PATCH 01/14] xfs: move the quotaoff dqrele inode walk into xfs_icache.c Darrick J. Wong
2021-06-02  1:23   ` Dave Chinner
2021-06-02  0:52 ` [PATCH 02/14] xfs: detach inode dquots at the end of inactivation Darrick J. Wong
2021-06-02  0:52 ` [PATCH 03/14] xfs: move the inode walk functions further down Darrick J. Wong
2021-06-02  1:26   ` Dave Chinner
2021-06-02  0:52 ` [PATCH 04/14] xfs: pass the goal of the incore inode walk to xfs_inode_walk() Darrick J. Wong
2021-06-02  1:42   ` Dave Chinner [this message]
2021-06-02  0:53 ` [PATCH 05/14] xfs: separate the dqrele_all inode grab logic from xfs_inode_walk_ag_grab Darrick J. Wong
2021-06-02  1:51   ` Dave Chinner
2021-06-02  3:28     ` Darrick J. Wong
2021-06-02  0:53 ` [PATCH 06/14] xfs: move xfs_inew_wait call into xfs_dqrele_inode Darrick J. Wong
2021-06-02  1:52   ` Dave Chinner
2021-06-02  0:53 ` [PATCH 07/14] xfs: remove iter_flags parameter from xfs_inode_walk_* Darrick J. Wong
2021-06-02  1:53   ` Dave Chinner
2021-06-02  0:53 ` [PATCH 08/14] xfs: remove indirect calls from xfs_inode_walk{,_ag} Darrick J. Wong
2021-06-02  2:00   ` Dave Chinner
2021-06-02  0:53 ` [PATCH 09/14] xfs: clean up the blockgc grab and scan calls a little Darrick J. Wong
2021-06-02  0:53 ` [PATCH 10/14] xfs: clean up xfs_dqrele_inode calling conventions Darrick J. Wong
2021-06-02  0:53 ` [PATCH 11/14] xfs: fix radix tree tag signs Darrick J. Wong
2021-06-02  2:02   ` Dave Chinner
2021-06-02  0:53 ` [PATCH 12/14] xfs: pass struct xfs_eofblocks to the inode scan callback Darrick J. Wong
2021-06-02  2:04   ` Dave Chinner
2021-06-02  6:15     ` Darrick J. Wong
2021-06-02  0:53 ` [PATCH 13/14] xfs: merge xfs_reclaim_inodes_ag into xfs_inode_walk_ag Darrick J. Wong
2021-06-02  2:10   ` Dave Chinner
2021-06-02  6:16     ` Darrick J. Wong
2021-06-02  0:53 ` [PATCH 14/14] xfs: refactor per-AG inode tagging functions Darrick J. Wong
2021-06-02  2:22   ` 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=20210602014252.GL664593@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --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.