Skip to content

Commit

Permalink
Relax refreservation constraints on ZVOLs
Browse files Browse the repository at this point in the history
This change allow refreservation to be set larger than the current
ZVOL size: this is safe as we normally set refreservation > volsize
at ZVOL creation time when we account for metadata.

Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
  • Loading branch information
loli10K committed Sep 6, 2017
1 parent 4c5b89f commit 1053fe7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,6 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,

switch (prop) {
case ZFS_PROP_RESERVATION:
case ZFS_PROP_REFRESERVATION:
if (intval > volsize) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"'%s' is greater than current "
Expand Down
3 changes: 2 additions & 1 deletion tests/runfiles/linux.run
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ tests = ['zfs_rename_001_pos', 'zfs_rename_002_pos', 'zfs_rename_003_pos',
'zfs_rename_to_encrypted']

[tests/functional/cli_root/zfs_reservation]
tests = ['zfs_reservation_001_pos', 'zfs_reservation_002_pos']
tests = ['zfs_reservation_001_pos', 'zfs_reservation_002_pos',
'zfs_reservation_bigger']

[tests/functional/cli_root/zfs_rollback]
tests = ['zfs_rollback_001_pos', 'zfs_rollback_002_pos',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
zfs_reservation_001_pos.ksh \
zfs_reservation_002_pos.ksh
zfs_reservation_002_pos.ksh \
zfs_reservation_bigger.ksh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib

#
# DESCRIPTION:
#
# Verify refreservation can be set bigger than then current ZVOL size
#
# STRATEGY:
# 1. Create a ZVOL with initial refreservation
# 2. Remove the refreservation
# 3. Verify we can set the old refreservation value again on the ZVOL
#

verify_runnable "both"

function cleanup
{
datasetexists $ZVOL && log_must_busy zfs destroy -f $ZVOL
}

log_onexit cleanup

log_assert "Verify refreservation can be set bigger than then current ZVOL size"

ZVOL="$TESTPOOL/$TESTVOL"
volsize="$((1024 * 1024 * 64))" # 64M

# 1. Create a ZVOL with initial refreservation
log_must zfs create -V $volsize $ZVOL
refreserv=`get_prop refreservation $ZVOL`
if [[ $refreserv -le $volsize ]]; then
log_fail "Unexpected refreservation on $ZVOL ($refreserv <= $volsize)"
fi

# 2. Remove the refreservation
log_must zfs set refreservation=none $ZVOL
if [[ `get_prop refreservation $ZVOL` != 0 ]]; then
log_fail "Could not correctly remove refreservation on $ZVOL"
fi

# 3. Verify we can set the same refreservation value again on the ZVOL
log_must zfs set refreservation=$refreserv $ZVOL
if [[ `get_prop refreservation $ZVOL` != $refreserv ]]; then
log_fail "Could not correctly set refreservation to old value on $ZVOL"
fi

log_pass "Successfully set refreservation on ZVOL"

0 comments on commit 1053fe7

Please sign in to comment.