Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2017 23:12:34 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r323250 - projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv
Message-ID:  <201709062312.v86NCY8d007969@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Sep  6 23:12:34 2017
New Revision: 323250
URL: https://svnweb.freebsd.org/changeset/base/323250

Log:
  Fix refreserv_00[24]
  
  tests/sys/cddl/zfs/tests/refreserv/refreserv_002_pos.ksh
  	Import a fix from Illumos.  Quotas and reservations are a little bit
  	approximate.  This change incrementally raises refreservation as
  	high as it can go, instead of assuming that it can equal the quota.
  
  tests/sys/cddl/zfs/tests/refreserv/refreserv_004_pos.ksh
  	Instead of assuming that refreservation can equal the parent's
  	quota, allow a margin of 5MB, like refreserv_001_pos does.  I don't
  	know why this wasn't a problem for Illumos.  Also, delete the final
  	line setting reservation.  I'm not sure what the purpose of that
  	line was.  It may originally have been a copy/paste error.
  
  tests/sys/cddl/zfs/tests/refreserv/refreserv_test.sh
  	Clear expected failures
  
  Obtained from:	Illumos (partially)
  Sponsored by:	Spectra Logic Corp

Modified:
  projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_002_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_004_pos.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_test.sh

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_002_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_002_pos.ksh	Wed Sep  6 23:01:41 2017	(r323249)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_002_pos.ksh	Wed Sep  6 23:12:34 2017	(r323250)
@@ -70,6 +70,29 @@ function cleanup
 	log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
 }
 
+# This function iteratively increases refreserv to its highest possible
+# value. Simply setting refreserv == quota can allow enough writes to
+# complete that the test fails.
+function max_refreserv
+{
+	typeset ds=$1
+	typeset -i incsize=131072
+	typeset -i rr=$(get_prop available $ds)
+
+	log_must $ZFS set refreserv=$rr $ds
+	while :; do
+		$ZFS set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1
+		if [[ $? == 0 ]]; then
+			((rr += incsize))
+			continue
+		else
+			((incsize /= 2))
+			((incsize == 0)) && break
+		fi
+	done
+}
+
+
 log_assert "Setting full size as refreservation, verify no snapshot " \
 	"can be created."
 log_onexit cleanup
@@ -88,9 +111,7 @@ for ds in $datasets; do
 	# Verify refreservation on dataset
 	#
 	log_must $ZFS set quota=25M $ds
-	log_must $ZFS set refreservation=25M $ds
-	mntpnt=$(get_prop mountpoint $ds)
-	log_must $TOUCH $mntpnt/$TESTFILE
+	max_refreserv $ds
 	log_mustnot $ZFS snapshot $ds@snap
 	if datasetexists $ds@snap ; then
 		log_fail "ERROR: $ds@snap should not exists."

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_004_pos.ksh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_004_pos.ksh	Wed Sep  6 23:01:41 2017	(r323249)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_004_pos.ksh	Wed Sep  6 23:12:34 2017	(r323250)
@@ -82,20 +82,19 @@ for ds in $datasets; do
 	log_must $ZFS set quota=25M $ds
 	log_must $ZFS set refreservation=15M $ds
 
-	typeset -i avail
-	avail=$(get_prop avail $subfs)
+	typeset  avail
+	avail=5M
 	log_must $ZFS set refreservation=$avail $subfs
 	typeset mntpnt
 	mntpnt=$(get_prop mountpoint $subfs)
 	log_must $MKFILE $avail $mntpnt/$TESTFILE
 
-	typeset -i exceed
-	((exceed = avail + 1))
+	typeset  exceed
+	exceed=15M
 	log_mustnot $ZFS set refreservation=$exceed $subfs
-	log_mustnot $MKFILE $avail $mntpnt/$TESTFILE
+	log_mustnot $MKFILE $exceed $mntpnt/$TESTFILE
 
 	log_must $ZFS set quota=none $ds
-	log_must $ZFS set reservation=15M $ds
 done
 
 log_pass "Verify refreservation is limited by available space."

Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_test.sh
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_test.sh	Wed Sep  6 23:01:41 2017	(r323249)
+++ projects/zfsd/head/tests/sys/cddl/zfs/tests/refreserv/refreserv_test.sh	Wed Sep  6 23:12:34 2017	(r323250)
@@ -55,7 +55,6 @@ refreserv_002_pos_head()
 }
 refreserv_002_pos_body()
 {
-	atf_expect_fail "BUG25520 this test incorrectly assumes that the avail, reserv, and refreserv properties are exact values that apply to data but not metadata"
 	. $(atf_get_srcdir)/../../include/default.cfg
 	. $(atf_get_srcdir)/refreserv.cfg
 
@@ -102,7 +101,6 @@ refreserv_004_pos_head()
 }
 refreserv_004_pos_body()
 {
-	atf_expect_fail "BUG25520 this test incorrectly assumes that the avail, reserv, and refreserv properties are exact values that apply to data but not metadata"
 	. $(atf_get_srcdir)/../../include/default.cfg
 	. $(atf_get_srcdir)/refreserv.cfg
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709062312.v86NCY8d007969>