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.
43 _require_block_device $SCRATCH_DEV
47 _scratch_mkfs >>$seqres.full 2>&1
49 # kernel should not hang nor oops when mounting fs to nonexistent mount point
50 mount_nonexistent_mnt()
52 echo "# mount to nonexistent mount point" >>$seqres.full
53 rm -rf $TEST_DIR/nosuchdir
54 $MOUNT_PROG $SCRATCH_DEV $TEST_DIR/nosuchdir >>$seqres.full 2>&1
57 # fs driver should be able to handle mounting a free loop device gracefully
58 # xfs ever hung, "ec53d1d xfs: don't block on buffer read errors" fixed it
61 echo "# mount a free loop device" >>$seqres.full
63 $MOUNT_PROG -t $FSTYP $loopdev $SCRATCH_MNT >>$seqres.full 2>&1
66 # mount with wrong fs type specified.
67 # This should fail gracefully, no hang no oops are expected
71 if [ "$FSTYP" == "ext4" ]; then
74 echo "# mount with wrong fs type" >>$seqres.full
75 $MOUNT_PROG -t $fs $SCRATCH_DEV $SCRATCH_MNT >>$seqres.full 2>&1
78 # umount a symlink to device, which is not mounted.
79 # This should fail gracefully, no hang no oops are expected
80 umount_symlink_device()
82 local symlink=$TEST_DIR/$seq.scratch_dev_symlink
84 echo "# umount symlink to device, which is not mounted" >>$seqres.full
85 ln -s $SCRATCH_DEV $symlink
86 $UMOUNT_PROG $symlink >>$seqres.full 2>&1
89 # umount a path name that is 256 bytes long, this should fail gracefully,
90 # and the following umount should not hang nor oops
93 local longname=$SCRATCH_MNT/`$PERL_PROG -e 'print "a"x256;'`
95 _scratch_mount 2>&1 | tee -a $seqres.full
97 echo "# umount a too-long name" >>$seqres.full
98 $UMOUNT_PROG $longname >>$seqres.full 2>&1
99 _scratch_unmount 2>&1 | tee -a $seqres.full
102 # lazy umount a symlink should not block following umount.
103 # This is the test case described in https://lkml.org/lkml/2014/7/21/98
104 lazy_umount_symlink()
106 local symlink=$SCRATCH_MNT/$seq.testdir_symlink
107 echo "# lazy umount a symlink" >>$seqres.full
108 _scratch_mount 2>&1 | tee -a $seqres.full
109 mkdir -p $SCRATCH_MNT/testdir
111 ln -s $SCRATCH_MNT/testdir $symlink
113 $UMOUNT_PROG -l $symlink >>$seqres.full 2>&1
114 # _scratch_unmount should not be blocked
115 _scratch_unmount 2>&1 | tee -a $seqres.full
118 echo "Silence is golden"
120 mount_nonexistent_mnt
124 umount_symlink_device