From f8020c936356b887ab1e03eba1a723f9dfda6eea Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 15 Dec 2020 13:55:44 -0500 Subject: Make metaslab class rotor and aliquot per-allocator. Metaslab rotor and aliquot are used to distribute workload between vdevs while keeping some locality for logically adjacent blocks. Once multiple allocators were introduced to separate allocation of different objects it does not make much sense for different allocators to write into different metaslabs of the same metaslab group (vdev) same time, competing for its resources. This change makes each allocator choose metaslab group independently, colliding with others only sporadically. Test including simultaneous write into 4 files with recordsize of 4KB on a striped pool of 30 disks on a system with 40 logical cores show reduction of vdev queue lock contention from 54 to 27% due to better load distribution. Unfortunately it won't help much ZVOLs yet since only one dataset/ZVOL is synced at a time, and so for the most part only one allocator is used, but it may improve later. While there, to reduce the number of pointer dereferences change per-allocator storage for metaslab classes and groups from several separate malloc()'s to variable length arrays at the ends of the original class and group structures. Reviewed-by: Brian Behlendorf Reviewed-by: Matthew Ahrens Signed-off-by: Alexander Motin Closes #11288 --- module/zfs/zio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'module/zfs/zio.c') diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 982940dbd..ba438353a 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -2783,8 +2783,8 @@ zio_write_gang_block(zio_t *pio) ASSERT(has_data); flags |= METASLAB_ASYNC_ALLOC; - VERIFY(zfs_refcount_held(&mc->mc_alloc_slots[pio->io_allocator], - pio)); + VERIFY(zfs_refcount_held(&mc->mc_allocator[pio->io_allocator]. + mca_alloc_slots, pio)); /* * The logical zio has already placed a reservation for @@ -4468,9 +4468,8 @@ zio_done(zio_t *zio) metaslab_group_alloc_verify(zio->io_spa, zio->io_bp, zio, zio->io_allocator); - VERIFY(zfs_refcount_not_held( - &zio->io_metaslab_class->mc_alloc_slots[zio->io_allocator], - zio)); + VERIFY(zfs_refcount_not_held(&zio->io_metaslab_class-> + mc_allocator[zio->io_allocator].mca_alloc_slots, zio)); } -- cgit v1.2.3