Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "features" property for zpool feature sets. #10980

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
* Copyright (c) 2017, Intel Corporation.
* Copyright (c) 2019, loli10K <ezomori.nozomu@gmail.com>
* Copyright (c) 2020, Google LLC.
*/

#include <assert.h>
Expand Down
1 change: 1 addition & 0 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
* Copyright (c) 2017, Intel Corporation.
* Copyright (c) 2018, loli10K <ezomori.nozomu@gmail.com>
* Copyright (c) 2020, Google LLC.
*/

#include <errno.h>
Expand Down
1 change: 1 addition & 0 deletions lib/libzfs/libzfs_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2020 by Google LLC.
*/

/*
Expand Down
1 change: 1 addition & 0 deletions man/man8/zpoolprops.8
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.\" Copyright (c) 2018 George Melikov. All Rights Reserved.
.\" Copyright 2017 Nexenta Systems, Inc.
.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
.\" Copyright (c) 2020 Google LLC.
.\"
.Dd August 9, 2019
.Dt ZPOOLPROPS 8
Expand Down
1 change: 1 addition & 0 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Copyright (c) 2017, 2019, Datto Inc. All rights reserved.
* Copyright 2017 Joyent, Inc.
* Copyright (c) 2017, Intel Corporation.
* Copyright (c) 2020 by Google LLC.
*/

/*
Expand Down
3 changes: 2 additions & 1 deletion tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos',
'zpool_create_encrypted', 'zpool_create_crypt_combos',
'zpool_create_features_001_pos', 'zpool_create_features_002_pos',
'zpool_create_features_003_pos', 'zpool_create_features_004_neg',
'zpool_create_features_005_pos',
'zpool_create_features_005_pos', 'zpool_create_features_006_neg',
'zpool_create_features_007_pos',
'create-o_ashift', 'zpool_create_tempname']
tags = ['functional', 'cli_root', 'zpool_create']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ dist_pkgdata_SCRIPTS = \
zpool_create_features_003_pos.ksh \
zpool_create_features_004_neg.ksh \
zpool_create_features_005_pos.ksh \
zpool_create_features_006_neg.ksh \
zpool_create_features_007_pos.ksh \
create-o_ashift.ksh \
zpool_create_tempname.ksh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# Portions Copyright (c) 2020 by Google LLC.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -36,6 +37,8 @@
# 2. Verify that every feature@ property is in the 'disabled' state
# 3. Destroy pool and re-create with -o version=28
# 4. Verify again.
# 5. Destroy pool and re-create with -o features=none
# 6. Verify again.
#
################################################################################

Expand Down Expand Up @@ -67,4 +70,8 @@ log_must zpool destroy -f $TESTPOOL
log_must zpool create -f -o version=28 $TESTPOOL $DISKS
check_features

log_must zpool destroy -f $TESTPOOL
log_must zpool create -f -o features=none $TESTPOOL $DISKS
check_features

log_pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# Portions Copyright (c) 2020 by Google LLC.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib

################################################################################
#
# Specifying invalid featuresets should cause the create to fail.
#
# 1. Try to create the pool with a variety of invalid featuresets
# 2. Verify no pool was created.
#
################################################################################

verify_runnable "global"

TMP1=$(mktemp)
TMP2=$(mktemp)

# TMP1 invalid, TMP2 valid
echo "invalidfeature" > $TMP1
echo "async_destroy" > $TMP2

properties="\
features=hopefullynotarealfile \
features=/dev/null \
features=, \
features=$TMP1 \
features=$TMP1,$TMP2 \
"

function cleanup
{
datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
rm -f $TMP1 $TMP2
}

log_assert "'zpool create' with invalid featuresets fails"
log_onexit cleanup

for prop in $properties; do
log_mustnot zpool create -f -o "$prop" $TESTPOOL $DISKS
log_mustnot datasetexists $TESTPOOL
done

log_pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# Portions Copyright (c) 2020 by Google LLC.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib

################################################################################
#
# When using featuresets, only features present in all featuresets are
# enabled.
#
# 1. Create two featuresets with async_destroy being the only feature present
# in both. Create a pool with these two featuresets requested.
# 2. Verify that every feature@ property except feature@async_destroy is in
# the 'disabled' state
#
################################################################################

verify_runnable "global"

TMP1=$(mktemp)
TMP2=$(mktemp)

echo "async_destroy empty_bpobj extensible_dataset" > $TMP1
echo "resilver_defer bookmarks async_destroy encryption # empty_bpobj commented out" > $TMP2

function cleanup
{
datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
rm -f $TMP1 $TMP2
}

log_onexit cleanup

log_assert "'zpool create -o features=$TMP1,$TMP2' only " \
"enables async_destroy"

log_must zpool create -f -o features=$TMP1,$TMP2 $TESTPOOL $DISKS

state=$(zpool list -Ho feature@async_destroy $TESTPOOL)
if [[ "$state" != "enabled" ]]; then
log_fail "async_destroy has state $state"
fi

for prop in $(zpool get all $TESTPOOL | awk '$2 ~ /feature@/ { print $2 }'); do
state=$(zpool list -Ho "$prop" $TESTPOOL)
if [[ "$prop" != "feature@async_destroy" \
&& "$state" != "disabled" ]]; then
log_fail "$prop is enabled on new pool"
fi
done

log_pass