public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] xfs: remove metafile inodes from the active inode stat
Date: Thu, 5 Feb 2026 22:43:42 -0800	[thread overview]
Message-ID: <20260206064342.GX7712@frogsfrogsfrogs> (raw)
In-Reply-To: <20260202141502.378973-3-hch@lst.de>

On Mon, Feb 02, 2026 at 03:14:32PM +0100, Christoph Hellwig wrote:
> The active inode (or active vnode until recently) stat can get much larger
> than expected on file systems with a lot of metafile inodes like zoned
> file systems on SMR hard disks with 10.000s of rtg rmap inodes.
> 
> Remove all metafile inodes from the active counter to make it more useful
> to track actual workloads and add a separate counter for active metafile
> inodes.
> 
> This fixes xfs/177 on SMR hard drives.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok to me, though I wonder slightly about the atomicity of the
percpu counter inc/decrements.  But it's been that way for a long time
so

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_buf.c |  4 ++++
>  fs/xfs/libxfs/xfs_metafile.c  |  5 +++++
>  fs/xfs/xfs_icache.c           |  5 ++++-
>  fs/xfs/xfs_stats.c            | 11 ++++++++---
>  fs/xfs/xfs_stats.h            |  3 ++-
>  5 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index dcc9566ef5fe..91a499ced4e8 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -268,6 +268,10 @@ xfs_inode_from_disk(
>  	}
>  	if (xfs_is_reflink_inode(ip))
>  		xfs_ifork_init_cow(ip);
> +	if (xfs_is_metadir_inode(ip)) {
> +		XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
> +		XFS_STATS_INC(ip->i_mount, xs_inodes_meta);
> +	}
>  	return 0;
>  
>  out_destroy_data_fork:
> diff --git a/fs/xfs/libxfs/xfs_metafile.c b/fs/xfs/libxfs/xfs_metafile.c
> index cf239f862212..71f004e9dc64 100644
> --- a/fs/xfs/libxfs/xfs_metafile.c
> +++ b/fs/xfs/libxfs/xfs_metafile.c
> @@ -61,6 +61,9 @@ xfs_metafile_set_iflag(
>  	ip->i_diflags2 |= XFS_DIFLAG2_METADATA;
>  	ip->i_metatype = metafile_type;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
> +
> +	XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
> +	XFS_STATS_INC(ip->i_mount, xs_inodes_meta);
>  }
>  
>  /* Clear the metadata directory inode flag. */
> @@ -74,6 +77,8 @@ xfs_metafile_clear_iflag(
>  
>  	ip->i_diflags2 &= ~XFS_DIFLAG2_METADATA;
>  	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
> +	XFS_STATS_INC(ip->i_mount, xs_inodes_active);
> +	XFS_STATS_DEC(ip->i_mount, xs_inodes_meta);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index f76c6decdaa3..f2d4294efd37 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -172,7 +172,10 @@ __xfs_inode_free(
>  	/* asserts to verify all state is correct here */
>  	ASSERT(atomic_read(&ip->i_pincount) == 0);
>  	ASSERT(!ip->i_itemp || list_empty(&ip->i_itemp->ili_item.li_bio_list));
> -	XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
> +	if (xfs_is_metadir_inode(ip))
> +		XFS_STATS_DEC(ip->i_mount, xs_inodes_meta);
> +	else
> +		XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
>  
>  	call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
>  }
> diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
> index bc4a5d6dc795..c13d600732c9 100644
> --- a/fs/xfs/xfs_stats.c
> +++ b/fs/xfs/xfs_stats.c
> @@ -59,7 +59,8 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
>  		{ "rtrefcntbt",		xfsstats_offset(xs_qm_dqreclaims)},
>  		/* we print both series of quota information together */
>  		{ "qm",			xfsstats_offset(xs_gc_read_calls)},
> -		{ "zoned",		xfsstats_offset(__pad1)},
> +		{ "zoned",		xfsstats_offset(xs_inodes_meta)},
> +		{ "metafile",		xfsstats_offset(xs_xstrat_bytes)},
>  	};
>  
>  	/* Loop over all stats groups */
> @@ -99,16 +100,20 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
>  
>  void xfs_stats_clearall(struct xfsstats __percpu *stats)
>  {
> +	uint32_t	xs_inodes_active, xs_inodes_meta;
>  	int		c;
> -	uint32_t	xs_inodes_active;
>  
>  	xfs_notice(NULL, "Clearing xfsstats");
>  	for_each_possible_cpu(c) {
>  		preempt_disable();
> -		/* save xs_inodes_active, it's a universal truth! */
> +		/*
> +		 * Save the active / meta inode counters, as they are stateful.
> +		 */
>  		xs_inodes_active = per_cpu_ptr(stats, c)->s.xs_inodes_active;
> +		xs_inodes_meta = per_cpu_ptr(stats, c)->s.xs_inodes_meta;
>  		memset(per_cpu_ptr(stats, c), 0, sizeof(*stats));
>  		per_cpu_ptr(stats, c)->s.xs_inodes_active = xs_inodes_active;
> +		per_cpu_ptr(stats, c)->s.xs_inodes_meta = xs_inodes_meta;
>  		preempt_enable();
>  	}
>  }
> diff --git a/fs/xfs/xfs_stats.h b/fs/xfs/xfs_stats.h
> index 64bc0cc18126..57c32b86c358 100644
> --- a/fs/xfs/xfs_stats.h
> +++ b/fs/xfs/xfs_stats.h
> @@ -142,7 +142,8 @@ struct __xfsstats {
>  	uint32_t		xs_gc_read_calls;
>  	uint32_t		xs_gc_write_calls;
>  	uint32_t		xs_gc_zone_reset_calls;
> -	uint32_t		__pad1;
> +/* Metafile counters */
> +	uint32_t		xs_inodes_meta;
>  /* Extra precision counters */
>  	uint64_t		xs_xstrat_bytes;
>  	uint64_t		xs_write_bytes;
> -- 
> 2.47.3
> 
> 

  parent reply	other threads:[~2026-02-06  6:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02 14:14 fix inode stats with lots of metafiles Christoph Hellwig
2026-02-02 14:14 ` [PATCH 1/2] xfs: cleanup inode counter stats Christoph Hellwig
2026-02-03  6:16   ` Nirjhar Roy (IBM)
2026-02-03  6:47     ` Christoph Hellwig
2026-02-06  6:38   ` Darrick J. Wong
2026-02-02 14:14 ` [PATCH 2/2] xfs: remove metafile inodes from the active inode stat Christoph Hellwig
2026-02-03  7:11   ` Nirjhar Roy (IBM)
2026-02-03  7:14     ` Christoph Hellwig
2026-02-03  7:24       ` Nirjhar Roy (IBM)
2026-02-03  7:29         ` Christoph Hellwig
2026-02-06  6:43   ` Darrick J. Wong [this message]
2026-02-06  6:52     ` Christoph Hellwig
2026-02-25  9:38 ` fix inode stats with lots of metafiles Carlos Maiolino
  -- strict thread matches above, loose matches on Subject: below --
2026-02-24 13:59 fix inode stats with lots of metafiles v2 Christoph Hellwig
2026-02-24 13:59 ` [PATCH 2/2] xfs: remove metafile inodes from the active inode stat Christoph Hellwig

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=20260206064342.GX7712@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --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