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 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
37 blockdev --setrw $SCRATCH_DEV
39 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
45 # real QA test starts here
51 _scratch_mkfs_xfs >/dev/null 2>&1
54 # Mark the device read-only
56 echo "setting device read-only"
57 blockdev --setro $SCRATCH_DEV
60 # Mount it, and make sure we can't write to it, and we can unmount it again
62 echo "mounting read-only block device:"
63 _scratch_mount 2>&1 | _filter_scratch
65 echo "touching file on read-only filesystem (should fail)"
66 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
69 # Apparently this used to be broken at some point:
70 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
72 echo "unmounting read-only filesystem"
73 umount $SCRATCH_MNT 2>&1 | _filter_scratch
75 echo "setting device read-write"
76 blockdev --setrw $SCRATCH_DEV
78 echo "mounting read-write block device:"
79 _scratch_mount 2>&1 | _filter_scratch
82 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
85 src/godown -f $SCRATCH_MNT
87 echo "unmounting shutdown filesystem:"
88 umount $SCRATCH_MNT 2>&1 | _filter_scratch
90 echo "setting device read-only"
91 blockdev --setro $SCRATCH_DEV
94 # Mounting a filesystem that requires log-recovery fails unless
95 # -o norecovery is used.
97 echo "mounting filesystem that needs recovery on a read-only device:"
98 _scratch_mount 2>&1 | _filter_scratch
100 echo "unmounting read-only filesystem"
101 umount $SCRATCH_MNT 2>&1 | _filter_scratch
104 # This is the way out if the underlying device really is read-only.
105 # Doesn't mean it's a good idea in practive, more a last resort
106 # data recovery hack.
108 echo "mounting filesystem with -o norecovery on a read-only device:"
109 _scratch_mount -o norecovery 2>&1 | _filter_scratch
111 echo "unmounting read-only filesystem"
112 umount $SCRATCH_MNT 2>&1 | _filter_scratch
114 echo "setting device read-write"
115 blockdev --setrw $SCRATCH_DEV
118 # But log recovery is performed when mount with -o ro as long as
119 # the underlying device is not write protected.
121 echo "mounting filesystem that needs recovery with -o ro:"
122 _scratch_mount -o ro 2>&1 | _filter_scratch