aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-02-20 09:38:55 -0500
committerEryu Guan <guaneryu@gmail.com>2020-02-23 22:52:16 +0800
commit1d6d14db1165db1ffc87fbddcf97eb70fdf84607 (patch)
tree334dabb5d377f69fc4c15afe8df1bcc90f24d634
parent6f7ef01037d23ceb52f4bef88866f2f27e42a23a (diff)
downloadxfstests-dev-1d6d14db1165db1ffc87fbddcf97eb70fdf84607.tar.gz
fstests: add a another gap extent testcase for btrfs
This is a testcase for a corner that I missed when trying to fix gap extents for btrfs. We would end up with gaps if we hole punched past isize and then extended past the gap in a specific way. This is a simple reproducer to show the problem, and has been properly fixed by my patches now. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-xtests/btrfs/20685
-rw-r--r--tests/btrfs/206.out5
-rw-r--r--tests/btrfs/group1
3 files changed, 91 insertions, 0 deletions
diff --git a/tests/btrfs/206 b/tests/btrfs/206
new file mode 100755
index 00000000..b6503fcc
--- /dev/null
+++ b/tests/btrfs/206
@@ -0,0 +1,85 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Facebook. All Rights Reserved.
+#
+# FS QA Test 206
+#
+# Validate that without no-holes we do not get a i_size that is after a gap in
+# the file extents on disk when punching a hole past i_size. This is fixed by
+# the following patches
+#
+# btrfs: use the file extent tree infrastructure
+# btrfs: replace all uses of btrfs_ordered_update_i_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
+. ./common/dmlogwrites
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_test
+_require_scratch
+_require_log_writes
+_require_xfs_io_command "falloc" "-k"
+_require_xfs_io_command "fpunch"
+
+_log_writes_init $SCRATCH_DEV
+_log_writes_mkfs "-O ^no-holes" >> $seqres.full 2>&1
+
+# There's not a straightforward way to commit the transaction without also
+# flushing dirty pages, so shorten the commit interval to 1 so we're sure to get
+# a commit with our broken file
+_log_writes_mount -o commit=1
+
+# This creates a gap extent because fpunch doesn't insert hole extents past
+# i_size
+$XFS_IO_PROG -f -c "falloc -k 4k 8k" $SCRATCH_MNT/file
+$XFS_IO_PROG -f -c "fpunch 4k 4k" $SCRATCH_MNT/file
+
+# The pwrite extends the i_size to cover the gap extent, and then the truncate
+# sets the disk_i_size to 12k because it assumes everything was a-ok.
+$XFS_IO_PROG -f -c "pwrite 0 4k" $SCRATCH_MNT/file | _filter_xfs_io
+$XFS_IO_PROG -f -c "pwrite 0 8k" $SCRATCH_MNT/file | _filter_xfs_io
+$XFS_IO_PROG -f -c "truncate 12k" $SCRATCH_MNT/file
+
+# Wait for a transaction commit
+sleep 2
+
+_log_writes_unmount
+_log_writes_remove
+
+cur=$(_log_writes_find_next_fua 0)
+echo "cur=$cur" >> $seqres.full
+while [ ! -z "$cur" ]; do
+ _log_writes_replay_log_range $cur $SCRATCH_DEV >> $seqres.full
+
+ # We only care about the fs consistency, so just run fsck, we don't have
+ # to mount the fs to validate it
+ _check_scratch_fs
+
+ cur=$(_log_writes_find_next_fua $(($cur + 1)))
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/206.out b/tests/btrfs/206.out
new file mode 100644
index 00000000..11ce1cfa
--- /dev/null
+++ b/tests/btrfs/206.out
@@ -0,0 +1,5 @@
+QA output created by 206
+wrote 4096/4096 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
diff --git a/tests/btrfs/group b/tests/btrfs/group
index da3066fb..e3ad347b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -208,3 +208,4 @@
203 auto quick send clone
204 auto quick punch
205 auto quick clone compress
+204 auto quick log replay