]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfstests: do not unmount tmpfs during remount
authorJunho Ryu <jayr@google.com>
Thu, 18 Feb 2016 23:45:35 +0000 (10:45 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 18 Feb 2016 23:45:35 +0000 (10:45 +1100)
Several tests unmount then re-mount the scratch filesystem, to check
that the content is unchanged; but unmounting a tmpfs is designed to
lose its content, which causes such tests to fail unnecessarily.

Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Junho Ryu <jayr@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc
tests/generic/003
tests/generic/135
tests/generic/169
tests/generic/169.out
tests/generic/192
tests/generic/226
tests/generic/258
tests/generic/306
tests/generic/317
tests/generic/318

index af1e4e0f850316cc59e66886d9b61f0fe7875e9f..c0ec905e8db4e876ee4c83718b23f0e91687a14f 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -329,10 +329,28 @@ _scratch_unmount()
        esac
 }
 
+_scratch_remount()
+{
+    local opts="$1"
+
+    if test -n "$opts"; then
+       mount -o "remount,$opts" $SCRATCH_MNT
+    fi
+}
+
 _scratch_cycle_mount()
 {
+    local opts="$1"
+
+    if [ "$FSTYP" = tmpfs ]; then
+       _scratch_remount "$opts"
+       return
+    fi
+    if test -n "$opts"; then
+       opts="-o $opts"
+    fi
     _scratch_unmount
-    _scratch_mount
+    _scratch_mount "$opts"
 }
 
 _test_mount()
@@ -356,6 +374,9 @@ _test_unmount()
 
 _test_cycle_mount()
 {
+    if [ "$FSTYP" = tmpfs ]; then
+       return
+    fi
     _test_unmount
     _test_mount
 }
index 7ffd09a36235c4dfd91de46934259cd0478dc02f..710ffc8ef56a085fb179dbf21e0d20dd0bbe20aa 100755 (executable)
@@ -107,9 +107,8 @@ file1_stat_after_second_access=`_stat $TPATH/dir1/file1`
 _compare_stat_times NNN "$file1_stat_after_first_access" \
        "$file1_stat_after_second_access" "after accessing file1 second time"
 
-# Remounting with nodiratime option
-_scratch_unmount
-_scratch_mount "-o nodiratime"
+# Mounting with nodiratime option
+_scratch_cycle_mount "nodiratime"
 file1_stat_after_remount=`_stat $TPATH/dir1/file1`
 _compare_stat_times NNN "$file1_stat_after_second_access" \
        "$file1_stat_after_remount" "for file1 after remount"
@@ -134,9 +133,8 @@ dir2_stat_after_file_access=`_stat $TPATH/dir2`
 _compare_stat_times NNN "$dir2_stat_after_file_creation" \
        "$dir2_stat_after_file_access" "for dir2 after file access"
 
-# Remounting with noatime option, creating a file and accessing it
-_scratch_unmount
-_scratch_mount "-o noatime"
+# Mounting with noatime option, creating a file and accessing it
+_scratch_cycle_mount "noatime"
 echo "ccc" > $TPATH/dir2/file3
 file3_stat_before_first_access=`_stat $TPATH/dir2/file3`
 sleep 1
@@ -158,10 +156,9 @@ file1_stat_after_change=`_stat $TPATH/dir1/file1_renamed`
 _compare_stat_times NNY "$file1_stat_after_modify" \
        "$file1_stat_after_change" "after changing file1"
 
-# Remounting with strictatime option and
+# Mounting with strictatime option and
 # accessing a previously created file twice
-_scratch_unmount
-_scratch_mount "-o strictatime"
+_scratch_cycle_mount "strictatime"
 cat $TPATH/dir2/file3 > /dev/null
 file3_stat_after_second_access=`_stat $TPATH/dir2/file3`
 _compare_stat_times YNN "$file3_stat_after_first_access" \
