From 8508ff36afa875d33c5de9e252d47e905e726b02 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Fri, 28 Jun 2019 14:02:41 -0700 Subject: [PATCH] Don't activate metaslabs with weight 0 Signed-off-by: Paul Dagnelie --- module/zfs/metaslab.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c index a14057f89136..f9b02c6128ce 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -2485,6 +2485,18 @@ metaslab_activate(metaslab_t *msp, int allocator, uint64_t activation_weight) return (0); } + /* + * If the metaslab has literally 0 space, it will have weight 0. In + * that case, don't bother activating it. This can happen if the + * metaslab had space during find_valid_metaslab, but another thread + * loaded it and used all that space while we were waiting to grab the + * lock. + */ + if (msp->ms_weight == 0) { + ASSERT0(range_tree_space(msp->ms_allocatable)); + return (ENOSPC); + } + if ((error = metaslab_activate_allocator(msp->ms_group, msp, allocator, activation_weight)) != 0) { return (error);