diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index d3c28170430f..9fe15f3e4608 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -919,7 +919,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) * this device altogether. */ if ((fd = open(path, O_RDONLY)) >= 0) { - err = fstat64(fd, &statbuf); + err = fstat64_blk(fd, &statbuf); (void) close(fd); } else { err = stat64(path, &statbuf); diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index cf0dd126ff8a..9b35c046822e 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -237,23 +237,14 @@ tests = ['zpool_attach_001_neg', 'attach-o_ashift'] [tests/functional/cli_root/zpool_clear] tests = ['zpool_clear_002_neg', 'zpool_clear_003_neg'] -# DISABLED: -# zpool_create_001_pos - needs investigation -# zpool_create_002_pos - needs investigation -# zpool_create_004_pos - needs investigation -# zpool_create_006_pos - https://github.com/zfsonlinux/zfs/issues/3484 -# zpool_create_008_pos - uses VTOC labels (?) and 'overlapping slices' -# zpool_create_011_neg - tries to access /etc/vfstab etc -# zpool_create_012_neg - swap devices -# zpool_create_014_neg - swap devices -# zpool_create_015_neg - swap devices -# zpool_create_016_pos - no dumadm command. -# zpool_create_020_pos - needs investigation [tests/functional/cli_root/zpool_create] -tests = [ - 'zpool_create_003_pos', 'zpool_create_005_pos', 'zpool_create_007_neg', - 'zpool_create_009_neg', 'zpool_create_010_neg', 'zpool_create_017_neg', - 'zpool_create_018_pos', 'zpool_create_019_pos', +tests = ['zpool_create_001_pos', 'zpool_create_002_pos', + 'zpool_create_003_pos', 'zpool_create_004_pos', 'zpool_create_005_pos', + 'zpool_create_006_pos', 'zpool_create_007_neg', 'zpool_create_008_pos', + 'zpool_create_009_neg', 'zpool_create_010_neg', 'zpool_create_011_neg', + 'zpool_create_012_neg', 'zpool_create_014_neg', + 'zpool_create_015_neg', 'zpool_create_016_pos', 'zpool_create_017_neg', + 'zpool_create_018_pos', 'zpool_create_019_pos', 'zpool_create_020_pos', 'zpool_create_021_pos', 'zpool_create_022_pos', 'zpool_create_023_neg', 'zpool_create_024_pos', 'zpool_create_features_001_pos', 'zpool_create_features_002_pos', @@ -261,11 +252,8 @@ tests = [ 'zpool_create_features_005_pos', 'create-o_ashift'] -# DISABLED: -# zpool_destroy_001_pos - needs investigation -# zpool_destroy_002_pos - busy mountpoint behavior [tests/functional/cli_root/zpool_destroy] -tests = [ +tests = ['zpool_destroy_001_pos', 'zpool_destroy_002_pos', 'zpool_destroy_003_neg'] pre = post = diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index aa8f69821ba7..e458f4197511 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -65,6 +65,7 @@ export SYSTEM_FILES='arp md5sum mkdir mknod + mkswap mktemp modprobe mount @@ -100,6 +101,7 @@ export SYSTEM_FILES='arp su sudo sum + swapoff swapon sync tail diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index aafc47b2b151..269d323e60d1 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3302,3 +3302,35 @@ function zed_stop log_must rmdir $ZEDLET_DIR fi } + +# +# Setup a swap device using the provided device. +# +function swap_setup +{ + typeset swapdev=$1 + + if is_linux; then + log_must mkswap $swapdev + log_must swapon $swapdev + else + log_must swap -a $swapdev + fi +} + +# +# Cleanup a swap device on the provided device. +# +function swap_cleanup +{ + typeset swapdev=$1 + + if is_linux; then + log_must swapoff $swapdev + else + swap -l | grep $swapdev > /dev/null 2>&1 + if [[ $? -eq 0 ]]; then + log_must swap -d $swapdev + fi + fi +} diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib index 8551b453d22c..cffbbd82196f 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @@ -79,7 +79,7 @@ function create_blockfile log_fail "Create file system fail." log_must mount ${DEV_DSKDIR}/$disk $dir - log_must mkfile $size $file + log_must truncate -s $size $file } # @@ -121,12 +121,20 @@ function clean_blockfile # function find_vfstab_dev { - typeset vfstab="/etc/vfstab" - typeset tmpfile="/tmp/vfstab.tmp" + typeset vfstab="" + typeset tmpfile="" typeset vfstabdev typeset vfstabdevs="" typeset line + if is_linux; then + vfstab="/etc/fstab" + tmpfile="/tmp/fstab.tmp" + else + vfstab="/etc/vfstab" + tmpfile="/tmp/vfstab.tmp" + fi + cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile while read -r line do @@ -144,11 +152,14 @@ function find_vfstab_dev # function save_dump_dev { - typeset dumpdev - typeset fnd="Dump device" - dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \ - awk '{print $1}'` + if is_linux; then + dumpdev="" + else + typeset fnd="Dump device" + dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \ + awk '{print $1}'` + fi echo $dumpdev } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_002_pos.ksh index 58921a0ecb12..95375778dd9a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_002_pos.ksh @@ -80,9 +80,9 @@ log_must echo "y" | newfs \ ${DEV_RDSKDIR}/${disk}${SLICE_PREFIX}${SLICE1} >/dev/null 2>&1 create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}${SLICE_PREFIX}${SLICE4} create_blockfile $FILESIZE1 $TESTDIR1/$FILEDISK1 ${disk}${SLICE_PREFIX}${SLICE5} -log_must mkfile $SIZE /var/tmp/$FILEDISK0 -log_must mkfile $SIZE /var/tmp/$FILEDISK1 -log_must mkfile $SIZE /var/tmp/$FILEDISK2 +log_must truncate -s $SIZE /var/tmp/$FILEDISK0 +log_must truncate -s $SIZE /var/tmp/$FILEDISK1 +log_must truncate -s $SIZE /var/tmp/$FILEDISK2 unset NOINUSE_CHECK log_must zpool export $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_004_pos.ksh index 48846aa8ce58..269756274264 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_004_pos.ksh @@ -62,7 +62,7 @@ create_pool $TESTPOOL $disk log_must zfs create -o mountpoint=$TESTDIR $TESTPOOL/$TESTFS vdevs_list=$(echo $TESTDIR/file.{01..16}) -log_must mkfile $MINVDEVSIZE $vdevs_list +log_must truncate -s $MINVDEVSIZE $vdevs_list create_pool "$TESTPOOL1" $vdevs_list log_must vdevs_in_pool "$TESTPOOL1" "$vdevs_list" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_006_pos.ksh index 60cefb01fc51..060c7af4bde4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_006_pos.ksh @@ -87,7 +87,8 @@ set -A valid_args \ spare $vdev6" \ "raidz2 $vdev0 $vdev1 $vdev2 raidz2 $vdev3 $vdev4 $vdev5 \ raidz2 $vdev6 $vdev7 $vdev8 spare $vdev9" \ - "raidz2 $vdev0 $vdev1 $vdev2 spare $vdev3 raidz2 $vdev4 $vdev5 $vdev6" + "raidz2 $vdev0 $vdev1 $vdev2 spare $vdev3 raidz2 $vdev4 $vdev5 $vdev6" \ + "spare $vdev0 $vdev1 $vdev2 mirror $vdev3 $vdev4 raidz $vdev5 $vdev6" set -A forced_args \ "$vdev0 raidz $vdev1 $vdev2 raidz1 $vdev3 $vdev4 $vdev5" \ @@ -104,7 +105,8 @@ set -A forced_args \ raidz2 $vdev4 $vdev5 $vdev6 spare $vdev7" \ "mirror $vdev0 $vdev1 raidz $vdev2 $vdev3 \ spare $vdev4 raidz2 $vdev5 $vdev6 $vdev7" \ - "spare $vdev0 $vdev1 $vdev2 mirror $vdev3 $vdev4 raidz $vdev5 $vdev6" + "spare $vdev0 $vdev1 $vdev2 mirror $vdev3 $vdev4 \ + raidz2 $vdev5 $vdev6 $vdev7" i=0 while ((i < ${#valid_args[@]})); do diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_008_pos.ksh index 2a09aa1cd3b5..2e31af3c2260 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_008_pos.ksh @@ -125,14 +125,16 @@ fi create_pool $TESTPOOL $disk destroy_pool $TESTPOOL -# Make the disk is VTOC labeled since only VTOC label supports overlap -log_must labelvtoc $disk -log_must create_overlap_slice $disk - -unset NOINUSE_CHECK -log_mustnot zpool create $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} -log_must zpool create -f $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} -destroy_pool $TESTPOOL +if ! is_linux; then + # Make the disk is VTOC labeled since only VTOC label supports overlap + log_must labelvtoc $disk + log_must create_overlap_slice $disk + + unset NOINUSE_CHECK + log_mustnot zpool create $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} + log_must zpool create -f $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} + destroy_pool $TESTPOOL +fi # exported device to be as spare vdev need -f to create pool diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_011_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_011_neg.ksh index 359bfaf9c60d..f5fc3326e96a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_011_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_011_neg.ksh @@ -58,7 +58,7 @@ function cleanup log_must dumpadm -u -d $saved_dump_dev fi - partition_disk $SIZE $disk 6 + partition_disk $SIZE $disk 7 } log_assert "'zpool create' should be failed with inapplicable scenarios." @@ -77,11 +77,18 @@ raidz1=$mirror1 raidz2=$mirror2 diff_size_dev="${disk}${SLICE_PREFIX}${SLICE6} ${disk}${SLICE_PREFIX}${SLICE7}" vfstab_dev=$(find_vfstab_dev) -specified_dump_dev=${disk}${SLICE_PREFIX}${SLICE0} -saved_dump_dev=$(save_dump_dev) -cyl=$(get_endslice $disk $SLICE6) -set_partition $SLICE7 "$cyl" $SIZE1 $disk +if is_linux; then + partition_disk $SIZE $disk 7 + cyl=$(get_endslice $disk $SLICE5) + set_partition $SLICE6 "$cyl" $SIZE1 $disk +else + specified_dump_dev=${disk}${SLICE_PREFIX}${SLICE0} + saved_dump_dev=$(save_dump_dev) + + cyl=$(get_endslice $disk $SLICE6) + set_partition $SLICE7 "$cyl" $SIZE1 $disk +fi create_pool "$TESTPOOL" "$pooldev1" # @@ -115,17 +122,19 @@ done # now destroy the pool to be polite log_must zpool destroy -f $TESTPOOL -# create/destroy a pool as a simple way to set the partitioning -# back to something normal so we can use this $disk as a dump device -log_must zpool create -f $TESTPOOL3 $disk -log_must zpool destroy -f $TESTPOOL3 +if ! is_linux; then + # create/destroy a pool as a simple way to set the partitioning + # back to something normal so we can use this $disk as a dump device + log_must zpool create -f $TESTPOOL3 $disk + log_must zpool destroy -f $TESTPOOL3 -log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev -log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev" + log_must dumpadm -d ${DEV_DSKDIR}/$specified_dump_dev + log_mustnot zpool create -f $TESTPOOL1 "$specified_dump_dev" -# Also check to see that in-use checking prevents us from creating -# a zpool from just the first slice on the disk. -log_mustnot zpool create \ - -f $TESTPOOL1 ${specified_dump_dev}${SLICE_PREFIX}${SLICE0} + # Also check to see that in-use checking prevents us from creating + # a zpool from just the first slice on the disk. + log_mustnot zpool create \ + -f $TESTPOOL1 ${specified_dump_dev}${SLICE_PREFIX}${SLICE0} +fi log_pass "'zpool create' is failed as expected with inapplicable scenarios." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh index 062a2d63a83f..347fdfea49fa 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh @@ -50,10 +50,14 @@ function cleanup if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi - } -typeset swap_disks=`swap -l | grep "c[0-9].*d[0-9].*s[0-9]" | \ - awk '{print $1}'` + +if is_linux; then + typeset swap_disks=`swapon -s | grep "/dev" | awk '{print $1}'` +else + typeset swap_disks=`swap -l | grep "c[0-9].*d[0-9].*s[0-9]" | \ + awk '{print $1}'` +fi log_assert "'zpool create' should fail with disk slice in swap." log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_014_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_014_neg.ksh index 6785c02e1157..334cb0c25c24 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_014_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_014_neg.ksh @@ -48,10 +48,7 @@ verify_runnable "global" function cleanup { if datasetexists $vol_name; then - swap -l | grep $TMP_FILE > /dev/null 2>&1 - if [[ $? -eq 0 ]]; then - log_must swap -d $TMP_FILE - fi + swap_cleanup $TMP_FILE rm -f $TMP_FILE log_must umount $mntp zfs destroy $vol_name @@ -71,6 +68,12 @@ else disk=$DISK0 fi +if is_linux; then + set -A options "" "-f" +else + set -A options "-n" "" "-f" +fi + typeset pool_dev=${disk}${SLICE_PREFIX}${SLICE0} typeset vol_name=$TESTPOOL/$TESTVOL typeset mntp=/mnt @@ -82,9 +85,9 @@ log_must echo "y" | newfs ${ZVOL_DEVDIR}/$vol_name > /dev/null 2>&1 log_must mount ${ZVOL_DEVDIR}/$vol_name $mntp log_must mkfile 50m $TMP_FILE -log_must swap -a $TMP_FILE +swap_setup $TMP_FILE -for opt in "-n" "" "-f"; do +for opt in options; do log_mustnot zpool create $opt $TESTPOOL $TMP_FILE done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_015_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_015_neg.ksh index 24e58e0f86cb..69c7b8188116 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_015_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_015_neg.ksh @@ -52,10 +52,7 @@ function cleanup { # cleanup zfs pool and dataset if datasetexists $vol_name; then - swap -l | grep ${ZVOL_DEVDIR}/$vol_name > /dev/null 2>&1 - if [[ $? -eq 0 ]]; then - swap -d ${ZVOL_DEVDIR}/${vol_name} - fi + swap_cleanup ${ZVOL_DEVDIR}/$vol_name fi for pool in $TESTPOOL1 $TESTPOOL; do @@ -83,13 +80,14 @@ log_onexit cleanup # create_pool $TESTPOOL $pool_dev log_must zfs create -V 100m $vol_name -log_must swap -a ${ZVOl_DEVDIR}/$vol_name +swap_setup ${ZVOL_DEVDIR}/$vol_name + for opt in "-n" "" "-f"; do log_mustnot zpool create $opt $TESTPOOL1 ${ZVOL_DEVDIR}/${vol_name} done # cleanup -log_must swap -d ${ZVOL_DEVDIR}/${vol_name} +swap_cleanup ${ZVOL_DEVDIR}/${vol_name} log_must zfs destroy $vol_name log_must zpool destroy $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh index 4c2e554320f1..2314f4f69118 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh @@ -46,6 +46,10 @@ verify_runnable "global" +if is_linux; then + log_unsupported "Test case isn't useful under Linux." +fi + function cleanup { if poolexists $TESTPOOL; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh index 47da43e8ff9a..a7ab372176b2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh @@ -49,9 +49,9 @@ function cleanup if poolexists $TESTPOOL ; then destroy_pool $TESTPOOL fi - if [ -d ${TESTPOOL}.root ] + if [ -d /${TESTPOOL}.root ] then - log_must rmdir ${TESTPOOL}.root + log_must rmdir /${TESTPOOL}.root fi } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg index e9d8831f8259..65b43da2da4d 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg @@ -29,6 +29,8 @@ # export DISK=${DISKS%% *} +export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISKSARRAY=$DISKS if is_linux; then set_device_dir diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh index 6525db29c1c1..428765e2ebdd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh @@ -72,9 +72,15 @@ log_onexit cleanup partition_disk $SLICE_SIZE $DISK 2 create_pool "$TESTPOOL" "${DISK}${SLICE_PREFIX}${SLICE0}" -create_pool "$TESTPOOL1" "${DISK}${SLICE_PREFIX}${SLICE1}" -log_must zfs create -s -V $VOLSIZE $TESTPOOL1/$TESTVOL -create_pool "$TESTPOOL2" "${ZVOL_DEVDIR}/$TESTPOOL1/$TESTVOL" + +if is_linux; then + # Layering a pool on a zvol can deadlock and isn't supported. + create_pool "$TESTPOOL2" "${DISK}${SLICE_PREFIX}${SLICE1}" +else + create_pool "$TESTPOOL1" "${DISK}${SLICE_PREFIX}${SLICE1}" + log_must zfs create -s -V $VOLSIZE $TESTPOOL1/$TESTVOL + create_pool "$TESTPOOL2" "${ZVOL_DEVDIR}/$TESTPOOL1/$TESTVOL" +fi typeset -i i=0 while (( i < ${#datasets[*]} )); do diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh index d05493df2ff0..e273a8678a41 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh @@ -111,6 +111,11 @@ for dir in $TESTDIR /$TESTPOOL/$TESTCTR /$TESTPOOL/$TESTCTR/$TESTFS1 ; do done done +# 4. 'zpool destroy -f' the pool (unsupported behavior in Linux) +if is_linux; then + log_must cd /tmp +fi + destroy_pool $TESTPOOL log_mustnot poolexists "$TESTPOOL"