From 8b27e08ed8c6d854ee3c398773407dfac24d7578 Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Thu, 9 Apr 2020 09:59:31 -0700 Subject: [PATCH] Add separate field for indicating that spa is in middle of split By default it's not possible to open a device already owned by an active vdev. It's necessary to make an exception to this for vdev split. The FreeBSD platform code will make an exception if spa_is splitting is set to to true. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Matt Macy Closes #10178 --- include/sys/spa_impl.h | 1 + module/zfs/spa.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/sys/spa_impl.h b/include/sys/spa_impl.h index e8806dda906a..6481d5397792 100644 --- a/include/sys/spa_impl.h +++ b/include/sys/spa_impl.h @@ -216,6 +216,7 @@ struct spa { spa_load_state_t spa_load_state; /* current load operation */ boolean_t spa_indirect_vdevs_loaded; /* mappings loaded? */ boolean_t spa_trust_config; /* do we trust vdev tree? */ + boolean_t spa_is_splitting; /* in the middle of a split? */ spa_config_source_t spa_config_source; /* where config comes from? */ uint64_t spa_import_flags; /* import specific flags */ spa_taskqs_t spa_zio_taskq[ZIO_TYPES][ZIO_TASKQ_TYPES]; diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 72a54ebcef2f..0d4646c15160 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -7477,6 +7477,7 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config, list_destroy(&vd_trim_list); newspa->spa_config_source = SPA_CONFIG_SRC_SPLIT; + newspa->spa_is_splitting = B_TRUE; /* create the new pool from the disks of the original pool */ error = spa_load(newspa, SPA_LOAD_IMPORT, SPA_IMPORT_ASSEMBLE); @@ -7554,6 +7555,7 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config, spa_history_log_internal(newspa, "split", NULL, "from pool %s", spa_name(spa)); + newspa->spa_is_splitting = B_FALSE; kmem_free(vml, children * sizeof (vdev_t *)); /* if we're not going to mount the filesystems in userland, export */