FSTests Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] xfstest: add a test for the btrfs file extent gap issue
@ 2020-01-30 20:52 Josef Bacik
  2020-01-31  9:33 ` Filipe Manana
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2020-01-30 20:52 UTC (permalink / raw)
  To: fstests, linux-btrfs, kernel-team

This is a test to validate that we're not adjusting up i_size before we
have the appropriate file extents on disk.  We had a problem where
i_size would be adjusted up without a contiguous range of file extents,
which isn't ok without a special option enabled.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/172.out |  3 ++
 tests/btrfs/group   |  1 +
 3 files changed, 78 insertions(+)
 create mode 100755 tests/btrfs/172
 create mode 100644 tests/btrfs/172.out

diff --git a/tests/btrfs/172 b/tests/btrfs/172
new file mode 100755
index 00000000..8c0c94d6
--- /dev/null
+++ b/tests/btrfs/172
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Facebook.  All Rights Reserved.
+#
+# FS QA Test 172
+#
+# Validate that without no-holes we do not get an i_size that is after a gap in
+# the file extents on disk.  This is fixed by the series
+#
+#     btrfs: fix hole corruption issue with !NO_HOLES
+#
+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
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_log_writes
+
+_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 5 so we're sure to get
+# a commit with our broken file
+_log_writes_mount -o commit=5
+
+$XFS_IO_PROG -f -c "pwrite 0 5m" $SCRATCH_MNT/file | _filter_xfs_io
+$XFS_IO_PROG -f -c "sync_range -abw 2m 1m" $SCRATCH_MNT/file | _filter_xfs_io
+
+# Now wait for a transaction commit to happen, wait 2x just to be super sure
+sleep 10
+
+_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/172.out b/tests/btrfs/172.out
new file mode 100644
index 00000000..45051739
--- /dev/null
+++ b/tests/btrfs/172.out
@@ -0,0 +1,3 @@
+QA output created by 172
+wrote 5242880/5242880 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 4b64bf8b..527fbbf1 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -174,6 +174,7 @@
 169 auto quick send
 170 auto quick snapshot
 171 auto quick qgroup
+172 auto quick
 173 auto quick swap
 174 auto quick swap
 175 auto quick swap volume
-- 
2.24.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] xfstest: add a test for the btrfs file extent gap issue
  2020-01-30 20:52 [PATCH] xfstest: add a test for the btrfs file extent gap issue Josef Bacik
@ 2020-01-31  9:33 ` Filipe Manana
  0 siblings, 0 replies; 2+ messages in thread
From: Filipe Manana @ 2020-01-31  9:33 UTC (permalink / raw)
  To: Josef Bacik; +Cc: fstests, linux-btrfs, kernel-team

On Thu, Jan 30, 2020 at 8:52 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> This is a test to validate that we're not adjusting up i_size before we
> have the appropriate file extents on disk.  We had a problem where
> i_size would be adjusted up without a contiguous range of file extents,
> which isn't ok without a special option enabled.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/172.out |  3 ++
>  tests/btrfs/group   |  1 +
>  3 files changed, 78 insertions(+)
>  create mode 100755 tests/btrfs/172
>  create mode 100644 tests/btrfs/172.out
>
> diff --git a/tests/btrfs/172 b/tests/btrfs/172
> new file mode 100755
> index 00000000..8c0c94d6
> --- /dev/null
> +++ b/tests/btrfs/172
> @@ -0,0 +1,74 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Facebook.  All Rights Reserved.
> +#
> +# FS QA Test 172
> +#
> +# Validate that without no-holes we do not get an i_size that is after a gap in
> +# the file extents on disk.  This is fixed by the series
> +#
> +#     btrfs: fix hole corruption issue with !NO_HOLES

A list of the patch subjects would be better imho, since those are
grepable in git.

> +#
> +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
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_log_writes

Missing:  _require_xfs_io_command "sync_range"

> +
> +_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 5 so we're sure to get
> +# a commit with our broken file
> +_log_writes_mount -o commit=5
> +
> +$XFS_IO_PROG -f -c "pwrite 0 5m" $SCRATCH_MNT/file | _filter_xfs_io
> +$XFS_IO_PROG -f -c "sync_range -abw 2m 1m" $SCRATCH_MNT/file | _filter_xfs_io
> +
> +# Now wait for a transaction commit to happen, wait 2x just to be super sure
> +sleep 10

Could be 6s. Saving test run time for something so trivial.

> +
> +_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/172.out b/tests/btrfs/172.out
> new file mode 100644
> index 00000000..45051739
> --- /dev/null
> +++ b/tests/btrfs/172.out
> @@ -0,0 +1,3 @@
> +QA output created by 172
> +wrote 5242880/5242880 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 4b64bf8b..527fbbf1 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -174,6 +174,7 @@
>  169 auto quick send
>  170 auto quick snapshot
>  171 auto quick qgroup
> +172 auto quick

Missing 'log' and 'replay' groups, like all other dmlogwrites tests.

Other than that it looks good, thanks.

>  173 auto quick swap
>  174 auto quick swap
>  175 auto quick swap volume
> --
> 2.24.1
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-30 20:52 [PATCH] xfstest: add a test for the btrfs file extent gap issue Josef Bacik
2020-01-31  9:33 ` Filipe Manana

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git