2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
7 # Some random mount/umount corner case tests
9 # - mount at a nonexistent mount point
10 # - mount a free loop device
11 # - mount with a wrong fs type specified
12 # - umount an symlink to device which is not mounted
13 # - umount a path with too long name
14 # - lazy umount a symlink
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
22 status=1 # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # get standard environment, filters and checks
35 # real QA test starts here
37 # Modify as appropriate.
40 _require_test_symlinks
44 _require_block_device $SCRATCH_DEV
48 _scratch_mkfs >>$seqres.full 2>&1
50 # kernel should not hang nor oops when mounting fs to nonexistent mount point
51 mount_nonexistent_mnt()
53 echo "# mount to nonexistent mount point" >>$seqres.full
54 rm -rf $TEST_DIR/nosuchdir
55 $MOUNT_PROG $SCRATCH_DEV $TEST_DIR/nosuchdir >>$seqres.full 2>&1
58 # fs driver should be able to handle mounting a free loop device gracefully
59 # xfs ever hung, "ec53d1d xfs: don't block on buffer read errors" fixed it
62 echo "# mount a free loop device" >>$seqres.full
64 $MOUNT_PROG -t $FSTYP $loopdev $SCRATCH_MNT >>$seqres.full 2>&1
67 # mount with wrong fs type specified.
68 # This should fail gracefully, no hang no oops are expected
72 if [ "$FSTYP" == "ext4" ]; then
75 echo "# mount with wrong fs type" >>$seqres.full
76 $MOUNT_PROG -t $fs $SCRATCH_DEV $SCRATCH_MNT >>$seqres.full 2>&1
79 # umount a symlink to device, which is not mounted.
80 # This should fail gracefully, no hang no oops are expected
81 umount_symlink_device()
83 local symlink=$TEST_DIR/$seq.scratch_dev_symlink
85 echo "# umount symlink to device, which is not mounted" >>$seqres.full
86 ln -s $SCRATCH_DEV $symlink
87 $UMOUNT_PROG $symlink >>$seqres.full 2>&1
90 # umount a path name that is 256 bytes long, this should fail gracefully,
91 # and the following umount should not hang nor oops
94 local longname=$SCRATCH_MNT/`$PERL_PROG -e 'print "a"x256;'`
96 _scratch_mount 2>&1 | tee -a $seqres.full
98 echo "# umount a too-long name" >>$seqres.full
99 $UMOUNT_PROG $longname >>$seqres.full 2>&1
100 _scratch_unmount 2>&1 | tee -a $seqres.full
103 # lazy umount a symlink should not block following umount.
104 # This is the test case described in https://lkml.org/lkml/2014/7/21/98
105 lazy_umount_symlink()
107 local symlink=$SCRATCH_MNT/$seq.testdir_symlink
108 echo "# lazy umount a symlink" >>$seqres.full
109 _scratch_mount 2>&1 | tee -a $seqres.full
110 mkdir -p $SCRATCH_MNT/testdir
112 ln -s $SCRATCH_MNT/testdir $symlink
114 $UMOUNT_PROG -l $symlink >>$seqres.full 2>&1
115 # _scratch_unmount should not be blocked
116 _scratch_unmount 2>&1 | tee -a $seqres.full
119 echo "Silence is golden"
121 mount_nonexistent_mnt
125 umount_symlink_device