]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic: test i_mode recovery after power failure
authorChao Yu <yuchao0@huawei.com>
Tue, 5 Mar 2019 11:47:44 +0000 (19:47 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sat, 9 Mar 2019 10:19:01 +0000 (18:19 +0800)
After fsync, filesystem should guarantee inode metadata including
permission info being persisted, so even after sudden power-cut,
during mount, we should recover i_mode fields correctly, in order
to not loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/535 [new file with mode: 0755]
tests/generic/535.out [new file with mode: 0644]
tests/generic/group

diff --git a/tests/generic/535 b/tests/generic/535
new file mode 100755 (executable)
index 0000000..3a6801c
--- /dev/null
@@ -0,0 +1,105 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Huawei.  All Rights Reserved.
+#
+# FS QA Test 535
+#
+# This testcase is trying to test recovery flow of generic filesystem,
+# w/ below steps, once i_mode changes, after we fsync that file, we can
+# expect that i_mode can be recovered after sudden power-cuts.
+# 1. touch testfile or mkdir testdir
+# 2. chmod 777 testfile/testdir
+# 3. sync
+# 4. chmod 755 testfile/testdir
+# 5. fsync testfile/testdir
+# 6. record last i_mode
+# 7. flakey drop
+# 8. remount
+# 9. check i_mode
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       _cleanup_flakey
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmflakey
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_dm_target flakey
+
+_scratch_mkfs >/dev/null 2>&1
+_require_metadata_journaling $SCRATCH_DEV
+_init_flakey
+
+testfile=$SCRATCH_MNT/testfile
+testdir=$SCRATCH_MNT/testdir
+
+do_check()
+{
+       local target=$1
+       local is_dir=$2
+
+       _mount_flakey
+
+       if [ $is_dir = 1 ]; then
+               mkdir $target
+       else
+               touch $target
+       fi
+
+       echo "Test chmod $target" >> $seqres.full
+
+       chmod 777 $target
+       sync
+
+       chmod 755 $target
+       $XFS_IO_PROG $target -c "fsync"
+
+       local before=`stat -c %a $target`
+
+       _flakey_drop_and_remount
+
+       local after=`stat -c %a $target`
+
+       # check inode's i_mode
+       if [ "$before" != "$after" ]; then
+               echo "Before: $before"
+               echo "After : $after"
+       fi
+
+       if [ $is_dir = 1 ]; then
+               rmdir $target
+       else
+               rm -f $target
+       fi
+       _unmount_flakey
+}
+
+echo "Silence is golden"
+
+do_check $testfile 0
+do_check $testdir 1
+
+status=0
+exit
diff --git a/tests/generic/535.out b/tests/generic/535.out
new file mode 100644 (file)
index 0000000..f4e95f8
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 535
+Silence is golden
index 7aff620d0951234b8574e20ad8d4c6656032a0ea..78b9b45d62bbb5903d25c00d255b78c2db79aad1 100644 (file)
 532 auto quick
 533 auto quick attr
 534 auto quick log
+535 auto quick log