4 # Check out various mount/remount/unmount scenarious on a read-only blockdev.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Christoph Hellwig.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
36 blockdev --setrw $SCRATCH_DEV
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
44 # real QA test starts here
50 _scratch_mkfs_xfs >/dev/null 2>&1
53 # Mark the device read-only
55 echo "setting device read-only"
56 blockdev --setro $SCRATCH_DEV
59 # Mount it, and make sure we can't write to it, and we can unmount it again
61 echo "mounting read-only block device:"
62 _scratch_mount 2>&1 | _filter_scratch
64 echo "touching file on read-only filesystem (should fail)"
65 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
68 # Apparently this used to be broken at some point:
69 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
71 echo "unmounting read-only filesystem"
72 umount $SCRATCH_MNT 2>&1 | _filter_scratch
74 echo "setting device read-write"
75 blockdev --setrw $SCRATCH_DEV
77 echo "mounting read-write block device:"
78 _scratch_mount 2>&1 | _filter_scratch
81 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
84 src/godown -f $SCRATCH_MNT
86 echo "unmounting shutdown filesystem:"
87 umount $SCRATCH_MNT 2>&1 | _filter_scratch
89 echo "setting device read-only"
90 blockdev --setro $SCRATCH_DEV
93 # Mounting a filesystem that requires log-recovery fails unless
94 # -o norecovery is used.
96 echo "mounting filesystem that needs recovery on a read-only device:"
97 _scratch_mount 2>&1 | _filter_scratch
99 echo "unmounting read-only filesystem"
100 umount $SCRATCH_MNT 2>&1 | _filter_scratch
103 # This is the way out if the underlying device really is read-only.
104 # Doesn't mean it's a good idea in practive, more a last resort
105 # data recovery hack.
107 echo "mounting filesystem with -o norecovery on a read-only device:"
108 _scratch_mount -o norecovery 2>&1 | _filter_scratch
110 echo "unmounting read-only filesystem"
111 umount $SCRATCH_MNT 2>&1 | _filter_scratch
113 echo "setting device read-write"
114 blockdev --setrw $SCRATCH_DEV
117 # But log recovery is performed when mount with -o ro as long as
118 # the underlying device is not write protected.
120 echo "mounting filesystem that needs recovery with -o ro:"
121 _scratch_mount -o ro 2>&1 | _filter_scratch