OpenZFS 9286 - want refreservation=auto

Authored by: Mike Gerdts <mike.gerdts@joyent.com>
Reviewed by: Allan Jude <allanjude@freebsd.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Approved by: Richard Lowe <richlowe@richlowe.net>
Ported-by: Don Brady <don.brady@delphix.com>

Porting Notes:
* Adopted destroy_dataset in ZTS test cleanup
* Use ksh shebang instead of bash for new tests

OpenZFS-issue: https://www.illumos.org/issues/9286
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/723d0c85
Closes #7387
This commit is contained in:
Mike Gerdts
2018-04-11 10:14:45 -06:00
committed by Brian Behlendorf
parent 9966754ac5
commit d22f3a8244
9 changed files with 424 additions and 11 deletions
+2 -1
View File
@@ -675,7 +675,8 @@ tests = ['reservation_001_pos', 'reservation_002_pos', 'reservation_003_pos',
'reservation_007_pos', 'reservation_008_pos', 'reservation_009_pos',
'reservation_010_pos', 'reservation_011_pos', 'reservation_012_pos',
'reservation_013_pos', 'reservation_014_pos', 'reservation_015_pos',
'reservation_016_pos', 'reservation_017_pos']
'reservation_016_pos', 'reservation_017_pos', 'reservation_019_pos',
'reservation_020_pos', 'reservation_021_neg', 'reservation_022_pos']
tags = ['functional', 'reservation']
[tests/functional/rootpool]
@@ -19,7 +19,11 @@ dist_pkgdata_SCRIPTS = \
reservation_015_pos.sh \
reservation_016_pos.sh \
reservation_017_pos.sh \
reservation_018_pos.sh
reservation_018_pos.sh \
reservation_019_pos.sh \
reservation_020_pos.sh \
reservation_021_neg.sh \
reservation_022_pos.sh
dist_pkgdata_DATA = \
reservation.cfg \
@@ -0,0 +1,63 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018 Joyent, Inc.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/reservation/reservation.shlib
#
# DESCRIPTION:
#
# A thin provisioned volume can become thick provisioned with 'zfs set
# refreservation=auto'.
#
# STRATEGY:
# 1) Create a sparse value.
# 2) Use zfs set refreservation=auto to make it thick provisioned.
# 3) Verify that refreservation is now the size predicted by
# volsize_to_reservation().
#
verify_runnable "global"
function cleanup
{
destroy_dataset "$TESTPOOL/$TESTVOL" "-f"
}
log_onexit cleanup
log_assert "A thin provisioned volume can become thick provisioned with" \
"'zfs set refreservation=auto'."
space_avail=$(get_prop available $TESTPOOL)
(( vol_size = (space_avail / 2) & ~(1024 * 1024 - 1) ))
vol=$TESTPOOL/$TESTVOL
# Create sparse vol and verify
log_must zfs create -V $vol_size -s $vol
resv=$(get_prop refreservation $vol)
log_must test $resv -eq 0
# Set refreservation
log_must zfs set refreservation=auto $vol
# Verify
resv=$(get_prop refreservation $vol)
expected=$(volsize_to_reservation $vol $vol_size)
log_must test $resv -eq $expected
log_pass "Setting refreservation=auto set refreservation to expected value"
@@ -0,0 +1,64 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018 Joyent, Inc.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/reservation/reservation.shlib
#
# DESCRIPTION:
#
# Cloning a thick provisioned volume results in a sparse volume
#
# STRATEGY:
# 1) Create a thick provisioned volume.
# 2) Snapshot and clone it.
# 3) Verify that the clone is sparse.
#
verify_runnable "global"
function cleanup
{
# Destroy first vol and descendants in one go.
destroy_dataset "$TESTPOOL/$TESTVOL" "-Rf"
}
log_onexit cleanup
log_assert "Cloning a thick provisioned volume results in a sparse volume"
space_avail=$(get_prop available $TESTPOOL)
(( vol_size = (space_avail / 4) & ~(1024 * 1024 - 1) ))
vol=$TESTPOOL/$TESTVOL
snap=$vol@clone
vol2=$TESTPOOL/$TESTVOL2
# Create sparse vol and verify
log_must zfs create -V $vol_size $vol
resv=$(get_prop refreservation $vol)
expected=$(volsize_to_reservation $vol $vol_size)
log_must test $resv -eq $expected
# Clone it
log_must zfs snapshot $snap
log_must zfs clone $snap $vol2
# Verify
resv=$(get_prop refreservation $vol2)
log_must test $resv -eq 0
log_pass "Cloning a thick provisioned volume results in a sparse volume"
@@ -0,0 +1,72 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018 Joyent, Inc.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/reservation/reservation.shlib
#
# DESCRIPTION:
#
# The use of refreservation=auto on a filesystem does not change the
# refreservation and results in an error.
#
# STRATEGY:
# 1) Create a filesystem
# 2) Verify that zfs set refreservation=auto fails without changing
# refreservation from none.
# 3) Set refreservation to a valid value.
# 4) Verify that zfs set refreservation=auto fails without changing
# refreservation from the previous value.
#
verify_runnable "both"
fs=$TESTPOOL/$TESTFS/$(basename $0).$$
function cleanup
{
destroy_dataset "$fs" "-f"
}
log_onexit cleanup
log_assert "refreservation=auto on a filesystem generates an error without" \
"changing refreservation"
space_avail=$(get_prop available $TESTPOOL)
(( fs_size = space_avail / 4 ))
# Create a filesystem with no refreservation
log_must zfs create $fs
resv=$(get_prop refreservation $fs)
log_must test $resv -eq 0
# Verify that refreservation=auto fails without altering refreservation
log_mustnot zfs set refreservation=auto $fs
resv=$(get_prop refreservation $fs)
log_must test $resv -eq 0
# Set refreservation and verify
log_must zfs set refreservation=$fs_size $fs
resv=$(get_prop refreservation $fs)
log_must test $resv -eq $fs_size
# Verify that refreservation=auto fails without altering refreservation
log_mustnot zfs set refreservation=auto $fs
resv=$(get_prop refreservation $fs)
log_must test $resv -eq $fs_size
log_pass "refreservation=auto does not work on filesystems, as expected"
@@ -0,0 +1,82 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018 Joyent, Inc.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/reservation/reservation.shlib
#
# DESCRIPTION:
#
# Cloning a volume with -o refreservation=auto creates a thick provisioned
# volume
#
# STRATEGY:
# 1) Create a sparse volume.
# 2) Snapshot and clone it, using clone -o refreservation=auto.
# 3) Verify that the clone has refreservation that matches the size predicted by
# volsize_to_reservation().
# 4) Snapshot this second volume and clone it, using clone -o
# refreservation=auto.
# 5) Verify that the second clone has refreservation that matches the size
# predicted by volsize_to_reservation().
#
verify_runnable "global"
function cleanup
{
# Destroy first vol and descendants in one go.
destroy_dataset "$TESTPOOL/$TESTVOL" "-Rf"
}
log_onexit cleanup
log_assert "Cloning a volume with -o refreservation=auto creates a thick" \
"provisioned volume"
space_avail=$(get_prop available $TESTPOOL)
(( vol_size = (space_avail / 4) & ~(1024 * 1024 - 1) ))
vol=$TESTPOOL/$TESTVOL
vol2=$TESTPOOL/$TESTVOL2
vol3=$TESTPOOL/$TESTVOL2-again
# Create sparse vol and verify
log_must zfs create -s -V $vol_size $vol
resv=$(get_prop refreservation $vol)
log_must test $resv -eq 0
# Clone it
snap=$vol@clone
log_must zfs snapshot $snap
log_must zfs clone -o refreservation=auto $snap $vol2
# Verify it is thick provisioned
resv=$(get_prop refreservation $vol2)
expected=$(volsize_to_reservation $vol2 $vol_size)
log_must test $resv -eq $expected
# Clone the thick provisioned volume
snap=$vol2@clone
log_must zfs snapshot $snap
log_must zfs clone -o refreservation=auto $snap $vol3
# Verify new newest clone is also thick provisioned
resv=$(get_prop refreservation $vol3)
expected=$(volsize_to_reservation $vol3 $vol_size)
log_must test $resv -eq $expected
log_pass "Cloning a thick provisioned volume results in a sparse volume"