From d8750b0adfaf55af4646a6fe52f645f8517fad26 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..51bddf8d9651 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 (SET_ERROR(ENOSPC)); + } + if ((error = metaslab_activate_allocator(msp->ms_group, msp, allocator, activation_weight)) != 0) { return (error);