Skip to content

Commit e33839b

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: add sysfs stats for zoned GC
Add counters of read, write and zone_reset operations as well as GC written bytes to sysfs. This way they can be easily used for monitoring tools and test cases. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent edf6078 commit e33839b

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

fs/xfs/xfs_stats.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
2424
uint64_t xs_write_bytes = 0;
2525
uint64_t xs_read_bytes = 0;
2626
uint64_t xs_defer_relog = 0;
27+
uint64_t xs_gc_bytes = 0;
2728

2829
static const struct xstats_entry {
2930
char *desc;
@@ -57,7 +58,8 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
5758
{ "rtrmapbt_mem", xfsstats_offset(xs_rtrefcbt_2) },
5859
{ "rtrefcntbt", xfsstats_offset(xs_qm_dqreclaims)},
5960
/* we print both series of quota information together */
60-
{ "qm", xfsstats_offset(xs_xstrat_bytes)},
61+
{ "qm", xfsstats_offset(xs_gc_read_calls)},
62+
{ "zoned", xfsstats_offset(__pad1)},
6163
};
6264

6365
/* Loop over all stats groups */
@@ -77,6 +79,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
7779
xs_write_bytes += per_cpu_ptr(stats, i)->s.xs_write_bytes;
7880
xs_read_bytes += per_cpu_ptr(stats, i)->s.xs_read_bytes;
7981
xs_defer_relog += per_cpu_ptr(stats, i)->s.xs_defer_relog;
82+
xs_gc_bytes += per_cpu_ptr(stats, i)->s.xs_gc_bytes;
8083
}
8184

8285
len += scnprintf(buf + len, PATH_MAX-len, "xpc %llu %llu %llu\n",
@@ -89,6 +92,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)
8992
#else
9093
0);
9194
#endif
95+
len += scnprintf(buf + len, PATH_MAX-len, "gc xpc %llu\n", xs_gc_bytes);
9296

9397
return len;
9498
}

fs/xfs/xfs_stats.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,17 @@ struct __xfsstats {
138138
uint32_t xs_qm_dqwants;
139139
uint32_t xs_qm_dquot;
140140
uint32_t xs_qm_dquot_unused;
141+
/* Zone GC counters */
142+
uint32_t xs_gc_read_calls;
143+
uint32_t xs_gc_write_calls;
144+
uint32_t xs_gc_zone_reset_calls;
145+
uint32_t __pad1;
141146
/* Extra precision counters */
142147
uint64_t xs_xstrat_bytes;
143148
uint64_t xs_write_bytes;
144149
uint64_t xs_read_bytes;
145150
uint64_t xs_defer_relog;
151+
uint64_t xs_gc_bytes;
146152
};
147153

148154
#define xfsstats_offset(f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t))

fs/xfs/xfs_zone_gc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,8 @@ xfs_zone_gc_start_chunk(
712712
data->scratch_head = (data->scratch_head + len) % data->scratch_size;
713713
data->scratch_available -= len;
714714

715+
XFS_STATS_INC(mp, xs_gc_read_calls);
716+
715717
WRITE_ONCE(chunk->state, XFS_GC_BIO_NEW);
716718
list_add_tail(&chunk->entry, &data->reading);
717719
xfs_zone_gc_iter_advance(iter, irec.rm_blockcount);
@@ -815,6 +817,9 @@ xfs_zone_gc_write_chunk(
815817
return;
816818
}
817819

820+
XFS_STATS_INC(mp, xs_gc_write_calls);
821+
XFS_STATS_ADD(mp, xs_gc_bytes, chunk->len);
822+
818823
WRITE_ONCE(chunk->state, XFS_GC_BIO_NEW);
819824
list_move_tail(&chunk->entry, &data->writing);
820825

@@ -911,6 +916,8 @@ xfs_submit_zone_reset_bio(
911916
return;
912917
}
913918

919+
XFS_STATS_INC(mp, xs_gc_zone_reset_calls);
920+
914921
bio->bi_iter.bi_sector = xfs_gbno_to_daddr(&rtg->rtg_group, 0);
915922
if (!bdev_zone_is_seq(bio->bi_bdev, bio->bi_iter.bi_sector)) {
916923
/*

0 commit comments

Comments
 (0)