BRT: Rework structures and locks to be per-vdev

While block cloning operation from the beginning was made per-vdev,
before this change most of its data were protected by two pool-
wide locks.  It created lots of lock contention in many workload.

This change makes most of block cloning data structures per-vdev,
which allows to lock them separately.  The only pool-wide lock now
it spa_brt_lock, protecting array of per-vdev pointers and in most
cases taken as reader.  Also this splits per-vdev locks into three
different ones: bv_pending_lock protects the AVL-tree of pending
operations in open context, bv_mos_entries_lock protects BRT ZAP
object from while being prefetched, and bv_lock protects the rest
of per-vdev context during TXG commit process.  There should be
no functional difference aside of some optimizations.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Pawel Jakub Dawidek <pjd@FreeBSD.org>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #16740
This commit is contained in:
Alexander Motin
2024-11-10 17:29:25 -05:00
committed by Brian Behlendorf
parent 309ce6303f
commit fd6e8c1d2a
6 changed files with 401 additions and 533 deletions
+332 -451
View File
File diff suppressed because it is too large Load Diff
+6 -11
View File
@@ -1870,13 +1870,7 @@ spa_get_slop_space(spa_t *spa)
if (spa->spa_dedup_dspace == ~0ULL)
spa_update_dspace(spa);
/*
* spa_get_dspace() includes the space only logically "used" by
* deduplicated data, so since it's not useful to reserve more
* space with more deduplicated data, we subtract that out here.
*/
space =
spa_get_dspace(spa) - spa->spa_dedup_dspace - brt_get_dspace(spa);
space = spa->spa_rdspace;
slop = MIN(space >> spa_slop_shift, spa_max_slop);
/*
@@ -1912,8 +1906,7 @@ spa_get_checkpoint_space(spa_t *spa)
void
spa_update_dspace(spa_t *spa)
{
spa->spa_dspace = metaslab_class_get_dspace(spa_normal_class(spa)) +
ddt_get_dedup_dspace(spa) + brt_get_dspace(spa);
spa->spa_rdspace = metaslab_class_get_dspace(spa_normal_class(spa));
if (spa->spa_nonallocating_dspace > 0) {
/*
* Subtract the space provided by all non-allocating vdevs that
@@ -1933,9 +1926,11 @@ spa_update_dspace(spa_t *spa)
* doesn't matter that the data we are moving may be
* allocated twice (on the old device and the new device).
*/
ASSERT3U(spa->spa_dspace, >=, spa->spa_nonallocating_dspace);
spa->spa_dspace -= spa->spa_nonallocating_dspace;
ASSERT3U(spa->spa_rdspace, >=, spa->spa_nonallocating_dspace);
spa->spa_rdspace -= spa->spa_nonallocating_dspace;
}
spa->spa_dspace = spa->spa_rdspace + ddt_get_dedup_dspace(spa) +
brt_get_dspace(spa);
}
/*