1 #!/usr/bin/ksh
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 (c) 2012 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/include/libtest.shlib
19 . $STF_SUITE/tests/functional/nopwrite/nopwrite.shlib
20
21 #
22 # Description:
23 # Verify that duplicate writes to a clone are accounted as new data if the
24 # prerequisites for nopwrite are not met.
25 #
26 # Scenarios:
27 # 1. The file in the origin ds is written without compression or sha256.
28 # 2. The file in the origin ds is written before sha256 checksum is turned on.
29 # 3. The clone does not have compression.
30 # 4. The clone does not have the appropriate checksum.
31 #
32
33 verify_runnable "global"
34 origin="$TESTPOOL/$TESTFS"
35 log_onexit cleanup
36
37 function cleanup
38 {
39 datasetexists $origin && log_must $ZFS destroy -R $origin
40 log_must $ZFS create -o mountpoint=$TESTDIR $origin
41 }
42
43 log_assert "nopwrite isn't enabled without the prerequisites"
44
45 # Data written into origin fs without compression or sha256
46 $DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
47 >/dev/null 2>&1 || log_fail "dd of $TESTDIR/file failed."
48 $ZFS snapshot $origin@a || log_fail "zfs snap failed"
49 log_must $ZFS clone -o compress=on $origin@a $origin/clone
50 log_must $ZFS set checksum=sha256 $origin/clone
51 $DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
52 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
53 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
54 $ZFS destroy -R $origin@a || log_fail "zfs destroy failed"
55 log_must $RM -f $TESTDIR/file
56
57 # Data written to origin fs before checksum enabled
58 log_must $ZFS set compress=on $origin
59 $DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
60 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
61 log_must $ZFS set checksum=sha256 $origin
62 $ZFS snapshot $origin@a || log_fail "zfs snap failed"
63 log_must $ZFS clone $origin@a $origin/clone
64 $DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
65 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
66 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
67 $ZFS destroy -R $origin@a || log_fail "zfs destroy failed"
68 log_must $RM -f $TESTDIR/file
69
70 # Clone with compression=off
71 $DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
72 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
73 $ZFS snapshot $origin@a || log_fail "zfs snap failed"
74 log_must $ZFS clone -o compress=off $origin@a $origin/clone
75 $DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
76 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
77 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
78 $ZFS destroy -R $origin@a || log_fail "zfs destroy failed"
79 log_must $RM -f $TESTDIR/file
80
81 # Clone with fletcher4, rather than sha256
82 $DD if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
83 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
84 $ZFS snapshot $origin@a || log_fail "zfs snap failed"
85 log_must $ZFS clone -o checksum=fletcher4 $origin@a $origin/clone
86 $DD if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
87 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
88 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
89
90 log_pass "nopwrite isn't enabled without the prerequisites"
|
1 #!/usr/bin/ksh
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 (c) 2012, 2016 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/include/libtest.shlib
19 . $STF_SUITE/tests/functional/nopwrite/nopwrite.shlib
20
21 #
22 # Description:
23 # Verify that duplicate writes to a clone are accounted as new data if the
24 # prerequisites for nopwrite are not met.
25 #
26 # Scenarios:
27 # 1. The file in the origin ds is written without compression or sha256.
28 # 2. The file in the origin ds is written before sha256 checksum is turned on.
29 # 3. The clone does not have compression.
30 # 4. The clone does not have the appropriate checksum.
31 #
32
33 verify_runnable "global"
34 origin="$TESTPOOL/$TESTFS"
35 log_onexit cleanup
36
37 function cleanup
38 {
39 datasetexists $origin && log_must zfs destroy -R $origin
40 log_must zfs create -o mountpoint=$TESTDIR $origin
41 }
42
43 log_assert "nopwrite isn't enabled without the prerequisites"
44
45 # Data written into origin fs without compression or sha256
46 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
47 >/dev/null 2>&1 || log_fail "dd of $TESTDIR/file failed."
48 zfs snapshot $origin@a || log_fail "zfs snap failed"
49 log_must zfs clone -o compress=on $origin@a $origin/clone
50 log_must zfs set checksum=sha256 $origin/clone
51 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
52 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
53 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
54 zfs destroy -R $origin@a || log_fail "zfs destroy failed"
55 log_must rm -f $TESTDIR/file
56
57 # Data written to origin fs before checksum enabled
58 log_must zfs set compress=on $origin
59 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
60 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
61 log_must zfs set checksum=sha256 $origin
62 zfs snapshot $origin@a || log_fail "zfs snap failed"
63 log_must zfs clone $origin@a $origin/clone
64 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
65 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
66 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
67 zfs destroy -R $origin@a || log_fail "zfs destroy failed"
68 log_must rm -f $TESTDIR/file
69
70 # Clone with compression=off
71 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
72 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
73 zfs snapshot $origin@a || log_fail "zfs snap failed"
74 log_must zfs clone -o compress=off $origin@a $origin/clone
75 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
76 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
77 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
78 zfs destroy -R $origin@a || log_fail "zfs destroy failed"
79 log_must rm -f $TESTDIR/file
80
81 # Clone with fletcher4, rather than sha256
82 dd if=/dev/urandom of=$TESTDIR/file bs=1024k count=$MEGS conv=notrunc \
83 >/dev/null 2>&1 || log_fail "dd into $TESTDIR/file failed."
84 zfs snapshot $origin@a || log_fail "zfs snap failed"
85 log_must zfs clone -o checksum=fletcher4 $origin@a $origin/clone
86 dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
87 conv=notrunc >/dev/null 2>&1 || log_fail "dd failed."
88 log_mustnot verify_nopwrite $origin $origin@a $origin/clone
89
90 log_pass "nopwrite isn't enabled without the prerequisites"
|