Skip to content

Commit 47553dd

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: remove metafile inodes from the active inode stat
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> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 03a6d6c commit 47553dd

5 files changed

Lines changed: 23 additions & 5 deletions

File tree

fs/xfs/libxfs/xfs_inode_buf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ xfs_inode_from_disk(
268268
}
269269
if (xfs_is_reflink_inode(ip))
270270
xfs_ifork_init_cow(ip);
271+
if (xfs_is_metadir_inode(ip)) {
272+
XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
273+
XFS_STATS_INC(ip->i_mount, xs_inodes_meta);
274+
}
271275
return 0;
272276

273277
out_destroy_data_fork:

fs/xfs/libxfs/xfs_metafile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ xfs_metafile_set_iflag(
6161
ip->i_diflags2 |= XFS_DIFLAG2_METADATA;
6262
ip->i_metatype = metafile_type;
6363
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
64+
65+
XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
66+
XFS_STATS_INC(ip->i_mount, xs_inodes_meta);
6467
}
6568

6669
/* Clear the metadata directory inode flag. */
@@ -74,6 +77,8 @@ xfs_metafile_clear_iflag(
7477

7578
ip->i_diflags2 &= ~XFS_DIFLAG2_METADATA;
7679
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
80+
XFS_STATS_INC(ip->i_mount, xs_inodes_active);
81+
XFS_STATS_DEC(ip->i_mount, xs_inodes_meta);
7782
}
7883

7984
/*

fs/xfs/xfs_icache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ __xfs_inode_free(
172172
/* asserts to verify all state is correct here */
173173
ASSERT(atomic_read(&ip->i_pincount) == 0);
174174
ASSERT(!ip->i_itemp || list_empty(&ip->i_itemp->ili_item.li_bio_list));
175-
XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
175+
if (xfs_is_metadir_inode(ip))
176+
XFS_STATS_DEC(ip->i_mount, xs_inodes_meta);
177+
else
178+
XFS_STATS_DEC(ip->i_mount, xs_inodes_active);
176179

177180
call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
178181
}

fs/xfs/xfs_stats.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
5959
{ "rtrefcntbt", xfsstats_offset(xs_qm_dqreclaims)},
6060
/* we print both series of quota information together */
6161
{ "qm", xfsstats_offset(xs_gc_read_calls)},
62-
{ "zoned", xfsstats_offset(__pad1)},
62+
{ "zoned", xfsstats_offset(xs_inodes_meta)},
63+
{ "metafile", xfsstats_offset(xs_xstrat_bytes)},
6364
};
6465

6566
/* Loop over all stats groups */
@@ -99,16 +100,20 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
99100

100101
void xfs_stats_clearall(struct xfsstats __percpu *stats)
101102
{
103+
uint32_t xs_inodes_active, xs_inodes_meta;
102104
int c;
103-
uint32_t xs_inodes_active;
104105

105106
xfs_notice(NULL, "Clearing xfsstats");
106107
for_each_possible_cpu(c) {
107108
preempt_disable();
108-
/* save xs_inodes_active, it's a universal truth! */
109+
/*
110+
* Save the active / meta inode counters, as they are stateful.
111+
*/
109112
xs_inodes_active = per_cpu_ptr(stats, c)->s.xs_inodes_active;
113+
xs_inodes_meta = per_cpu_ptr(stats, c)->s.xs_inodes_meta;
110114
memset(per_cpu_ptr(stats, c), 0, sizeof(*stats));
111115
per_cpu_ptr(stats, c)->s.xs_inodes_active = xs_inodes_active;
116+
per_cpu_ptr(stats, c)->s.xs_inodes_meta = xs_inodes_meta;
112117
preempt_enable();
113118
}
114119
}

fs/xfs/xfs_stats.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ struct __xfsstats {
142142
uint32_t xs_gc_read_calls;
143143
uint32_t xs_gc_write_calls;
144144
uint32_t xs_gc_zone_reset_calls;
145-
uint32_t __pad1;
145+
/* Metafile counters */
146+
uint32_t xs_inodes_meta;
146147
/* Extra precision counters */
147148
uint64_t xs_xstrat_bytes;
148149
uint64_t xs_write_bytes;

0 commit comments

Comments
 (0)