Re: [PATCH 04/14] xfs: pass the goal of the incore inode walk to xfs_inode_walk()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 01, 2021 at 05:52:54PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux