mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
Add more refquota tests
It used to be possible for zfs receive (and other operations related to clone swap) to bypass refquotas. This can cause a number of issues, and there should be an automated test for it. Added tests for rollback and receive not overriding refquota. Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes #9139
This commit is contained in:
parent
c75d3968bd
commit
72dbc01e7f
@ -750,7 +750,8 @@ tags = ['functional', 'redundancy']
|
||||
|
||||
[tests/functional/refquota]
|
||||
tests = ['refquota_001_pos', 'refquota_002_pos', 'refquota_003_pos',
|
||||
'refquota_004_pos', 'refquota_005_pos', 'refquota_006_neg']
|
||||
'refquota_004_pos', 'refquota_005_pos', 'refquota_006_neg',
|
||||
'refquota_007_neg', 'refquota_008_neg']
|
||||
tags = ['functional', 'refquota']
|
||||
|
||||
[tests/functional/refreserv]
|
||||
|
@ -7,4 +7,6 @@ dist_pkgdata_SCRIPTS = \
|
||||
refquota_003_pos.ksh \
|
||||
refquota_004_pos.ksh \
|
||||
refquota_005_pos.ksh \
|
||||
refquota_006_neg.ksh
|
||||
refquota_006_neg.ksh \
|
||||
refquota_007_neg.ksh \
|
||||
refquota_008_neg.ksh
|
||||
|
61
tests/zfs-tests/tests/functional/refquota/refquota_007_neg.ksh
Executable file
61
tests/zfs-tests/tests/functional/refquota/refquota_007_neg.ksh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# refquota limits the amount of space a dataset can consume,
|
||||
# snapshot rollback should be limited by refquota.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a file in a filesystem
|
||||
# 2. Create a snapshot of the filesystem
|
||||
# 3. Remove the file
|
||||
# 4. Set a refquota of size half of the file
|
||||
# 5. Rollback the filesystem from the snapshot
|
||||
# 6. Rollback should fail
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
|
||||
log_must $ZFS create $TESTPOOL/$TESTFS
|
||||
log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
TESTFILE='testfile'
|
||||
FS=$TESTPOOL/$TESTFS
|
||||
|
||||
mntpnt=$(get_prop mountpoint $FS)
|
||||
log_must mkfile 20M $mntpnt/$TESTFILE
|
||||
log_must zfs snapshot $FS@snap20M
|
||||
log_must rm $mntpnt/$TESTFILE
|
||||
|
||||
log_must sync
|
||||
|
||||
log_must zfs set refquota=10M $FS
|
||||
log_mustnot zfs rollback $FS@snap20M
|
||||
|
||||
log_pass "The rollback to the snapshot was restricted by refquota."
|
71
tests/zfs-tests/tests/functional/refquota/refquota_008_neg.ksh
Executable file
71
tests/zfs-tests/tests/functional/refquota/refquota_008_neg.ksh
Executable file
@ -0,0 +1,71 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# refquota limits the amount of space a dataset can consume,
|
||||
# This test verifies that zfs receive does not override
|
||||
# refquota.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a sub-filesystem $TESTSUBFS1
|
||||
# 2. Create a file in the sub-filesystem $TESTSUBFS1
|
||||
# 3. Create a snapshot of the sub-filesystem $TESTSUBFS1
|
||||
# 4. Create another sub-filesystem $TESTSUBFS2
|
||||
# 5. Apply a refquota value to $TESTSUBFS2,
|
||||
# half the sub-filesystem $TESTSUBFS1 file size
|
||||
# 6. Verify that zfs receive of the snapshot of $TESTSUBFS1
|
||||
# fails due to refquota
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
oldvalue=$(get_tunable spa_asize_inflation)
|
||||
function cleanup
|
||||
{
|
||||
set_tunable32 spa_asize_inflation $oldvalue
|
||||
log_must zfs destroy -rf $TESTPOOL/$TESTFS
|
||||
log_must zfs create $TESTPOOL/$TESTFS
|
||||
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
set_tunable32 spa_asize_inflation 2
|
||||
|
||||
TESTFILE='testfile'
|
||||
FS=$TESTPOOL/$TESTFS
|
||||
log_must zfs create $FS/$TESTSUBFS1
|
||||
log_must zfs create $FS/$TESTSUBFS2
|
||||
|
||||
mntpnt1=$(get_prop mountpoint $FS/$TESTSUBFS1)
|
||||
mntpnt2=$(get_prop mountpoint $FS/$TESTSUBFS2)
|
||||
|
||||
log_must mkfile 200M $mntpnt1/$TESTFILE
|
||||
log_must zfs snapshot $FS/$TESTSUBFS1@snap200m
|
||||
|
||||
log_must zfs set refquota=10M $FS/$TESTSUBFS2
|
||||
log_mustnot eval "zfs send $FS/$TESTSUBFS1@snap200m |" \
|
||||
"zfs receive -F $FS/$TESTSUBFS2"
|
||||
|
||||
log_pass "ZFS receive does not override refquota"
|
||||
|
Loading…
Reference in New Issue
Block a user