From e26b3771ee43256a0347b7ec2503abbed7b5ecd5 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 27 Jun 2023 11:03:29 +1000 Subject: [PATCH] spa_preferred_class: pass the entire zio Rather than picking out specific values out of the properties, just pass the entire zio in, to make it easier in the future to use more of that info to decide on the storage class. I would have rathered just pass io_prop in, but having spa.h include zio.h gets a bit tricky. Reviewed-by: Alexander Motin Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Sponsored-by: Klara, Inc. Sponsored-by: iXsystems, Inc. Closes #15894 --- include/sys/spa.h | 3 +-- module/zfs/spa_misc.c | 13 ++++++++----- module/zfs/zio.c | 7 ++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/sys/spa.h b/include/sys/spa.h index 12321c6562..3998f5a6de 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -1049,8 +1049,7 @@ extern metaslab_class_t *spa_log_class(spa_t *spa); extern metaslab_class_t *spa_embedded_log_class(spa_t *spa); extern metaslab_class_t *spa_special_class(spa_t *spa); extern metaslab_class_t *spa_dedup_class(spa_t *spa); -extern metaslab_class_t *spa_preferred_class(spa_t *spa, uint64_t size, - dmu_object_type_t objtype, uint_t level, uint_t special_smallblk); +extern metaslab_class_t *spa_preferred_class(spa_t *spa, const zio_t *zio); extern boolean_t spa_special_has_ddt(spa_t *spa); extern void spa_evicting_os_register(spa_t *, objset_t *os); diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index 439e56f0d0..c9ee36c0f9 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -2007,9 +2007,11 @@ spa_special_has_ddt(spa_t *spa) * Locate an appropriate allocation class */ metaslab_class_t * -spa_preferred_class(spa_t *spa, uint64_t size, dmu_object_type_t objtype, - uint_t level, uint_t special_smallblk) +spa_preferred_class(spa_t *spa, const zio_t *zio) { + const zio_prop_t *zp = &zio->io_prop; + dmu_object_type_t objtype = zp->zp_type; + /* * ZIL allocations determine their class in zio_alloc_zil(). */ @@ -2027,14 +2029,15 @@ spa_preferred_class(spa_t *spa, uint64_t size, dmu_object_type_t objtype, } /* Indirect blocks for user data can land in special if allowed */ - if (level > 0 && (DMU_OT_IS_FILE(objtype) || objtype == DMU_OT_ZVOL)) { + if (zp->zp_level > 0 && + (DMU_OT_IS_FILE(objtype) || objtype == DMU_OT_ZVOL)) { if (has_special_class && zfs_user_indirect_is_special) return (spa_special_class(spa)); else return (spa_normal_class(spa)); } - if (DMU_OT_IS_METADATA(objtype) || level > 0) { + if (DMU_OT_IS_METADATA(objtype) || zp->zp_level > 0) { if (has_special_class) return (spa_special_class(spa)); else @@ -2047,7 +2050,7 @@ spa_preferred_class(spa_t *spa, uint64_t size, dmu_object_type_t objtype, * zfs_special_class_metadata_reserve_pct exclusively for metadata. */ if (DMU_OT_IS_FILE(objtype) && - has_special_class && size <= special_smallblk) { + has_special_class && zio->io_size <= zp->zp_zpl_smallblk) { metaslab_class_t *special = spa_special_class(spa); uint64_t alloc = metaslab_class_get_alloc(special); uint64_t space = metaslab_class_get_space(special); diff --git a/module/zfs/zio.c b/module/zfs/zio.c index bc5a3c9b70..7810113737 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -3637,8 +3637,7 @@ zio_dva_throttle(zio_t *zio) metaslab_class_t *mc; /* locate an appropriate allocation class */ - mc = spa_preferred_class(spa, zio->io_size, zio->io_prop.zp_type, - zio->io_prop.zp_level, zio->io_prop.zp_zpl_smallblk); + mc = spa_preferred_class(spa, zio); if (zio->io_priority == ZIO_PRIORITY_SYNC_WRITE || !mc->mc_alloc_throttle_enabled || @@ -3710,9 +3709,7 @@ zio_dva_allocate(zio_t *zio) */ mc = zio->io_metaslab_class; if (mc == NULL) { - mc = spa_preferred_class(spa, zio->io_size, - zio->io_prop.zp_type, zio->io_prop.zp_level, - zio->io_prop.zp_zpl_smallblk); + mc = spa_preferred_class(spa, zio); zio->io_metaslab_class = mc; }