Skip to content

Commit

Permalink
Enable all zpool_create/zpool_destroy tests
Browse files Browse the repository at this point in the history
* zpool_create_002_pos, zpool_create_004_pos - Use sparse files for
  file vdevs in order to avoid increasing the partition size.

* zpool_create_006_pos - 6ba1ce9 allows raidz+mirror configs with
  similar redundancy.  Updating the valid_args and forced_args cases.

* zpool_create_008_pos - Disable overlapping partition portion.

* zpool_create_011_neg - Fix to correctly create the extra partition.
  Modified zpool_vdev.c to use fstat64_blk() wrapper which includes
  the st_size even for block devices.

* zpool_create_012_neg - Updated to properly find swap devices.

* zpool_create_014_neg, zpool_create_015_neg - Updated to use
  swap_setup() and swap_cleanup() wrappers which do the right thing
  on Linux and Illumos.  Removed '-n' option which successed under
  Linux due to differences in the inuse checks.

* zpool_create_016_pos.ksh - Skipped test case isn't useful.

* zpool_create_020_pos - Added missing / to cleanup() function.

* zpool_destroy_001_pos - Removed test case which creates a pool on
  a zvol.  This is more likely to deadlock under Linux and has never
  been completely supported on any platform.

* zpool_destroy_002_pos - 'zpool destroy -f' is unsupported on Linux.
  Mount point must not be busy in order to unmount them.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
behlendorf committed May 4, 2017
1 parent dddef7d commit 07032e3
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 77 deletions.
2 changes: 1 addition & 1 deletion cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 8 additions & 20 deletions tests/runfiles/linux.run
Original file line number Diff line number Diff line change
Expand Up @@ -237,35 +237,23 @@ 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',
'zpool_create_features_003_pos', 'zpool_create_features_004_neg',
'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 =
Expand Down
2 changes: 2 additions & 0 deletions tests/zfs-tests/include/commands.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export SYSTEM_FILES='arp
md5sum
mkdir
mknod
mkswap
mktemp
modprobe
mount
Expand Down Expand Up @@ -100,6 +101,7 @@ export SYSTEM_FILES='arp
su
sudo
sum
swapoff
swapon
sync
tail
Expand Down
32 changes: 32 additions & 0 deletions tests/zfs-tests/include/libtest.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

#
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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"

#
Expand Down Expand Up @@ -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."
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 07032e3

Please sign in to comment.