From 8aab12182184802afb3937f1fa35be4368a45f0d Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 2 Dec 2016 23:13:44 -0800 Subject: [PATCH] OpenZFS 7404 - rootpool_007_neg, bootfs_006_pos and bootfs_008_neg tests fail with the loader project bits Authored by: Toomas Soome Reviewed by: Igor Kozhukhov Reviewed by: Marcel Telka Reviewed by: Matthew Ahrens Approved by: Richard Lowe Reviewed-by: George Melikov Ported-by: Brian Behlendorf Porting Notes: - Removed gzip and zle compression restriction on bootfs datasets. Grub added support for these long ago. Ay version of grub which understands lz4 also supports this. - Enabled rootpool tests in runfile but skipped by default in setup on Linux since they modify the rootpool. - bootfs_006_pos.ksh, striped pools are allowed as bootfs. OpenZFS-issue: https://www.illumos.org/issues/7404 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/55a424c Closes #5982 --- include/sys/zio.h | 10 +++ tests/runfiles/linux.run | 11 ++- tests/zfs-tests/include/libtest.shlib | 14 ++-- .../tests/functional/bootfs/Makefile.am | 4 +- .../functional/bootfs/bootfs_006_pos.ksh | 32 ++++++--- .../functional/bootfs/bootfs_007_neg.ksh | 71 ------------------- .../functional/bootfs/bootfs_007_pos.ksh | 0 ...{bootfs_008_neg.ksh => bootfs_008_pos.ksh} | 12 ++-- .../tests/functional/rootpool/Makefile.am | 2 +- ...tpool_007_neg.ksh => rootpool_007_pos.ksh} | 8 +-- .../tests/functional/rootpool/setup.ksh | 8 +++ 11 files changed, 66 insertions(+), 106 deletions(-) delete mode 100755 tests/zfs-tests/tests/functional/bootfs/bootfs_007_neg.ksh mode change 100644 => 100755 tests/zfs-tests/tests/functional/bootfs/bootfs_007_pos.ksh rename tests/zfs-tests/tests/functional/bootfs/{bootfs_008_neg.ksh => bootfs_008_pos.ksh} (88%) rename tests/zfs-tests/tests/functional/rootpool/{rootpool_007_neg.ksh => rootpool_007_pos.ksh} (86%) diff --git a/include/sys/zio.h b/include/sys/zio.h index 54b106f05..b69146b6e 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -120,6 +120,16 @@ enum zio_checksum { #define BOOTFS_COMPRESS_VALID(compress) \ ((compress) == ZIO_COMPRESS_LZJB || \ (compress) == ZIO_COMPRESS_LZ4 || \ + (compress) == ZIO_COMPRESS_GZIP_1 || \ + (compress) == ZIO_COMPRESS_GZIP_2 || \ + (compress) == ZIO_COMPRESS_GZIP_3 || \ + (compress) == ZIO_COMPRESS_GZIP_4 || \ + (compress) == ZIO_COMPRESS_GZIP_5 || \ + (compress) == ZIO_COMPRESS_GZIP_6 || \ + (compress) == ZIO_COMPRESS_GZIP_7 || \ + (compress) == ZIO_COMPRESS_GZIP_8 || \ + (compress) == ZIO_COMPRESS_GZIP_9 || \ + (compress) == ZIO_COMPRESS_ZLE || \ (compress) == ZIO_COMPRESS_ON || \ (compress) == ZIO_COMPRESS_OFF) diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index d8e39d01c..69e317882 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -28,12 +28,10 @@ tests = ['posix_003_pos'] [tests/functional/atime] tests = ['atime_001_pos', 'atime_002_neg', 'atime_003_pos'] -# DISABLED: -# bootfs_006_pos - needs investigation -# bootfs_008_neg - needs investigation [tests/functional/bootfs] tests = ['bootfs_001_pos', 'bootfs_002_neg', 'bootfs_003_pos', - 'bootfs_004_neg', 'bootfs_005_neg', 'bootfs_007_neg'] + 'bootfs_004_neg', 'bootfs_005_neg', 'bootfs_006_pos', 'bootfs_007_pos', + 'bootfs_008_pos'] # DISABLED: # cache_001_pos - needs investigation @@ -562,9 +560,8 @@ tests = ['reservation_001_pos', 'reservation_002_pos', 'reservation_003_pos', 'reservation_013_pos', 'reservation_014_pos', 'reservation_015_pos', 'reservation_016_pos', 'reservation_017_pos'] -# DISABLED: Root pools must be handled differently under Linux -#[tests/functional/rootpool] -#tests = ['rootpool_002_neg', 'rootpool_003_neg', 'rootpool_007_neg'] +[tests/functional/rootpool] +tests = ['rootpool_002_neg', 'rootpool_003_neg', 'rootpool_007_pos'] # DISABLED: # rsend_008_pos - Fails for OpenZFS on illumos diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index d9d23d52d..8984071c8 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2702,8 +2702,11 @@ function is_zfsroot function get_rootfs { typeset rootfs="" - rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \ - /etc/mnttab) + + if ! is_linux; then + rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \ + /etc/mnttab) + fi if [[ -z "$rootfs" ]]; then log_fail "Can not get rootfs" fi @@ -2724,8 +2727,11 @@ function get_rootpool { typeset rootfs="" typeset rootpool="" - rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \ - /etc/mnttab) + + if ! is_linux; then + rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \ + /etc/mnttab) + fi if [[ -z "$rootfs" ]]; then log_fail "Can not get rootpool" fi diff --git a/tests/zfs-tests/tests/functional/bootfs/Makefile.am b/tests/zfs-tests/tests/functional/bootfs/Makefile.am index 901c0393d..15a6e202c 100644 --- a/tests/zfs-tests/tests/functional/bootfs/Makefile.am +++ b/tests/zfs-tests/tests/functional/bootfs/Makefile.am @@ -8,5 +8,5 @@ dist_pkgdata_SCRIPTS = \ bootfs_004_neg.ksh \ bootfs_005_neg.ksh \ bootfs_006_pos.ksh \ - bootfs_007_neg.ksh \ - bootfs_008_neg.ksh + bootfs_007_pos.ksh \ + bootfs_008_pos.ksh diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh index 012b0a1cb..e17c06bb5 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh @@ -117,30 +117,40 @@ verify_bootfs $TESTPOOL log_must zpool create $TESTPOOL mirror $VDEV1 $VDEV2 spare $VDEV3 verify_bootfs $TESTPOOL -## the following configurations are not supported as bootable pools +if is_linux; then + # stripe + log_must zpool create $TESTPOOL $VDEV1 $VDEV2 + verify_bootfs $TESTPOOL -# stripe -log_must zpool create $TESTPOOL $VDEV1 $VDEV2 -verify_no_bootfs $TESTPOOL + # stripe + hotspare + log_must zpool create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3 + verify_bootfs $TESTPOOL +else + ## the following configurations are not supported as bootable pools -# stripe + hotspare -log_must zpool create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3 -verify_no_bootfs $TESTPOOL + # stripe + log_must zpool create $TESTPOOL $VDEV1 $VDEV2 + verify_no_bootfs $TESTPOOL + + # stripe + hotspare + log_must zpool create $TESTPOOL $VDEV1 $VDEV2 spare $VDEV3 + verify_no_bootfs $TESTPOOL +fi # raidz log_must zpool create $TESTPOOL raidz $VDEV1 $VDEV2 -verify_no_bootfs $TESTPOOL +verify_bootfs $TESTPOOL # raidz + hotspare log_must zpool create $TESTPOOL raidz $VDEV1 $VDEV2 spare $VDEV3 -verify_no_bootfs $TESTPOOL +verify_bootfs $TESTPOOL # raidz2 log_must zpool create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 -verify_no_bootfs $TESTPOOL +verify_bootfs $TESTPOOL # raidz2 + hotspare log_must zpool create $TESTPOOL raidz2 $VDEV1 $VDEV2 $VDEV3 spare $VDEV4 -verify_no_bootfs $TESTPOOL +verify_bootfs $TESTPOOL log_pass "Pools of correct vdev types accept boot property" diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_007_neg.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_007_neg.ksh deleted file mode 100755 index 3ccbdc975..000000000 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_007_neg.ksh +++ /dev/null @@ -1,71 +0,0 @@ -#!/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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Copyright (c) 2013, 2016 by Delphix. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -# -# DESCRIPTION: -# -# Setting bootfs on a pool which was configured with the whole disk -# (i.e. EFI) will fail -# -# STRATEGY: -# 1. create a pool with a whole disk -# 2. create a filesystem on this pool -# 3. verify we can not set bootfs on the filesystem we just created. -# - -verify_runnable "global" - -function cleanup { - if poolexists $TESTPOOL ; then - destroy_pool "$TESTPOOL" - fi -} - -log_onexit cleanup - -DISK=${DISKS%% *} -typeset EFI_BOOTFS=$TESTPOOL/efs -typeset assert_mesg="setting bootfs on a pool which was configured with the \ - whole disk will fail" - -log_assert $assert_mesg -create_pool "$TESTPOOL" "$DISK" -log_must zfs create $EFI_BOOTFS - -if is_linux; then - log_must zpool set bootfs=$EFI_BOOTFS $TESTPOOL -else - log_mustnot zpool set bootfs=$EFI_BOOTFS $TESTPOOL -fi - -log_pass $assert_mesg diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_007_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_007_pos.ksh old mode 100644 new mode 100755 diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_008_neg.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_008_pos.ksh similarity index 88% rename from tests/zfs-tests/tests/functional/bootfs/bootfs_008_neg.ksh rename to tests/zfs-tests/tests/functional/bootfs/bootfs_008_pos.ksh index e0a767d4c..326c294c5 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_008_neg.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_008_pos.ksh @@ -34,13 +34,13 @@ # # DESCRIPTION: # -# setting bootfs on a dataset which has gzip compression enabled will fail +# setting bootfs on a dataset which has gzip compression enabled will not fail # # STRATEGY: # 1. create pools based on a valid vdev -# 2. create a filesystem on this pool and set the compression property to gzip1-9 +# 2. create a filesystem on this pool, set the compression property to gzip1-9 # 3. set the pool's bootfs property to filesystem we just configured which -# should fail +# should not fail # verify_runnable "global" @@ -56,9 +56,9 @@ function cleanup { } typeset assert_msg="setting bootfs on a dataset which has gzip \ - compression enabled will fail" + compression enabled will not fail" -typeset VDEV=$TESTDIR/bootfs_008_neg_a.$$.dat +typeset VDEV=$TEST_BASE_DIR/bootfs_008_pos_a.$$.dat typeset COMP_FS=$TESTPOOL/COMP_FS log_onexit cleanup @@ -74,7 +74,7 @@ set -A gtype "gzip" "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" \ while (( i < ${#gtype[@]} )); do log_must zfs set compression=${gtype[i]} $COMP_FS - log_mustnot zpool set bootfs=$COMP_FS $TESTPOOL + log_must zpool set bootfs=$COMP_FS $TESTPOOL log_must zfs set compression=off $COMP_FS (( i += 1 )) done diff --git a/tests/zfs-tests/tests/functional/rootpool/Makefile.am b/tests/zfs-tests/tests/functional/rootpool/Makefile.am index 9800fa094..ca5ad14fd 100644 --- a/tests/zfs-tests/tests/functional/rootpool/Makefile.am +++ b/tests/zfs-tests/tests/functional/rootpool/Makefile.am @@ -4,4 +4,4 @@ dist_pkgdata_SCRIPTS = \ cleanup.ksh \ rootpool_002_neg.ksh \ rootpool_003_neg.ksh \ - rootpool_007_neg.ksh + rootpool_007_pos.ksh diff --git a/tests/zfs-tests/tests/functional/rootpool/rootpool_007_neg.ksh b/tests/zfs-tests/tests/functional/rootpool/rootpool_007_pos.ksh similarity index 86% rename from tests/zfs-tests/tests/functional/rootpool/rootpool_007_neg.ksh rename to tests/zfs-tests/tests/functional/rootpool/rootpool_007_pos.ksh index d610c5add..e355a0f1f 100755 --- a/tests/zfs-tests/tests/functional/rootpool/rootpool_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/rootpool/rootpool_007_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: # -# the zfs rootfilesystem's compression property can not set to gzip[1-9] +# the zfs rootfilesystem's compression property can be set to gzip[1-9] # # STRATEGY: # 1) check if the current system is installed as zfs root # 2) get the rootfs -# 3) set the rootfs's compression to gzip 1-9 which should fail. +# 3) set the rootfs's compression to gzip 1-9 which should not fail. # verify_runnable "global" @@ -55,7 +55,7 @@ typeset rootpool=$(get_rootpool) typeset rootfs=$(get_pool_prop bootfs $rootpool) typeset orig_compress=$(get_prop compression $rootfs) -typeset assert_msg="the zfs rootfs's compression property can not set to \ +typeset assert_msg="the zfs rootfs's compression property can be set to \ gzip and gzip[1-9]" set -A gtype "gzip" "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" \ @@ -63,7 +63,7 @@ set -A gtype "gzip" "gzip-1" "gzip-2" "gzip-3" "gzip-4" "gzip-5" \ typeset -i i=0 while (( i < ${#gtype[@]} )); do - log_mustnot zfs set compression=${gtype[i]} $rootfs + log_must zfs set compression=${gtype[i]} $rootfs (( i += 1 )) done diff --git a/tests/zfs-tests/tests/functional/rootpool/setup.ksh b/tests/zfs-tests/tests/functional/rootpool/setup.ksh index a5baac54b..5c3e56b91 100755 --- a/tests/zfs-tests/tests/functional/rootpool/setup.ksh +++ b/tests/zfs-tests/tests/functional/rootpool/setup.ksh @@ -32,3 +32,11 @@ . $STF_SUITE/include/libtest.shlib verify_runnable "global" + +# +# This functionality is supported under Linux, but these test cases +# are disabled by default since they manipulate the systems root pool. +# +if is_linux; then + log_unsupported "Supported but disabled by default" +fi