1 #! /usr/bin/ksh -p
2 #
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13
14 #
15 # Copyright 2016 Nexenta Systems, Inc. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/wbc/wbc.cfg
19 . $STF_SUITE/tests/functional/wbc/wbc.kshlib
20
21 #
22 # DESCRIPTION:
23 # Removing writecached datasets should decrement feature@wbc refcounter
24 #
25 # STRATEGY:
26 # 1. Create pool with separated special devices and disabled write back
27 # cache
28 # 2. Display pool status
29 # 3. Create a filesystem
30 # 4. Check that "feature@wbc" is "enabled".
31 # 5. Enable write back cache for the created filesystem
32 # 6. Check that "feature@wbc" is "active"
33 # 7. Display pool status
34 # 8. Scrub pool and check status
35 # 9. Destroy the created filesystem
36 # 11. Check that "feature@wbc" is "enabled".
37 #
38
39 function check_feature_wbc_enabled
40 {
41 log_must eval "zpool get feature@wbc $TESTPOOL > /tmp/value.$$"
42 grep "enabled" /tmp/value.$$ > /dev/null 2>&1
43 if [ $? -ne 0 ]
44 then
45 log_fail "feature@wbc is not 'enabled'"
46 fi
47 }
48
49 function check_feature_wbc_active
50 {
51 log_must eval "zpool get feature@wbc $TESTPOOL > /tmp/value.$$"
52 grep "active" /tmp/value.$$ > /dev/null 2>&1
53 if [ $? -ne 0 ]
54 then
55 log_fail "feature@wbc is not 'active'"
56 fi
57 }
58
59 verify_runnable "global"
60 log_assert "Enabling WBC succeeds."
61 log_onexit cleanup
62 log_must create_pool_special $TESTPOOL "none"
63 log_must display_status $TESTPOOL
64
65 log_must zfs create $TESTPOOL/wbc
66 datasetexists $TESTPOOL/wbc || \
67 log_fail "zfs create $TESTPOOL/wbc fail."
68
69 check_feature_wbc_enabled
70 log_must enable_wbc $TESTPOOL/wbc
71 check_feature_wbc_active
72
73 log_must display_status $TESTPOOL
74 log_must sync
75 log_must zpool scrub $TESTPOOL
76 while is_pool_scrubbing $TESTPOOL ; do
77 sleep 1
78 done
79 log_must check_pool_errors $TESTPOOL
80
81 log_must zfs destroy -rR $TESTPOOL/wbc
82 datasetnonexists $TESTPOOL/wbc || \
83 log_fail "zfs destroy -rR $TESTPOOL/wbc fail."
84
85 check_feature_wbc_enabled
86
87 log_must display_status $TESTPOOL
88 log_must sync
89 log_must zpool scrub $TESTPOOL
90 while is_pool_scrubbing $TESTPOOL ; do
91 sleep 1
92 done
93 log_must check_pool_errors $TESTPOOL
94
95 log_must destroy_pool $TESTPOOL
96 log_pass "Enabling WBC succeeds."