]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic: move test case btrfs/261 into the generic group
authorFilipe Manana <fdmanana@suse.com>
Thu, 3 Mar 2022 11:40:21 +0000 (11:40 +0000)
committerEryu Guan <guaneryu@gmail.com>
Sun, 20 Mar 2022 16:26:40 +0000 (00:26 +0800)
The test case btrfs/261, part from its comments, doesn't really exercise
any behaviour that is btrfs specific, so, as Dave Chinner pointed out, it
can be moved into the generic group.

This change moves that test into the generic group and slightly adjust the
comments to make it clear which parts are btrfs specific.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/261 [deleted file]
tests/btrfs/261.out [deleted file]
tests/generic/677 [new file with mode: 0755]
tests/generic/677.out [new file with mode: 0644]

diff --git a/tests/btrfs/261 b/tests/btrfs/261
deleted file mode 100755 (executable)
index 8275e6a..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#! /bin/bash
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2022 SUSE Linux Products GmbH.  All Rights Reserved.
-#
-# FS QA Test 261
-#
-# Test that after a full fsync of a file with preallocated extents beyond the
-# file's size, if a power failure happens, the preallocated extents still exist
-# after we mount the filesystem.
-#
-. ./common/preamble
-_begin_fstest auto quick log prealloc
-
-_cleanup()
-{
-       _cleanup_flakey
-       cd /
-       rm -r -f $tmp.*
-}
-
-. ./common/rc
-. ./common/filter
-. ./common/dmflakey
-. ./common/punch
-
-# real QA test starts here
-
-_supported_fs btrfs
-_require_scratch
-_require_dm_target flakey
-_require_xfs_io_command "falloc" "-k"
-_require_xfs_io_command "fiemap"
-_require_odirect
-
-rm -f $seqres.full
-
-_scratch_mkfs >>$seqres.full 2>&1
-_require_metadata_journaling $SCRATCH_DEV
-_init_flakey
-_mount_flakey
-
-# Create our test file with many file extent items, so that they span several
-# leaves of metadata, even if the node/page size is 64K. We use direct IO and
-# not fsync/O_SYNC because it's both faster and it avoids clearing the full sync
-# flag from the inode - we want the fsync below to trigger the slow full sync
-# code path.
-$XFS_IO_PROG -f -d -c "pwrite -b 4K 0 16M" $SCRATCH_MNT/foo | _filter_xfs_io
-
-# Now add two preallocated extents to our file without extending the file's size.
-# One right at i_size, and another further beyond, leaving a gap between the two
-# prealloc extents.
-$XFS_IO_PROG -c "falloc -k 16M 1M" $SCRATCH_MNT/foo
-$XFS_IO_PROG -c "falloc -k 20M 1M" $SCRATCH_MNT/foo
-
-# Make sure everything is durably persisted and the transaction is committed.
-# This makes all created extents to have a generation lower than the generation
-# of the transaction used by the next write and fsync.
-sync
-
-# Now overwrite only the first extent, which will result in modifying only the
-# first leaf of metadata for our inode. Then fsync it. This fsync will use the
-# slow code path (inode full sync bit is set) because it's the first fsync since
-# the inode was created/loaded.
-$XFS_IO_PROG -c "pwrite 0 4K" -c "fsync" $SCRATCH_MNT/foo | _filter_xfs_io
-
-# Simulate a power failure and then mount again the filesystem to replay the log
-# tree.
-_flakey_drop_and_remount
-
-# After the power failure we expect that the preallocated extents, beyond the
-# inode's i_size, still exist.
-echo "List of extents after power failure:"
-$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foo | _filter_fiemap
-
-_unmount_flakey
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/261.out b/tests/btrfs/261.out
deleted file mode 100644 (file)
index e9cfe1e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-QA output created by 261
-wrote 16777216/16777216 bytes at offset 0
-XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 4096/4096 bytes at offset 0
-XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-List of extents after power failure:
-0: [0..32767]: data
-1: [32768..34815]: unwritten
-2: [34816..40959]: hole
-3: [40960..43007]: unwritten
diff --git a/tests/generic/677 b/tests/generic/677
new file mode 100755 (executable)
index 0000000..1d4eaa5
--- /dev/null
@@ -0,0 +1,86 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 SUSE Linux Products GmbH.  All Rights Reserved.
+#
+# FS QA Test 677
+#
+# Test that after a full fsync of a file with preallocated extents beyond the
+# file's size, if a power failure happens, the preallocated extents still exist
+# after we mount the filesystem.
+#
+. ./common/preamble
+_begin_fstest auto quick log prealloc
+
+_cleanup()
+{
+       _cleanup_flakey
+       cd /
+       rm -r -f $tmp.*
+}
+
+. ./common/rc
+. ./common/filter
+. ./common/dmflakey
+. ./common/punch
+
+# real QA test starts here
+
+_supported_fs generic
+_require_scratch
+_require_dm_target flakey
+_require_xfs_io_command "falloc" "-k"
+_require_xfs_io_command "fiemap"
+_require_odirect
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+_require_metadata_journaling $SCRATCH_DEV
+_init_flakey
+_mount_flakey
+
+# Create our test file with many extents.
+# On btrfs this results in having multiple leaves of metadata full of file
+# extent items, a condition necessary to trigger the original bug.
+#
+# We use direct IO here because:
+#
+# 1) It's faster then doing fsync after each buffered write;
+#
+# 2) For btrfs, the first fsync would clear the inode's full sync runtime flag,
+#    and we want the fsync below to trigger the full fsync code path of btrfs.
+$XFS_IO_PROG -f -d -c "pwrite -b 4K 0 16M" $SCRATCH_MNT/foo | _filter_xfs_io
+
+# Now add two preallocated extents to our file without extending the file's size.
+# One right at i_size, and another further beyond, leaving a gap between the two
+# prealloc extents.
+$XFS_IO_PROG -c "falloc -k 16M 1M" $SCRATCH_MNT/foo
+$XFS_IO_PROG -c "falloc -k 20M 1M" $SCRATCH_MNT/foo
+
+# Make sure everything is durably persisted.
+# On btrfs this commits the current transaction and it makes all the created
+# extents to have a generation lower than the generation of the transaction used
+# by the next write and fsync.
+sync
+
+# Now overwrite only the first extent.
+# On btrfs, due to COW (both data and metadata), that results in modifying only
+# the first leaf of metadata for our inode (we replace a file extent item and
+# update the inode item). Then fsync it. On btrfs this fsync will use the slow
+# code path because it's the first fsync since the inode was created/loaded.
+$XFS_IO_PROG -c "pwrite 0 4K" -c "fsync" $SCRATCH_MNT/foo | _filter_xfs_io
+
+# Simulate a power failure and then mount again the filesystem to replay the log
+# tree.
+_flakey_drop_and_remount
+
+# After the power failure we expect that the preallocated extents, beyond the
+# inode's i_size, still exist.
+echo "List of extents after power failure:"
+$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foo | _filter_fiemap
+
+_unmount_flakey
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/677.out b/tests/generic/677.out
new file mode 100644 (file)
index 0000000..4c91a0d
--- /dev/null
@@ -0,0 +1,10 @@
+QA output created by 677
+wrote 16777216/16777216 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 4096/4096 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+List of extents after power failure:
+0: [0..32767]: data
+1: [32768..34815]: unwritten
+2: [34816..40959]: hole
+3: [40960..43007]: unwritten