xfs: test what happens when we reset the root dir and it has xattrs
authorDarrick J. Wong <djwong@kernel.org>
Wed, 28 Apr 2021 04:08:43 +0000 (21:08 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 9 May 2021 15:19:32 +0000 (23:19 +0800)
Make sure that we can reset the root directory and the xattrs are erased
properly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/xfs/162 [new file with mode: 0755]
tests/xfs/162.out [new file with mode: 0644]
tests/xfs/group

diff --git a/tests/xfs/162 b/tests/xfs/162
new file mode 100755 (executable)
index 0000000..e3257a3
--- /dev/null
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 162
+#
+# Make sure that attrs are handled properly when repair has to reset the root
+# directory.
+#
+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 7 15
+
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/populate
+. ./common/fuzzy
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch_nocheck
+
+rm -f $seqres.full
+
+echo "Format and populate btree attr root dir"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+__populate_create_attr "${SCRATCH_MNT}" "$((64 * blksz / 40))" true
+_scratch_unmount
+
+echo "Break the root directory"
+_scratch_xfs_fuzz_metadata_field core.mode zeroes 'sb 0' 'addr rootino' >> $seqres.full 2>&1
+
+echo "Detect bad root directory"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 && \
+       echo "Should have detected bad root dir"
+
+echo "Fix bad root directory"
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "Detect fixed root directory"
+_scratch_xfs_repair -n >> $seqres.full 2>&1
+
+echo "Mount test"
+_scratch_mount
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/162.out b/tests/xfs/162.out
new file mode 100644 (file)
index 0000000..e74c4db
--- /dev/null
@@ -0,0 +1,7 @@
+QA output created by 162
+Format and populate btree attr root dir
+Break the root directory
+Detect bad root directory
+Fix bad root directory
+Detect fixed root directory
+Mount test
index 7d2ab08e84193e384a0c10851d64d69569737cb3..6fa4b66022eb095b1d1b590970977dcdc56c2451 100644 (file)
 159 auto quick bigtime
 160 auto quick bigtime
 161 auto quick bigtime quota
 159 auto quick bigtime
 160 auto quick bigtime
 161 auto quick bigtime quota
+162 auto quick attr repair
 164 rw pattern auto prealloc quick
 165 rw pattern auto prealloc quick
 166 rw metadata auto quick
 164 rw pattern auto prealloc quick
 165 rw pattern auto prealloc quick
 166 rw metadata auto quick