@@ -189,13 +186,12 @@ if [ "$FSTYP" = "btrfs" ]; then
                "$file3_stat_readonly_after_access" "for file in readonly subvol"
 fi
 
-# Remounting read-only. Access time should never be updated, despite the
+# Mounting read-only. Access time should never be updated, despite the
 # strictatime mount option.
 sleep 1
 dir2_stat_before_ro_mount=`_stat $TPATH/dir2`
 file3_stat_before_ro_mount=`_stat $TPATH/dir2/file3`
-_scratch_unmount
-_scratch_mount "-o ro,strictatime"
+_scratch_cycle_mount "ro,strictatime"
 ls $TPATH/dir2 > /dev/null
 cat $TPATH/dir2/file3 > /dev/null
 dir2_stat_after_ro_mount=`_stat $TPATH/dir2`
index 44006726fe09d3d662c997cc2c108b53809082f9..52418f696e0a1f55ec642125fa96e3adb6afa7ed 100755 (executable)
@@ -41,19 +41,8 @@ _supported_os Linux IRIX
 
 _require_odirect
 _require_scratch
-_scratch_mkfs >/dev/null 2>&1
-
-_umount_mount()
-{
-    CWD=`pwd`
-    cd /
-    # pipe error into /dev/null, in case not mounted (after _require_scratch)
-    _scratch_unmount 2>/dev/null
-    _scratch_mount
-    cd "$CWD"
-}
-
-_umount_mount
+_scratch_mkfs >/dev/null
+_scratch_mount
 
 cd $SCRATCH_MNT
 
@@ -71,7 +60,9 @@ $XFS_IO_PROG -f -c 'pwrite -b 4k -S 0x78 0 4k' trunc_file > /dev/null
 $XFS_IO_PROG -f -c 'truncate 2k' trunc_file > /dev/null
 $XFS_IO_PROG -c 'pwrite 1k 0 1k' trunc_file > /dev/null
 
-_umount_mount
+pushd / > /dev/null
+_scratch_cycle_mount
+popd > /dev/null
 
 # check file size and contents
 od -Ad -x async_file
index 839ff9d86b4743739525bda24452d8f52a7d7d61..f51f4d1981eadb2a79375402022b0babd89c7f02 100755 (executable)
@@ -73,13 +73,9 @@ $XFS_IO_PROG -a -c "pwrite 0 5k" -c "fsync" \
        $SCRATCH_MNT/testfile \
        | _show_wrote_and_stat_only
 
-echo "# unmounting scratch"
-_scratch_unmount>>$seqres.full 2>&1 \
-    || _fail "unmount failed"
-
-echo "# mounting scratch"
-_scratch_mount >>$seqres.full 2>&1 \
-    || _fail "mount failed: $MOUNT_OPTIONS"
+echo "# remounting scratch"
+_scratch_cycle_mount >>$seqres.full 2>&1 \
+    || _fail "remount failed: $MOUNT_OPTIONS"
 
 echo "# stating file to confirm correct size"
 $XFS_IO_PROG -r -c "stat" $SCRATCH_MNT/testfile \
@@ -90,13 +86,9 @@ $XFS_IO_PROG -f -c "pwrite 0 5" -c s -c "pwrite 5 5" \
        -c "stat" $SCRATCH_MNT/nextfile \
        | _show_wrote_and_stat_only
 
-echo "# unmounting scratch"
-_scratch_unmount>>$seqres.full 2>&1 \
-    || _fail "unmount failed"
-
-echo "# mounting scratch"
-_scratch_mount >>$seqres.full 2>&1 \
-    || _fail "mount failed: $MOUNT_OPTIONS"
+echo "# remounting scratch"
+_scratch_cycle_mount >>$seqres.full 2>&1 \
+    || _fail "remount failed: $MOUNT_OPTIONS"
 
 echo "# stating file to confirm correct size"
 $XFS_IO_PROG -r -c "stat" $SCRATCH_MNT/nextfile \
