4 # Test remount behaviour
5 # Initial motivation was for pv#985710 and pv#983964
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
9 #-----------------------------------------------------------------------
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21 tag="added by qa $seq"
26 umount $SCRATCH_MNT 2>/dev/null
27 _putback_scratch_fstab
33 sed -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
34 -e "s#$SCRATCH_MNT#SCRATCH_MNT#"
39 # assumes that we don't have extra ops in fstab
40 _mount | grep $SCRATCH_MNT | _scratch_filter
44 # mount(8) adds all options from mtab and fstab to the mount command
45 # line. So the filesystem either must not reject any option at all
46 # if it can't change it, or compare the value on the command line
47 # to the existing state and only reject it if it would change
48 # something that can't be changed.
50 # Test this behaviour by mounting a filesystem read-only with a non-
51 # default option and then try to remount it rw.
53 # note that mount(8) doesn't add the options when specifying both the
54 # device node and mount point, so test out the various mounting
59 # use filestreams as a hopefully never default option
61 echo "try remount ro,filestreams -> rw,filestreams"
63 _scratch_mount -o ro,filestreams
64 [ $? -eq 0 ] || echo "ro,filestreams mount failed unexpectedly"
67 for dev_mnt in $SCRATCH_DEV $SCRATCH_MNT "$SCRATCH_DEV $SCRATCH_MNT"; do
68 echo "mounting given: $dev_mnt" | _scratch_filter
69 _mount -o remount,rw $dev_mnt
70 [ $? -eq 0 ] || echo "remount rw failed"
77 echo "try remount ro,noattr2 -> rw,attr2"
79 _scratch_mount -o ro,noattr2
80 [ $? -eq 0 ] || echo "ro,noattr2 mount failed unexpectedly"
83 for dev_mnt in $SCRATCH_DEV $SCRATCH_MNT "$SCRATCH_DEV $SCRATCH_MNT"; do
84 echo "mounting given: $dev_mnt" | _scratch_filter
85 _mount -o remount,rw,attr2 $dev_mnt
86 [ $? -eq 0 ] || echo "remount rw,attr2 failed"
94 # make sure we really can write to a filesystem after remount,rw
99 echo "try touching file after remount ro -> rw with options"
102 [ $? -eq 0 ] || echo "mount (1) failed unexpectedly"
104 touch $SCRATCH_MNT/foobar
105 [ $? -eq 0 ] || echo "touch (1) failed unexpectedly"
110 [ $? -eq 0 ] || echo "mount (2) failed unexpectedly"
112 _mount -o remount,rw,filestreams $SCRATCH_MNT
113 [ $? -eq 0 ] || echo "remount failed unexpectedly"
115 touch $SCRATCH_MNT/foobar
116 [ $? -eq 0 ] || echo "touch (2) failed unexpectedly"
122 # barrier is the only option we can change besides ro<->rw which is partially
123 # handled by the VFS and tested elsewhere. Make sure mount accepts going
124 # from barrier (which also is the default) to nobarrier and back.
126 _test_remount_barrier()
129 echo "Do remount barrier tests"
132 # mention barrier explicitly even if it's currently the default just to be sure
133 _scratch_mount -o barrier
134 [ $? -eq 0 ] || echo "mount failed unexpectedly!"
137 _scratch_mount -o remount,nobarrier
138 [ $? -eq 0 ] || _fail "remount nobarrier failed"
141 _scratch_mount -o remount,barrier
142 [ $? -eq 0 ] || _fail "remount barrier failed"
150 # Example fstab entry
151 # /dev/sdb2 /mnt/scratch1 xfs defaults 0 0
155 # comment out any existing SCRATCH_DEV
156 $SED_PROG -i "s;$SCRATCH_DEV;#$SCRATCH_DEV;" /etc/fstab
158 # add our fstab entry
159 echo "$SCRATCH_DEV $SCRATCH_MNT xfs defaults 0 0 # $tag" >> /etc/fstab
162 _modify_scratch_fstab()
166 # modify our fstab entry that we added
167 # modify opts by looking for last word which has non-space chars
168 $SED_PROG -i "s; [^ ]* 0 0 # $tag; $opts 0 0 # $tag;" /etc/fstab
171 _putback_scratch_fstab()
173 # uncomment out any existing SCRATCH_DEV
174 $SED_PROG -i "s;#$SCRATCH_DEV;$SCRATCH_DEV;" /etc/fstab
176 # remove the one we added at the end
177 $SED_PROG -i "/# $tag/d" /etc/fstab
180 # get standard environment, filters and checks
184 # real QA test starts here
194 _scratch_mkfs_xfs | _filter_mkfs 2>/dev/null
201 echo "add noikeep to fstab for scratch"
202 _modify_scratch_fstab noikeep # noikeep is not default for non dmapi
205 _putback_scratch_fstab
206 _test_remount_barrier