OpenZFS 9738 - Fix third block copy allocations, broken at 9112.

Use METASLAB_WEIGHT_CLAIM weight to allocate tertiary blocks.
Previous use of METASLAB_WEIGHT_SECONDARY for that caused errors
later on metaslab_activate_allocator() call, leading to massive
load of unneeded metaslabs and write freezes.

Authored by: mav <mav@FreeBSD.org>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>

OpenZFS-issue: https://illumos.org/issues/9738
FreeBSD-commit: https://github.com/freebsd/freebsd/commit/63e7138
Closes #7858
This commit is contained in:
mav 2018-08-17 15:00:41 +00:00 committed by Brian Behlendorf
parent b83a0e2dc1
commit e38afd34c3

View File

@ -3035,7 +3035,6 @@ metaslab_group_alloc_normal(metaslab_group_t *mg, zio_alloc_list_t *zal,
metaslab_t *msp = NULL; metaslab_t *msp = NULL;
uint64_t offset = -1ULL; uint64_t offset = -1ULL;
uint64_t activation_weight; uint64_t activation_weight;
boolean_t tertiary = B_FALSE;
activation_weight = METASLAB_WEIGHT_PRIMARY; activation_weight = METASLAB_WEIGHT_PRIMARY;
for (int i = 0; i < d; i++) { for (int i = 0; i < d; i++) {
@ -3044,7 +3043,7 @@ metaslab_group_alloc_normal(metaslab_group_t *mg, zio_alloc_list_t *zal,
activation_weight = METASLAB_WEIGHT_SECONDARY; activation_weight = METASLAB_WEIGHT_SECONDARY;
} else if (activation_weight == METASLAB_WEIGHT_SECONDARY && } else if (activation_weight == METASLAB_WEIGHT_SECONDARY &&
DVA_GET_VDEV(&dva[i]) == mg->mg_vd->vdev_id) { DVA_GET_VDEV(&dva[i]) == mg->mg_vd->vdev_id) {
tertiary = B_TRUE; activation_weight = METASLAB_WEIGHT_CLAIM;
break; break;
} }
} }
@ -3053,10 +3052,8 @@ metaslab_group_alloc_normal(metaslab_group_t *mg, zio_alloc_list_t *zal,
* If we don't have enough metaslabs active to fill the entire array, we * If we don't have enough metaslabs active to fill the entire array, we
* just use the 0th slot. * just use the 0th slot.
*/ */
if (mg->mg_ms_ready < mg->mg_allocators * 2) { if (mg->mg_ms_ready < mg->mg_allocators * 3)
tertiary = B_FALSE;
allocator = 0; allocator = 0;
}
ASSERT3U(mg->mg_vd->vdev_ms_count, >=, 2); ASSERT3U(mg->mg_vd->vdev_ms_count, >=, 2);
@ -3082,7 +3079,7 @@ metaslab_group_alloc_normal(metaslab_group_t *mg, zio_alloc_list_t *zal,
msp = mg->mg_primaries[allocator]; msp = mg->mg_primaries[allocator];
was_active = B_TRUE; was_active = B_TRUE;
} else if (activation_weight == METASLAB_WEIGHT_SECONDARY && } else if (activation_weight == METASLAB_WEIGHT_SECONDARY &&
mg->mg_secondaries[allocator] != NULL && !tertiary) { mg->mg_secondaries[allocator] != NULL) {
msp = mg->mg_secondaries[allocator]; msp = mg->mg_secondaries[allocator];
was_active = B_TRUE; was_active = B_TRUE;
} else { } else {
@ -3125,7 +3122,8 @@ metaslab_group_alloc_normal(metaslab_group_t *mg, zio_alloc_list_t *zal,
continue; continue;
} }
if (msp->ms_weight & METASLAB_WEIGHT_CLAIM) { if (msp->ms_weight & METASLAB_WEIGHT_CLAIM &&
activation_weight != METASLAB_WEIGHT_CLAIM) {
metaslab_passivate(msp, msp->ms_weight & metaslab_passivate(msp, msp->ms_weight &
~METASLAB_WEIGHT_CLAIM); ~METASLAB_WEIGHT_CLAIM);
mutex_exit(&msp->ms_lock); mutex_exit(&msp->ms_lock);