index 22a5b77a693801e9ae3dbbd6ce179c4b87ff4063..5f7df395a26886404ce0c9d607a0ad8a84e53b06 100644 (file)
@@ -5,15 +5,13 @@ wrote 5120/5120 bytes at offset 0
 wrote 5120/5120 bytes at offset 5120
 wrote 5120/5120 bytes at offset 10240
 stat.size = 15360
-# unmounting scratch
-# mounting scratch
+# remounting scratch
 # stating file to confirm correct size
 stat.size = 15360
 # appending 10 bytes to new file, sync at 5 bytes
 wrote 5/5 bytes at offset 0
 wrote 5/5 bytes at offset 5
 stat.size = 10
-# unmounting scratch
-# mounting scratch
+# remounting scratch
 # stating file to confirm correct size
 stat.size = 10
index ebabea2747d30a62b61b7b0d1fe14a0a82feeb7b..6bbc87cec89af57112af41299a56978e494d768b 100755 (executable)
@@ -78,8 +78,7 @@ cat $testfile
 time2=`_access_time $testfile | tee -a $seqres.full`
 
 cd /
-_test_unmount
-_test_mount
+_test_cycle_mount
 time3=`_access_time $testfile | tee -a $seqres.full`
 
 delta1=`expr $time2 - $time1`
index b12965a0f01dcf1148bfe0fdf22978c79e3f2732..a099ec6daef0e676a60b0e43e45e182d673ffc77 100755 (executable)
@@ -61,8 +61,7 @@ for I in `seq 1 $loops`; do
 done
 
 echo
-_scratch_unmount
-_scratch_mount
+_scratch_cycle_mount
 
 echo "--> $loops direct 64m writes in a loop"
 for I in `seq 1 $loops`; do
index 285a422925bb49a33e31a09e8bb711dbc2775109..d28437ffbf6743804eb821356e1586924c5674ed 100755 (executable)
@@ -62,8 +62,7 @@ fi
 
 # unmount, remount, and check the timestamp
 echo "Remounting to flush cache"
-_test_unmount
-_test_mount
+_test_cycle_mount
 
 # Should yield -315593940 (prior to epoch)
 echo "Testing for negative seconds since epoch"
index 64d8cded120674e9d099b4258a7fafcfd47dc72e..86fd8293003638b465e4c9a99019a72f84aa9cf2 100755 (executable)
@@ -67,8 +67,7 @@ touch $BINDFILE || _fail "Could not create bind mount file"
 touch $TARGET || _fail "Could not create symlink target"
 ln -s $TARGET $SYMLINK
 
-_scratch_unmount || _fail "Could not unmount scratch device"
-_scratch_mount -o ro || _fail "Could not mount scratch readonly"
+_scratch_remount ro || _fail "Could not remount scratch readonly"
 
 # We should be able to read & write to/from these devices even on an RO fs
 echo "== try to create new file"
index 68f231c72a1df2fdbbd7eba830ba19aeb3cf08ce..a5d8804419ef7faaf8d70a98e68b3a40fda30f8a 100755 (executable)
@@ -96,8 +96,7 @@ echo ""
 echo "*** Remounting ***"
 echo ""
 sync
-_scratch_unmount >>$seqres.full 2>&1
-_scratch_mount      >>$seqres.full 2>&1 || _fail "mount failed"
+_scratch_cycle_mount      >>$seqres.full 2>&1 || _fail "remount failed"
 
 _print_numeric_uid
 
index c730b501251b63268c51fbe37871038ff5139b7a..f850a9b3e40a97bdf58d461eceac69a5da64cb53 100755 (executable)
@@ -109,8 +109,7 @@ _print_getfacls
 echo "*** Remounting ***"
 echo ""
 sync
-_scratch_unmount >>$seqres.full 2>&1
-_scratch_mount      >>$seqres.full 2>&1 || _fail "mount failed"
+_scratch_cycle_mount      >>$seqres.full 2>&1 || _fail "remount failed"
 
 _print_getfacls