Skip to content

Commit

Permalink
Add kstats tracking gang allocations
Browse files Browse the repository at this point in the history
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Paul Dagnelie <[email protected]>
  • Loading branch information
Paul Dagnelie committed Jan 28, 2025
1 parent fe44c5a commit eb47f59
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ static const int zio_buf_debug_limit = 16384;
static const int zio_buf_debug_limit = 0;
#endif

typedef struct zio_stats {
kstat_named_t ziostat_gang_writes;
kstat_named_t ziostat_gang_multilevel;
} zio_stats_t;

static zio_stats_t zio_stats = {
{ "gang_writes", KSTAT_DATA_UINT64 },
{ "gang_multilevel", KSTAT_DATA_UINT64 },
};

#define ZIOSTAT_BUMP(stat) \
atomic_inc_64(&zio_stats.stat.value.ui64);

static kstat_t *zio_ksp;

static inline void __zio_execute(zio_t *zio);

static void zio_taskq_dispatch(zio_t *, zio_taskq_type_t, boolean_t);
Expand All @@ -158,6 +173,13 @@ zio_init(void)
sizeof (zio_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
zio_link_cache = kmem_cache_create("zio_link_cache",
sizeof (zio_link_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
zio_ksp = kstat_create("zfs", 0, "zio_stats",
"misc", KSTAT_TYPE_NAMED, sizeof (zio_stats) /
sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL);
if (zio_ksp != NULL) {
zio_ksp->ks_data = &zio_stats;
kstat_install(zio_ksp);
}

for (c = 0; c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; c++) {
size_t size = (c + 1) << SPA_MINBLOCKSHIFT;
Expand Down Expand Up @@ -286,6 +308,10 @@ zio_fini(void)
VERIFY3P(zio_data_buf_cache[i], ==, NULL);
}

if (zio_ksp != NULL) {
kstat_delete(zio_ksp);
zio_ksp = NULL;
}
kmem_cache_destroy(zio_link_cache);
kmem_cache_destroy(zio_cache);

Expand Down Expand Up @@ -4114,6 +4140,9 @@ zio_dva_allocate(zio_t *zio)
spa_name(spa), zio, (u_longlong_t)zio->io_size,
error);
}
ZIOSTAT_BUMP(ziostat_gang_writes);
if (flags & METASLAB_GANG_CHILD)
ZIOSTAT_BUMP(ziostat_gang_multilevel);
return (zio_write_gang_block(zio, mc));
}
if (error != 0) {
Expand Down

0 comments on commit eb47f59

Please sign in to comment.