]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs: regression test for rmapbt fdblocks accounting problems
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 22 Jun 2018 06:40:42 +0000 (23:40 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 1 Jul 2018 12:35:27 +0000 (20:35 +0800)
In "xfs: fix fdblocks accounting w/ RMAPBT per-AG reservation", we fixed
the per-ag reservation code so that we always decrease fdblocks by the
reserved size because rmapbt blocks are counted as free space.

The primary symptom of this bug is that if the rmapbt has expanded since
mount time, the disk block counters reported via statfs will change
across a remount. Therefore, we exercise this as a regression test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/xfs/450 [new file with mode: 0755]
tests/xfs/450.out [new file with mode: 0644]
tests/xfs/group

diff --git a/tests/xfs/450 b/tests/xfs/450
new file mode 100755 (executable)
index 0000000..15b7387
--- /dev/null
@@ -0,0 +1,64 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle, Inc.  All rights reserved.
+#
+# FS QA Test No. 450
+#
+# Make sure that the statfs b_avail counter doesn't change across remount
+# after the rmapbt has grown in size.
+#
+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()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous \$seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_test_program "punch-alternating"
+_require_xfs_scratch_rmapbt
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+
+# Make sure we allocate a big enough file such that punching out every other
+# block will cause the rmapbt to expand by at least one block.
+blksz=$(_get_file_block_size $SCRATCH_MNT)
+nr_rmap_per_rmapbt=$(( (blksz - 56) / 24))
+blks=$(( (nr_rmap_per_rmapbt + 2) * 2))
+$XFS_IO_PROG -f -c "falloc 0 $((blks * blksz))" $SCRATCH_MNT/a >> $seqres.full
+$here/src/punch-alternating $SCRATCH_MNT/a
+
+# Do the stat counters change across the remount?
+before=$(stat -f -c '%b %f' $SCRATCH_MNT)
+_scratch_cycle_mount
+after=$(stat -f -c '%b %f' $SCRATCH_MNT)
+
+if [ "${before}" != "${after}" ]; then
+       echo "counters changed: ${before} ${after}"
+       echo "before: ${before}" >> $seqres.full
+       echo "after: ${after}" >> $seqres.full
+fi
+
+echo "Silence is golden."
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/450.out b/tests/xfs/450.out
new file mode 100644 (file)
index 0000000..dedec85
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 450
+Silence is golden.
index 932ab9092419ca1dabb1fd445cb4c2df3c3fe41e..be029c7810016669ca9b4ca2c825f0cbac67dd77 100644 (file)
 447 auto mount
 448 auto quick fuzzers
 449 auto quick
+450 auto quick rmap