2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Christoph Hellwig.
7 # Check out various mount/remount/unmount scenarious on a read-only blockdev.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
20 blockdev --setrw $SCRATCH_DEV
22 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
28 # real QA test starts here
32 _require_scratch_nocheck
33 _require_scratch_shutdown
34 _require_local_device $SCRATCH_DEV
37 _scratch_mkfs >/dev/null 2>&1
40 # Mark the device read-only
42 echo "setting device read-only"
43 blockdev --setro $SCRATCH_DEV
46 # Mount it, and make sure we can't write to it, and we can unmount it again
48 echo "mounting read-only block device:"
49 _try_scratch_mount 2>&1 | _filter_ro_mount
51 echo "touching file on read-only filesystem (should fail)"
52 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
55 # Apparently this used to be broken at some point:
56 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
58 echo "unmounting read-only filesystem"
59 _scratch_unmount 2>&1 | _filter_scratch
61 echo "setting device read-write"
62 blockdev --setrw $SCRATCH_DEV
64 echo "mounting read-write block device:"
65 _try_scratch_mount 2>&1 | _filter_scratch
68 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
71 src/godown -f $SCRATCH_MNT
73 echo "unmounting shutdown filesystem:"
74 _scratch_unmount 2>&1 | _filter_scratch
76 echo "setting device read-only"
77 blockdev --setro $SCRATCH_DEV
80 # Mounting a filesystem that requires log-recovery fails unless
81 # -o norecovery is used.
83 echo "mounting filesystem that needs recovery on a read-only device:"
84 _try_scratch_mount 2>&1 | _filter_ro_mount
86 echo "unmounting read-only filesystem"
87 _scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
90 # This is the way out if the underlying device really is read-only.
91 # Doesn't mean it's a good idea in practive, more a last resort
94 echo "mounting filesystem with -o norecovery on a read-only device:"
95 _try_scratch_mount -o norecovery 2>&1 | _filter_ro_mount
97 echo "unmounting read-only filesystem"
98 _scratch_unmount 2>&1 | _filter_scratch
100 echo "setting device read-write"
101 blockdev --setrw $SCRATCH_DEV
104 # But log recovery is performed when mount with -o ro as long as
105 # the underlying device is not write protected.
107 echo "mounting filesystem that needs recovery with -o ro:"
108 _try_scratch_mount -o ro 2>&1 | _filter_scratch