mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Add ashift validation when adding devices to a pool
Currently, zpool add allows users to add top-level vdevs that have different ashifts but doing so prevents users from being able to perform a top-level vdev removal. Often times consumers may not realize that they have mismatched ashifts until the top-level removal fails. This feature adds ashift validation to the zpool add command and will fail the operation if the sector size of the specified vdev does not match the existing pool. This behavior can be disabled by using the -f flag. In addition, new flags have been added to provide fine-grained control to disable specific checks. These flags are: --allow-in-use --allow-ashift-mismatch --allow-replicaton-mismatch The force flag will disable all of these checks. Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Mark Maybee <mmaybee@delphix.com> Signed-off-by: George Wilson <gwilson@delphix.com> Closes #15509
This commit is contained in:
+12
-2
@@ -21,7 +21,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2020 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2011, 2024 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2018, Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
||||
* Copyright 2013 Saso Kiselkov. All rights reserved.
|
||||
@@ -7083,7 +7083,7 @@ spa_draid_feature_incr(void *arg, dmu_tx_t *tx)
|
||||
* Add a device to a storage pool.
|
||||
*/
|
||||
int
|
||||
spa_vdev_add(spa_t *spa, nvlist_t *nvroot)
|
||||
spa_vdev_add(spa_t *spa, nvlist_t *nvroot, boolean_t check_ashift)
|
||||
{
|
||||
uint64_t txg, ndraid = 0;
|
||||
int error;
|
||||
@@ -7174,6 +7174,16 @@ spa_vdev_add(spa_t *spa, nvlist_t *nvroot)
|
||||
}
|
||||
}
|
||||
|
||||
if (check_ashift && spa->spa_max_ashift == spa->spa_min_ashift) {
|
||||
for (int c = 0; c < vd->vdev_children; c++) {
|
||||
tvd = vd->vdev_child[c];
|
||||
if (tvd->vdev_ashift != spa->spa_max_ashift) {
|
||||
return (spa_vdev_exit(spa, vd, txg,
|
||||
ZFS_ERR_ASHIFT_MISMATCH));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int c = 0; c < vd->vdev_children; c++) {
|
||||
tvd = vd->vdev_child[c];
|
||||
vdev_remove_child(vd, tvd);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* Copyright (c) 2014, 2016 Joyent, Inc. All rights reserved.
|
||||
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
|
||||
* Copyright (c) 2011, 2020 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2011, 2024 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
||||
* Copyright (c) 2013 Steven Hartland. All rights reserved.
|
||||
* Copyright (c) 2014 Integros [integros.com]
|
||||
@@ -1886,7 +1886,7 @@ zfs_ioc_vdev_add(zfs_cmd_t *zc)
|
||||
error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
|
||||
zc->zc_iflags, &config);
|
||||
if (error == 0) {
|
||||
error = spa_vdev_add(spa, config);
|
||||
error = spa_vdev_add(spa, config, zc->zc_flags);
|
||||
nvlist_free(config);
|
||||
}
|
||||
spa_close(spa, FTAG);
|
||||
|
||||
Reference in New Issue
Block a user