4 # Check out various mount/remount/unmount scenarious on a read-only blockdev.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Christoph Hellwig.
8 #-----------------------------------------------------------------------
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
22 sed -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" | \
23 sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
29 blockdev --setrw $SCRATCH_DEV
31 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # get standard environment, filters and checks
37 # real QA test starts here
43 _scratch_mkfs_xfs >/dev/null 2>&1
46 # Mark the device read-only
48 echo "setting device read-only"
49 blockdev --setro $SCRATCH_DEV
52 # Mount it, and make sure we can't write to it, and we can unmount it again
54 echo "mounting read-only block device:"
55 _scratch_mount 2>&1 | _filter_scratch
57 echo "touching file on read-only filesystem (should fail)"
58 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
61 # Apparently this used to be broken at some point:
62 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
64 echo "unmounting read-only filesystem"
65 umount $SCRATCH_MNT 2>&1 | _filter_scratch
67 echo "setting device read-write"
68 blockdev --setrw $SCRATCH_DEV
70 echo "mounting read-write block device:"
71 _scratch_mount 2>&1 | _filter_scratch
74 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
77 src/godown -f $SCRATCH_MNT
79 echo "unmounting shutdown filesystem:"
80 umount $SCRATCH_MNT 2>&1 | _filter_scratch
82 echo "setting device read-only"
83 blockdev --setro $SCRATCH_DEV
86 # Mounting a filesystem that requires log-recovery fails unless
87 # -o norecovery is used.
89 echo "mounting filesystem that needs recovery on a read-only device:"
90 _scratch_mount 2>&1 | _filter_scratch
92 echo "unmounting read-only filesystem"
93 umount $SCRATCH_MNT 2>&1 | _filter_scratch
96 # This is the way out if the underlying device really is read-only.
97 # Doesn't mean it's a good idea in practive, more a last resort
100 echo "mounting filesystem with -o norecovery on a read-only device:"
101 _scratch_mount -o norecovery 2>&1 | _filter_scratch
103 echo "unmounting read-only filesystem"
104 umount $SCRATCH_MNT 2>&1 | _filter_scratch
106 echo "setting device read-write"
107 blockdev --setrw $SCRATCH_DEV
110 # But log recovery is performed when mount with -o ro as long as
111 # the underlying device is not write protected.
113 echo "mounting filesystem that needs recovery with -o ro:"
114 _scratch_mount -o ro 2>&1 | _filter_scratch