]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/upgrade/upgrade_userobj_001_pos.ksh
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2013 by Jinshan Xiong. No rights reserved.
25 # Copyright (c) 2017 Datto Inc.
28 .
$STF_SUITE/include
/libtest.shlib
33 # Check that zfs upgrade for object count accounting works.
34 # Since userobjaccounting is a per dataset feature, this test case
35 # will create multiple dataset and try different upgrade method.
38 # 1. Create a pool with all features disabled
39 # 2. Create a few dataset for testing
40 # 3. Make sure automatic upgrade work
41 # 4. Make sure manual upgrade work
46 datasetexists
$TESTPOOL/fs1
&& log_must zfs destroy
$TESTPOOL/fs1
47 datasetexists
$TESTPOOL/fs2
&& log_must zfs destroy
$TESTPOOL/fs2
50 verify_runnable
"global"
52 log_assert
"pool upgrade for userobj accounting should work"
55 log_must mkfiles
$TESTDIR/tf $
((RANDOM
% 1000 + 1))
56 log_must zfs create
$TESTPOOL/fs1
57 log_must mkfiles
$TESTDIR/fs
1/tf $
((RANDOM
% 1000 + 1))
58 log_must zfs create
$TESTPOOL/fs2
59 log_must mkfiles
$TESTDIR/fs
2/tf $
((RANDOM
% 1000 + 1))
60 log_must zfs umount
$TESTPOOL/fs2
62 # Make sure userobj accounting is disabled
63 zfs userspace
-o objused
-H $TESTPOOL |
head -n 1 |
grep -q "-" ||
64 log_fail
"userobj accounting should be disabled initially"
66 # Upgrade zpool to support all features
67 log_must zpool upgrade
$TESTPOOL
69 # Make sure userobj accounting is disabled again
70 zfs userspace
-o objused
-H $TESTPOOL |
head -n 1 |
grep -q "-" ||
71 log_fail
"userobj accounting should be disabled after pool upgrade"
73 # Create a file in fs1 should trigger dataset upgrade
74 log_must mkfile
1m
$TESTDIR/fs
1/tf
75 log_must
sleep 1 # upgrade done in the background so let's give it a sec
77 # Make sure userobj accounting is working for fs1
78 zfs userspace
-o objused
-H $TESTPOOL/fs1 |
head -n 1 |
grep -q "-" &&
79 log_fail
"userobj accounting should be enabled for $TESTPOOL/fs1"
81 # Mount a dataset should trigger upgrade
82 log_must zfs mount
$TESTPOOL/fs2
83 log_must
sleep 1 # upgrade done in the background so let's give it a sec
85 # Make sure userobj accounting is working for fs2
86 zfs userspace
-o objused
-H $TESTPOOL/fs2 |
head -n 1 |
grep -q "-" &&
87 log_fail
"userobj accounting should be enabled for $TESTPOOL/fs2"
89 # All in all, after having been through this, the dataset for testpool
90 # still shouldn't be upgraded
91 zfs userspace
-o objused
-H $TESTPOOL |
head -n 1 |
grep -q "-" ||
92 log_fail
"userobj accounting should be disabled for $TESTPOOL"
94 # Manual upgrade root dataset
95 # uses an ioctl which will wait for the upgrade to be done before returning
96 log_must zfs
set version
=current
$TESTPOOL
97 zfs userspace
-o objused
-H $TESTPOOL |
head -n 1 |
grep -q "-" &&
98 log_fail
"userobj accounting should be enabled for $TESTPOOL"
100 log_pass
"all tests passed - what a lucky day!"