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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 # Copyright 2016 Nexenta Systems, Inc.
33 . $STF_SUITE/include/libtest.shlib
37 # Verify that ZFS volume snapshot could be fscked
40 # 1. Create a ZFS volume
41 # 2. Copy some files and create snapshot
42 # 3. Verify fsck on the snapshot is OK
45 verify_runnable "global"
47 volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL)
51 snapexists $TESTPOOL/$TESTVOL@snap && \
52 zfs destroy $TESTPOOL/$TESTVOL@snap
54 ismounted $TESTDIR $NEWFS_DEFAULT_FS
55 (( $? == 0 )) && log_must umount $TESTDIR
57 zfs set volsize=$volsize $TESTPOOL/$TESTVOL
60 log_assert "Verify that ZFS volume snapshot could be fscked"
64 BLOCKSZ=$(( 1024 * 1024 ))
67 log_must zfs set volsize=128m $TESTPOOL/$TESTVOL
69 log_must new_fs ${ZVOL_RDEVDIR}/$TESTPOOL/$TESTVOL
71 log_must mount ${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL $TESTDIR
77 file_write -o create -f $TESTDIR/testfile$$.$fn \
78 -b $BLOCKSZ -c $NUM_WRITES
80 if (( $retval != 0 )); then
86 if is_linux || is_freebsd ; then
89 log_must lockfs -f $TESTDIR
92 log_must zfs set snapdev=visible $TESTPOOL/$TESTVOL
93 log_must zfs snapshot $TESTPOOL/$TESTVOL@snap
96 fsck -n ${ZVOL_RDEVDIR}/$TESTPOOL/$TESTVOL@snap >/dev/null 2>&1
99 if [ $retval -ne 0 ] ; then
101 # Linux's fsck returns a different code for this test depending
104 # e2fsprogs-1.43.3 (Fedora 25 and older): returns 4
105 # e2fsprogs-1.43.4 (Fedora 26): returns 8
107 if [ $retval -ne 4 -a $retval -ne 8 ] ; then
108 log_fail "fsck exited with wrong value $retval"
111 if [ $retval -ne 39 ] ; then
112 log_fail "fsck exited with wrong value $retval"
117 log_pass "Verify that ZFS volume snapshot could be fscked"