From f4c1745bd6c9829a05ecec15759ede7757100ab5 Mon Sep 17 00:00:00 2001 From: loli10K Date: Mon, 10 Jul 2017 07:27:39 +0200 Subject: [PATCH] 8477 Assertion failed in vdev_state_dirty(): spa_writeable(spa) Reviewed by: Matthew Ahrens Approved by: Dan McDonald --- usr/src/pkg/manifests/system-test-zfstest.mf | 3 + usr/src/test/zfs-tests/runfiles/delphix.run | 3 +- usr/src/test/zfs-tests/runfiles/omnios.run | 3 +- usr/src/test/zfs-tests/runfiles/openindiana.run | 3 +- .../cli_root/zpool_clear/zpool_clear_readonly.ksh | 71 ++++++++++++++++++++++ usr/src/uts/common/fs/zfs/zfs_ioctl.c | 2 +- 6 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index d62c79e8f9..fc315074c2 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -1297,6 +1297,9 @@ file \ file \ path=opt/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_003_neg \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_create/cleanup \ mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_create/setup mode=0555 diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run index c72af833cd..f74a0b5ea0 100644 --- a/usr/src/test/zfs-tests/runfiles/delphix.run +++ b/usr/src/test/zfs-tests/runfiles/delphix.run @@ -230,7 +230,8 @@ tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos', tests = ['zpool_attach_001_neg'] [/opt/zfs-tests/tests/functional/cli_root/zpool_clear] -tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg'] +tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg', + 'zpool_clear_readonly'] [/opt/zfs-tests/tests/functional/cli_root/zpool_create] tests = ['zpool_create_001_pos', 'zpool_create_002_pos', diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index 13233d99d5..fcb13f40df 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -222,7 +222,8 @@ tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos', tests = ['zpool_attach_001_neg'] [/opt/zfs-tests/tests/functional/cli_root/zpool_clear] -tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg'] +tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg', + 'zpool_clear_readonly'] [/opt/zfs-tests/tests/functional/cli_root/zpool_create] tests = ['zpool_create_001_pos', 'zpool_create_002_pos', diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index 318589be07..1882ab02da 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -222,7 +222,8 @@ tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos', tests = ['zpool_attach_001_neg'] [/opt/zfs-tests/tests/functional/cli_root/zpool_clear] -tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg'] +tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg', + 'zpool_clear_readonly'] [/opt/zfs-tests/tests/functional/cli_root/zpool_create] tests = ['zpool_create_001_pos', 'zpool_create_002_pos', diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh new file mode 100644 index 0000000000..9eb2a3608f --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh @@ -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 2017, loli10K . All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_clear/zpool_clear.cfg + +# +# DESCRIPTION: +# Verify 'zpool clear' cannot be used on readonly pools. +# +# STRATEGY: +# 1. Create a pool. +# 2. Export the pool and import it readonly. +# 3. Verify 'zpool clear' on the pool (and each device) returns an error. +# + +verify_runnable "global" + +function cleanup +{ + destroy_pool $TESTPOOL1 + rm -f $TESTDIR/file.* +} + +log_assert "Verify 'zpool clear' cannot be used on readonly pools." +log_onexit cleanup + +# 1. Create a pool. +log_must truncate -s $FILESIZE $TESTDIR/file.{1,2,3} +log_must zpool create $TESTPOOL1 raidz $TESTDIR/file.* + +# 2. Export the pool and import it readonly. +log_must zpool export $TESTPOOL1 +log_must zpool import -d $TESTDIR -o readonly=on $TESTPOOL1 +if [[ "$(get_pool_prop readonly $TESTPOOL1)" != 'on' ]]; then + log_fail "Pool $TESTPOOL1 was not imported readonly." +fi + +# 3. Verify 'zpool clear' on the pool (and each device) returns an error. +log_mustnot zpool clear $TESTPOOL1 +for i in {1..3}; do + # Device must be online + log_must check_state $TESTPOOL1 $TESTDIR/file.$i 'online' + # Device cannot be cleared if the pool was imported readonly + log_mustnot zpool clear $TESTPOOL1 $TESTDIR/file.$i +done + +log_pass "'zpool clear' fails on readonly pools as expected." diff --git a/usr/src/uts/common/fs/zfs/zfs_ioctl.c b/usr/src/uts/common/fs/zfs/zfs_ioctl.c index 8f64939836..c13fa1a5a6 100644 --- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c +++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c @@ -5897,7 +5897,7 @@ zfs_ioctl_init(void) zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE); zfs_ioctl_register_pool(ZFS_IOC_CLEAR, zfs_ioc_clear, - zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE); + zfs_secpolicy_config, B_TRUE, POOL_CHECK_READONLY); zfs_ioctl_register_pool(ZFS_IOC_POOL_REOPEN, zfs_ioc_pool_reopen, zfs_secpolicy_config, B_TRUE, POOL_CHECK_SUSPENDED); -- 2.11.4.GIT