/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011, 2020 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2024 by Delphix. All rights reserved.
* Copyright (c) 2012 by Frederik Wessels. All rights reserved.
* Copyright (c) 2012 by Cyril Plisko. All rights reserved.
* Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved.
static zpool_compat_status_t zpool_do_load_compat(
const char *, boolean_t *);
+enum zpool_options {
+ ZPOOL_OPTION_POWER = 1024,
+ ZPOOL_OPTION_ALLOW_INUSE,
+ ZPOOL_OPTION_ALLOW_REPLICATION_MISMATCH,
+ ZPOOL_OPTION_ALLOW_ASHIFT_MISMATCH
+};
+
/*
* These libumem hooks provide a reasonable set of defaults for the allocator's
* debugging facilities.
{
switch (idx) {
case HELP_ADD:
- return (gettext("\tadd [-fgLnP] [-o property=value] "
+ return (gettext("\tadd [-afgLnP] [-o property=value] "
"<pool> <vdev> ...\n"));
case HELP_ATTACH:
return (gettext("\tattach [-fsw] [-o property=value] "
}
/*
- * zpool add [-fgLnP] [-o property=value] <pool> <vdev> ...
+ * zpool add [-afgLnP] [-o property=value] <pool> <vdev> ...
*
+ * -a Disable the ashift validation checks
* -f Force addition of devices, even if they appear in use
* -g Display guid for individual vdev name.
* -L Follow links when resolving vdev path name.
int
zpool_do_add(int argc, char **argv)
{
- boolean_t force = B_FALSE;
+ boolean_t check_replication = B_TRUE;
+ boolean_t check_inuse = B_TRUE;
boolean_t dryrun = B_FALSE;
+ boolean_t check_ashift = B_TRUE;
+ boolean_t force = B_FALSE;
int name_flags = 0;
int c;
nvlist_t *nvroot;
nvlist_t *props = NULL;
char *propval;
+ struct option long_options[] = {
+ {"allow-in-use", no_argument, NULL, ZPOOL_OPTION_ALLOW_INUSE},
+ {"allow-replication-mismatch", no_argument, NULL,
+ ZPOOL_OPTION_ALLOW_REPLICATION_MISMATCH},
+ {"allow-ashift-mismatch", no_argument, NULL,
+ ZPOOL_OPTION_ALLOW_ASHIFT_MISMATCH},
+ {0, 0, 0, 0}
+ };
+
/* check options */
- while ((c = getopt(argc, argv, "fgLno:P")) != -1) {
+ while ((c = getopt_long(argc, argv, "fgLno:P", long_options, NULL))
+ != -1) {
switch (c) {
case 'f':
force = B_TRUE;
case 'P':
name_flags |= VDEV_NAME_PATH;
break;
+ case ZPOOL_OPTION_ALLOW_INUSE:
+ check_inuse = B_FALSE;
+ break;
+ case ZPOOL_OPTION_ALLOW_REPLICATION_MISMATCH:
+ check_replication = B_FALSE;
+ break;
+ case ZPOOL_OPTION_ALLOW_ASHIFT_MISMATCH:
+ check_ashift = B_FALSE;
+ break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
usage(B_FALSE);
}
+ if (force) {
+ if (!check_inuse || !check_replication || !check_ashift) {
+ (void) fprintf(stderr, gettext("'-f' option is not "
+ "allowed with '--allow-replication-mismatch', "
+ "'--allow-ashift-mismatch', or "
+ "'--allow-in-use'\n"));
+ usage(B_FALSE);
+ }
+ check_inuse = B_FALSE;
+ check_replication = B_FALSE;
+ check_ashift = B_FALSE;
+ }
+
poolname = argv[0];
argc--;
}
/* pass off to make_root_vdev for processing */
- nvroot = make_root_vdev(zhp, props, force, !force, B_FALSE, dryrun,
- argc, argv);
+ nvroot = make_root_vdev(zhp, props, !check_inuse,
+ check_replication, B_FALSE, dryrun, argc, argv);
if (nvroot == NULL) {
zpool_close(zhp);
return (1);
ret = 0;
} else {
- ret = (zpool_add(zhp, nvroot) != 0);
+ ret = (zpool_add(zhp, nvroot, check_ashift) != 0);
}
nvlist_free(props);
return (ret);
}
-#define POWER_OPT 1024
/*
* zpool online [--power] <pool> <device> ...
int flags = 0;
boolean_t is_power_on = B_FALSE;
struct option long_options[] = {
- {"power", no_argument, NULL, POWER_OPT},
+ {"power", no_argument, NULL, ZPOOL_OPTION_POWER},
{0, 0, 0, 0}
};
case 'e':
flags |= ZFS_ONLINE_EXPAND;
break;
- case POWER_OPT:
+ case ZPOOL_OPTION_POWER:
is_power_on = B_TRUE;
break;
case '?':
boolean_t is_power_off = B_FALSE;
struct option long_options[] = {
- {"power", no_argument, NULL, POWER_OPT},
+ {"power", no_argument, NULL, ZPOOL_OPTION_POWER},
{0, 0, 0, 0}
};
case 't':
istmp = B_TRUE;
break;
- case POWER_OPT:
+ case ZPOOL_OPTION_POWER:
is_power_off = B_TRUE;
break;
case '?':
char *pool, *device;
struct option long_options[] = {
- {"power", no_argument, NULL, POWER_OPT},
+ {"power", no_argument, NULL, ZPOOL_OPTION_POWER},
{0, 0, 0, 0}
};
case 'X':
xtreme_rewind = B_TRUE;
break;
- case POWER_OPT:
+ case ZPOOL_OPTION_POWER:
is_power_on = B_TRUE;
break;
case '?':
char *cmd = NULL;
struct option long_options[] = {
- {"power", no_argument, NULL, POWER_OPT},
+ {"power", no_argument, NULL, ZPOOL_OPTION_POWER},
{0, 0, 0, 0}
};
case 'x':
cb.cb_explain = B_TRUE;
break;
- case POWER_OPT:
+ case ZPOOL_OPTION_POWER:
cb.cb_print_power = B_TRUE;
break;
case '?':
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2024 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
"log" : NULL, raidz_children, zs->zs_mirrors,
1);
- error = spa_vdev_add(spa, nvroot);
+ error = spa_vdev_add(spa, nvroot, B_FALSE);
fnvlist_free(nvroot);
switch (error) {
nvroot = make_vdev_root(NULL, NULL, NULL, ztest_opts.zo_vdev_size, 0,
class, raidz_children, zs->zs_mirrors, 1);
- error = spa_vdev_add(spa, nvroot);
+ error = spa_vdev_add(spa, nvroot, B_FALSE);
fnvlist_free(nvroot);
if (error == ENOSPC)
*/
nvlist_t *nvroot = make_vdev_root(NULL, aux, NULL,
(ztest_opts.zo_vdev_size * 5) / 4, 0, NULL, 0, 0, 1);
- error = spa_vdev_add(spa, nvroot);
+ error = spa_vdev_add(spa, nvroot, B_FALSE);
switch (error) {
case 0:
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2022 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2024 by Delphix. All rights reserved.
* Copyright Joyent, Inc.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2016, Intel Corporation.
EZFS_RESUME_EXISTS, /* Resume on existing dataset without force */
EZFS_SHAREFAILED, /* filesystem share failed */
EZFS_RAIDZ_EXPAND_IN_PROGRESS, /* a raidz is currently expanding */
+ EZFS_ASHIFT_MISMATCH, /* can't add vdevs with different ashifts */
EZFS_UNKNOWN
} zfs_error_t;
_LIBZFS_H int zpool_create(libzfs_handle_t *, const char *, nvlist_t *,
nvlist_t *, nvlist_t *);
_LIBZFS_H int zpool_destroy(zpool_handle_t *, const char *);
-_LIBZFS_H int zpool_add(zpool_handle_t *, nvlist_t *);
+_LIBZFS_H int zpool_add(zpool_handle_t *, nvlist_t *, boolean_t check_ashift);
typedef struct splitflags {
/* do not split, but return the config that would be split off */
/*
* 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 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013, 2017 Joyent, Inc. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
ZFS_ERR_RESUME_EXISTS,
ZFS_ERR_CRYPTO_NOTSUP,
ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS,
+ ZFS_ERR_ASHIFT_MISMATCH,
} zfs_errno_t;
/*
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2021 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2024 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright 2013 Saso Kiselkov. All rights reserved.
#define SPA_ASYNC_DETACH_SPARE 0x4000
/* device manipulation */
-extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot);
+extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot, boolean_t ashift_check);
extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot,
int replacing, int rebuild);
extern int spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid,
<var-decl name='prev' type-id='b03eadb4' visibility='default'/>
</data-member>
</class-decl>
- <class-decl name='list' size-in-bits='256' is-struct='yes' visibility='default' id='e824dae9'>
+ <class-decl name='list' size-in-bits='192' is-struct='yes' visibility='default' id='e824dae9'>
<data-member access='public' layout-offset-in-bits='0'>
- <var-decl name='list_size' type-id='b59d7dce' visibility='default'/>
- </data-member>
- <data-member access='public' layout-offset-in-bits='64'>
<var-decl name='list_offset' type-id='b59d7dce' visibility='default'/>
</data-member>
- <data-member access='public' layout-offset-in-bits='128'>
+ <data-member access='public' layout-offset-in-bits='64'>
<var-decl name='list_head' type-id='b0b5e45e' visibility='default'/>
</data-member>
</class-decl>
</function-type>
</abi-instr>
<abi-instr address-size='64' path='lib/libzfs/libzfs_crypto.c' language='LANG_C99'>
+ <array-type-def dimensions='1' type-id='38b51b3c' size-in-bits='832' id='02b72c00'>
+ <subrange length='13' type-id='7359adad' id='487fded1'/>
+ </array-type-def>
<array-type-def dimensions='1' type-id='fb7c6451' size-in-bits='256' id='64177143'>
<subrange length='32' type-id='7359adad' id='ae5bde82'/>
</array-type-def>
<class-decl name='_IO_codecvt' is-struct='yes' visibility='default' is-declaration-only='yes' id='a4036571'/>
<class-decl name='_IO_marker' is-struct='yes' visibility='default' is-declaration-only='yes' id='010ae0b9'/>
<class-decl name='_IO_wide_data' is-struct='yes' visibility='default' is-declaration-only='yes' id='79bd3751'/>
+ <class-decl name='__locale_data' is-struct='yes' visibility='default' is-declaration-only='yes' id='23de8b96'/>
+ <array-type-def dimensions='1' type-id='80f4b756' size-in-bits='832' id='39e6f84a'>
+ <subrange length='13' type-id='7359adad' id='487fded1'/>
+ </array-type-def>
<array-type-def dimensions='1' type-id='95e97e5e' size-in-bits='896' id='47394ee0'>
<subrange length='28' type-id='7359adad' id='3db583d7'/>
</array-type-def>
<typedef-decl name='__clock_t' type-id='bd54fe1a' id='4d66c6d7'/>
<typedef-decl name='__ssize_t' type-id='bd54fe1a' id='41060289'/>
<typedef-decl name='FILE' type-id='ec1ed955' id='aa12d1ba'/>
+ <class-decl name='__locale_struct' size-in-bits='1856' is-struct='yes' visibility='default' id='90cc1ce3'>
+ <data-member access='public' layout-offset-in-bits='0'>
+ <var-decl name='__locales' type-id='02b72c00' visibility='default'/>
+ </data-member>
+ <data-member access='public' layout-offset-in-bits='832'>
+ <var-decl name='__ctype_b' type-id='31347b7a' visibility='default'/>
+ </data-member>
+ <data-member access='public' layout-offset-in-bits='896'>
+ <var-decl name='__ctype_tolower' type-id='6d60f45d' visibility='default'/>
+ </data-member>
+ <data-member access='public' layout-offset-in-bits='960'>
+ <var-decl name='__ctype_toupper' type-id='6d60f45d' visibility='default'/>
+ </data-member>
+ <data-member access='public' layout-offset-in-bits='1024'>
+ <var-decl name='__names' type-id='39e6f84a' visibility='default'/>
+ </data-member>
+ </class-decl>
+ <typedef-decl name='__locale_t' type-id='f01e1813' id='b7ac9b5f'/>
<class-decl name='__sigset_t' size-in-bits='1024' is-struct='yes' naming-typedef-id='b9c97942' visibility='default' id='2616147f'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='__val' type-id='d2baa450' visibility='default'/>
</data-member>
</union-decl>
<typedef-decl name='__sigval_t' type-id='a094b870' id='eabacd01'/>
+ <typedef-decl name='locale_t' type-id='b7ac9b5f' id='973a4f8d'/>
<class-decl name='siginfo_t' size-in-bits='1024' is-struct='yes' naming-typedef-id='cb681f62' visibility='default' id='d8149419'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='si_signo' type-id='95e97e5e' visibility='default'/>
<pointer-type-def type-id='bb4788fa' size-in-bits='64' id='cecf4ea7'/>
<pointer-type-def type-id='010ae0b9' size-in-bits='64' id='e4c6fa61'/>
<pointer-type-def type-id='79bd3751' size-in-bits='64' id='c65a1f29'/>
+ <pointer-type-def type-id='23de8b96' size-in-bits='64' id='38b51b3c'/>
+ <pointer-type-def type-id='90cc1ce3' size-in-bits='64' id='f01e1813'/>
<qualified-type-def type-id='9b23c9ad' restrict='yes' id='8c85230f'/>
<qualified-type-def type-id='80f4b756' restrict='yes' id='9d26089a'/>
<pointer-type-def type-id='80f4b756' size-in-bits='64' id='7d3cd834'/>
+ <qualified-type-def type-id='95e97e5e' const='yes' id='2448a865'/>
+ <pointer-type-def type-id='2448a865' size-in-bits='64' id='6d60f45d'/>
<qualified-type-def type-id='aca3bac8' const='yes' id='2498fd78'/>
<pointer-type-def type-id='2498fd78' size-in-bits='64' id='eed6c816'/>
<qualified-type-def type-id='eed6c816' restrict='yes' id='a431a9da'/>
<class-decl name='_IO_codecvt' is-struct='yes' visibility='default' is-declaration-only='yes' id='a4036571'/>
<class-decl name='_IO_marker' is-struct='yes' visibility='default' is-declaration-only='yes' id='010ae0b9'/>
<class-decl name='_IO_wide_data' is-struct='yes' visibility='default' is-declaration-only='yes' id='79bd3751'/>
+ <class-decl name='__locale_data' is-struct='yes' visibility='default' is-declaration-only='yes' id='23de8b96'/>
<function-decl name='zpool_get_prop_int' mangled-name='zpool_get_prop_int' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_get_prop_int'>
<parameter type-id='4c81de99'/>
<parameter type-id='5d0c23fb'/>
<function-decl name='dlerror' visibility='default' binding='global' size-in-bits='64'>
<return type-id='26a90f95'/>
</function-decl>
+ <function-decl name='uselocale' visibility='default' binding='global' size-in-bits='64'>
+ <parameter type-id='973a4f8d'/>
+ <return type-id='973a4f8d'/>
+ </function-decl>
<function-decl name='PKCS5_PBKDF2_HMAC_SHA1' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='80f4b756'/>
<parameter type-id='95e97e5e'/>
<parameter type-id='80f4b756'/>
<return type-id='26a90f95'/>
</function-decl>
- <function-decl name='strerror' visibility='default' binding='global' size-in-bits='64'>
+ <function-decl name='strerror_l' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='95e97e5e'/>
+ <parameter type-id='973a4f8d'/>
<return type-id='26a90f95'/>
</function-decl>
<function-decl name='tcgetattr' visibility='default' binding='global' size-in-bits='64'>
<qualified-type-def type-id='9c313c2d' const='yes' id='c3b7ba7d'/>
<pointer-type-def type-id='c3b7ba7d' size-in-bits='64' id='713a56f5'/>
<pointer-type-def type-id='01a1b934' size-in-bits='64' id='566b3f52'/>
+ <qualified-type-def type-id='566b3f52' restrict='yes' id='c878edd6'/>
+ <pointer-type-def type-id='566b3f52' size-in-bits='64' id='82d4e9e8'/>
+ <qualified-type-def type-id='82d4e9e8' restrict='yes' id='aa19c230'/>
<pointer-type-def type-id='7e291ce6' size-in-bits='64' id='ca64ff60'/>
<pointer-type-def type-id='9da381c4' size-in-bits='64' id='cb785ebf'/>
<pointer-type-def type-id='1b055409' size-in-bits='64' id='9d424d31'/>
<pointer-type-def type-id='8e0af06e' size-in-bits='64' id='053457bd'/>
<pointer-type-def type-id='857bb57e' size-in-bits='64' id='75be733c'/>
<pointer-type-def type-id='a63d15a3' size-in-bits='64' id='a195f4a3'/>
+ <qualified-type-def type-id='a195f4a3' restrict='yes' id='33518961'/>
+ <pointer-type-def type-id='a195f4a3' size-in-bits='64' id='e80ff3ab'/>
+ <qualified-type-def type-id='e80ff3ab' restrict='yes' id='8f2c7109'/>
<pointer-type-def type-id='eae6431d' size-in-bits='64' id='0d41d328'/>
<pointer-type-def type-id='7a6844eb' size-in-bits='64' id='18c91f9e'/>
<pointer-type-def type-id='dddf6ca2' size-in-bits='64' id='d915a820'/>
<parameter type-id='9d424d31'/>
<return type-id='95e97e5e'/>
</function-decl>
- <function-decl name='getgrnam' visibility='default' binding='global' size-in-bits='64'>
- <parameter type-id='80f4b756'/>
- <return type-id='566b3f52'/>
+ <function-decl name='getgrnam_r' visibility='default' binding='global' size-in-bits='64'>
+ <parameter type-id='9d26089a'/>
+ <parameter type-id='c878edd6'/>
+ <parameter type-id='266fe297'/>
+ <parameter type-id='b59d7dce'/>
+ <parameter type-id='aa19c230'/>
+ <return type-id='95e97e5e'/>
</function-decl>
<function-decl name='hasmntopt' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='48bea5ec'/>
<parameter type-id='18c91f9e'/>
<return type-id='95e97e5e'/>
</function-decl>
- <function-decl name='getpwnam' visibility='default' binding='global' size-in-bits='64'>
- <parameter type-id='80f4b756'/>
- <return type-id='a195f4a3'/>
+ <function-decl name='getpwnam_r' visibility='default' binding='global' size-in-bits='64'>
+ <parameter type-id='9d26089a'/>
+ <parameter type-id='33518961'/>
+ <parameter type-id='266fe297'/>
+ <parameter type-id='b59d7dce'/>
+ <parameter type-id='8f2c7109'/>
+ <return type-id='95e97e5e'/>
</function-decl>
<function-decl name='strtol' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='9d26089a'/>
<function-decl name='zpool_add' mangled-name='zpool_add' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_add'>
<parameter type-id='4c81de99' name='zhp'/>
<parameter type-id='5ce45b60' name='nvroot'/>
+ <parameter type-id='c19b74c3' name='ashift_check'/>
<return type-id='95e97e5e'/>
</function-decl>
<function-decl name='zpool_export' mangled-name='zpool_export' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zpool_export'>
<enumerator name='LZC_SEND_FLAG_RAW' value='8'/>
<enumerator name='LZC_SEND_FLAG_SAVED' value='16'/>
</enum-decl>
- <class-decl name='ddt_key' size-in-bits='320' is-struct='yes' visibility='default' id='e0a4a1cb'>
+ <class-decl name='ddt_key_t' size-in-bits='320' is-struct='yes' naming-typedef-id='67f6d2cf' visibility='default' id='5fae1718'>
<data-member access='public' layout-offset-in-bits='0'>
<var-decl name='ddk_cksum' type-id='39730d0b' visibility='default'/>
</data-member>
<var-decl name='ddk_prop' type-id='9c313c2d' visibility='default'/>
</data-member>
</class-decl>
- <typedef-decl name='ddt_key_t' type-id='e0a4a1cb' id='67f6d2cf'/>
+ <typedef-decl name='ddt_key_t' type-id='5fae1718' id='67f6d2cf'/>
<enum-decl name='dmu_object_type' id='04b3b0b9'>
<underlying-type type-id='9cac1fee'/>
<enumerator name='DMU_OT_NONE' value='0'/>
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* 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 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
* Copyright (c) 2018 Datto Inc.
* Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
* necessary verification to ensure that the vdev specification is well-formed.
*/
int
-zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
+zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot, boolean_t check_ashift)
{
zfs_cmd_t zc = {"\0"};
int ret;
zcmd_write_conf_nvlist(hdl, &zc, nvroot);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
+ zc.zc_flags = check_ashift;
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_ADD, &zc) != 0) {
switch (errno) {
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2020 Joyent, Inc. All rights reserved.
- * Copyright (c) 2011, 2020 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2024 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
* Copyright (c) 2017 Datto Inc.
* Copyright (c) 2020 The FreeBSD Foundation
"dataset without force"));
case EZFS_RAIDZ_EXPAND_IN_PROGRESS:
return (dgettext(TEXT_DOMAIN, "raidz expansion in progress"));
+ case EZFS_ASHIFT_MISMATCH:
+ return (dgettext(TEXT_DOMAIN, "adding devices with "
+ "different physical sector sizes is not allowed"));
case EZFS_UNKNOWN:
return (dgettext(TEXT_DOMAIN, "unknown error"));
default:
case ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS:
zfs_verror(hdl, EZFS_RAIDZ_EXPAND_IN_PROGRESS, fmt, ap);
break;
+ case ZFS_ERR_ASHIFT_MISMATCH:
+ zfs_verror(hdl, EZFS_ASHIFT_MISMATCH, fmt, ap);
+ break;
default:
zfs_error_aux(hdl, "%s", zfs_strerror(error));
zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap);
.\" Copyright (c) 2018 George Melikov. All Rights Reserved.
.\" Copyright 2017 Nexenta Systems, Inc.
.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
+.\" Copyright (c) 2024 by Delphix. All Rights Reserved.
.\"
-.Dd March 16, 2022
+.Dd March 8, 2024
.Dt ZPOOL-ADD 8
.Os
.
.Nm zpool
.Cm add
.Op Fl fgLnP
+.Op Fl -allow-in-use -allow-replication-mismatch -allow-ashift-mismatch
.Oo Fl o Ar property Ns = Ns Ar value Oc
.Ar pool vdev Ns …
.
.It Fl f
Forces use of
.Ar vdev Ns s ,
-even if they appear in use or specify a conflicting replication level.
+even if they appear in use, have conflicting ashift values, or specify
+a conflicting replication level.
Not all devices can be overridden in this manner.
.It Fl g
Display
manual page for a list of valid properties that can be set.
The only property supported at the moment is
.Sy ashift .
+.It Fl -allow-ashift-mismatch
+Disable the ashift validation which allows mismatched ashift values in the
+pool.
+Adding top-level
+.Ar vdev Ns s
+with different sector sizes will prohibit future device removal operations, see
+.Xr zpool-remove 8 .
+.It Fl -allow-in-use
+Allow vdevs to be added even if they might be in use in another pool.
+.It Fl -allow-replication-mismatch
+Allow vdevs with conflicting replication levels to be added to the pool.
.El
.
.Sh EXAMPLES
/*
* 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.
* 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;
}
}
+ 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);
* 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]
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);
tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos',
'zpool_add_004_pos', 'zpool_add_006_pos', 'zpool_add_007_neg',
'zpool_add_008_neg', 'zpool_add_009_neg', 'zpool_add_010_pos',
- 'add-o_ashift', 'add_prop_ashift', 'zpool_add_dryrun_output']
+ 'add-o_ashift', 'add_prop_ashift', 'zpool_add_dryrun_output',
+ 'zpool_add--allow-ashift-mismatch']
tags = ['functional', 'cli_root', 'zpool_add']
[tests/functional/cli_root/zpool_attach]
functional/cli_root/zpool_add/add_prop_ashift.ksh \
functional/cli_root/zpool_add/cleanup.ksh \
functional/cli_root/zpool_add/setup.ksh \
+ functional/cli_root/zpool_add/zpool_add--allow-ashift-mismatch.ksh \
functional/cli_root/zpool_add/zpool_add_001_pos.ksh \
functional/cli_root/zpool_add/zpool_add_002_pos.ksh \
functional/cli_root/zpool_add/zpool_add_003_pos.ksh \
#
# Copyright 2017, loli10K. All rights reserved.
-# Copyright (c) 2020 by Delphix. All rights reserved.
+# Copyright (c) 2020, 2024 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
logical_ashift=$(get_tunable VDEV_FILE_LOGICAL_ASHIFT)
orig_ashift=$(get_tunable VDEV_FILE_PHYSICAL_ASHIFT)
max_auto_ashift=$(get_tunable VDEV_MAX_AUTO_ASHIFT)
+opt=""
typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
for ashift in ${ashifts[@]}
do
+ #
+ # Need to add the --allow-ashift-mismatch option to disable the
+ # ashift mismatch checks in zpool add.
+ #
+ if [[ $ashift -eq $orig_ashift ]]; then
+ opt=""
+ else
+ opt="--allow-ashift-mismatch"
+ fi
+
log_must zpool create $TESTPOOL $disk1
- log_must zpool add -o ashift=$ashift $TESTPOOL $disk2
+ log_must zpool add $opt -o ashift=$ashift $TESTPOOL $disk2
log_must verify_ashift $disk2 $ashift
# clean things for the next run
#
log_must zpool create $TESTPOOL $disk1
log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT $ashift
- log_must zpool add $TESTPOOL $disk2
+ log_must zpool add $opt $TESTPOOL $disk2
exp=$(( (ashift <= max_auto_ashift) ? ashift : logical_ashift ))
log_must verify_ashift $disk2 $exp
#
# Copyright 2017, loli10K. All rights reserved.
-# Copyright (c) 2020 by Delphix. All rights reserved.
+# Copyright (c) 2020, 2024 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
for ashift in ${ashifts[@]}
do
+ if [ $ashift -eq $orig_ashift ];then
+ opt=""
+ else
+ opt="--allow-ashift-mismatch"
+ fi
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
- log_must zpool add $TESTPOOL $disk2
+ log_must zpool add $opt $TESTPOOL $disk2
log_must verify_ashift $disk2 $ashift
# clean things for the next run
do
for cmdval in ${ashifts[@]}
do
+ if [ $ashift -eq $cmdval ];then
+ opt=""
+ else
+ opt="--allow-ashift-mismatch"
+ fi
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
- log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2
+ log_must zpool add $opt -o ashift=$cmdval $TESTPOOL $disk2
log_must verify_ashift $disk2 $cmdval
# clean things for the next run
log_must zpool add -f $TESTPOOL $DISK2
log_must vdevs_in_pool $TESTPOOL $DISK2
+log_must zpool destroy $TESTPOOL
+
+create_pool $TESTPOOL mirror $DISK0 $DISK1
+log_must poolexists $TESTPOOL
+
+log_mustnot zpool add $TESTPOOL $DISK2
+log_mustnot vdevs_in_pool $TESTPOOL $DISK2
+
+log_must zpool add --allow-replication-mismatch $TESTPOOL $DISK2
+log_must vdevs_in_pool $TESTPOOL $DISK2
+
log_pass "'zpool add -f <pool> <vdev> ...' executes successfully."
recursive=$(get_tunable VOL_RECURSIVE)
log_must set_tunable64 VOL_RECURSIVE 1
fi
-log_must zpool add $TESTPOOL $ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL
+log_must zpool add --allow-ashift-mismatch $TESTPOOL $ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL
log_must vdevs_in_pool "$TESTPOOL" "$ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL"
unset NOINUSE_CHECK
log_mustnot zpool add -f $TESTPOOL $DISK1
+log_mustnot zpool add --allow-in-use $TESTPOOL $DISK1
log_mustnot zpool add -f $TESTPOOL $mnttab_dev
+log_mustnot zpool add --allow-in-use $TESTPOOL $mnttab_dev
if is_linux; then
log_mustnot zpool add $TESTPOOL $vfstab_dev
else
for type in "" "mirror" "raidz" "draid" "spare" "log" "dedup" "special" "cache"
do
log_mustnot zpool add -f $TESTPOOL $type $DISK0 $DISK1
+ log_mustnot zpool add --allow-in-use $TESTPOOL $type $DISK0 $DISK1
log_mustnot zpool add -f $TESTPOOL $type $DISK1 $DISK1
+ log_mustnot zpool add --allow-in-use $TESTPOOL $type $DISK1 $DISK1
done
log_pass "'zpool add' get fail as expected if vdevs are the same or vdev is " \
while ((j < ${#add_args[@]})); do
log_must zpool create $TESTPOOL1 ${create_args[$i]}
log_mustnot zpool add $TESTPOOL1 ${add_args[$j]}
- log_must zpool add -f $TESTPOOL1 ${add_args[$j]}
+ log_must zpool add --allow-replication-mismatch $TESTPOOL1 ${add_args[$j]}
log_must zpool destroy -f $TESTPOOL1
((j += 1))