* [PATCH] fstests: btrfs/246: add test case to make sure btrfs can create compressed inline extent
@ 2021-08-25 6:19 Qu Wenruo
2021-08-25 14:24 ` Filipe Manana
0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2021-08-25 6:19 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs
Btrfs has the ability to inline small file extents into its metadata,
and such inlined extents can be further compressed if needed.
The new test case is for a regression caused by commit f2165627319f
("btrfs: compression: don't try to compress if we don't have enough
pages").
That commit prevents btrfs from creating compressed inline extents, even
"-o compress,max_inline=2048" is specified, only uncompressed inline
extents can be created.
The test case will use "btrfs inspect dump-tree" to verify the created
extent is both inlined and compressed.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
tests/btrfs/246 | 50 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/246.out | 2 ++
2 files changed, 52 insertions(+)
create mode 100755 tests/btrfs/246
create mode 100644 tests/btrfs/246.out
diff --git a/tests/btrfs/246 b/tests/btrfs/246
new file mode 100755
index 00000000..15bb064d
--- /dev/null
+++ b/tests/btrfs/246
@@ -0,0 +1,50 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test 246
+#
+# Make sure btrfs can create compressed inline extents
+#
+. ./common/preamble
+_begin_fstest auto quick compress
+
+# Override the default cleanup function.
+_cleanup()
+{
+ cd /
+ rm -r -f $tmp.*
+}
+
+# Import common functions.
+. ./common/filter
+# For __populate_find_inode()
+. ./common/populate
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_require_scratch
+
+_scratch_mkfs > /dev/null
+_scratch_mount -o compress,max_inline=2048
+
+# This should create compressed inline extent
+$XFS_IO_PROG -f -c "pwrite 0 2048" $SCRATCH_MNT/foobar > /dev/null
+ino=$(__populate_find_inode $SCRATCH_MNT/foobar)
+_scratch_unmount
+
+$BTRFS_UTIL_PROG inspect dump-tree -t 5 $SCRATCH_DEV | \
+ grep "($ino EXTENT_DATA 0" -A2 > $tmp.dump-tree
+echo "dump tree result for ino $ino:" >> $seqres.full
+cat $tmp.dump-tree >> $seqres.full
+
+grep -q "inline extent" $tmp.dump-tree || echo "no inline extent found"
+grep -q "compression 1" $tmp.dump-tree || echo "no compressed extent found"
+
+echo "Silence is golden"
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/246.out b/tests/btrfs/246.out
new file mode 100644
index 00000000..287f7983
--- /dev/null
+++ b/tests/btrfs/246.out
@@ -0,0 +1,2 @@
+QA output created by 246
+Silence is golden
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fstests: btrfs/246: add test case to make sure btrfs can create compressed inline extent
2021-08-25 6:19 [PATCH] fstests: btrfs/246: add test case to make sure btrfs can create compressed inline extent Qu Wenruo
@ 2021-08-25 14:24 ` Filipe Manana
2021-08-25 22:45 ` Qu Wenruo
0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2021-08-25 14:24 UTC (permalink / raw)
To: Qu Wenruo; +Cc: fstests, linux-btrfs
On Wed, Aug 25, 2021 at 7:19 AM Qu Wenruo <wqu@suse.com> wrote:
>
> Btrfs has the ability to inline small file extents into its metadata,
> and such inlined extents can be further compressed if needed.
>
> The new test case is for a regression caused by commit f2165627319f
> ("btrfs: compression: don't try to compress if we don't have enough
> pages").
>
> That commit prevents btrfs from creating compressed inline extents, even
> "-o compress,max_inline=2048" is specified, only uncompressed inline
> extents can be created.
>
> The test case will use "btrfs inspect dump-tree" to verify the created
> extent is both inlined and compressed.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> tests/btrfs/246 | 50 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/246.out | 2 ++
> 2 files changed, 52 insertions(+)
> create mode 100755 tests/btrfs/246
> create mode 100644 tests/btrfs/246.out
>
> diff --git a/tests/btrfs/246 b/tests/btrfs/246
> new file mode 100755
> index 00000000..15bb064d
> --- /dev/null
> +++ b/tests/btrfs/246
> @@ -0,0 +1,50 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2021 SUSE Linux Products GmbH. All Rights Reserved.
> +#
> +# FS QA Test 246
> +#
> +# Make sure btrfs can create compressed inline extents
> +#
> +. ./common/preamble
> +_begin_fstest auto quick compress
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> + cd /
> + rm -r -f $tmp.*
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +# For __populate_find_inode()
> +. ./common/populate
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_require_scratch
> +
> +_scratch_mkfs > /dev/null
> +_scratch_mount -o compress,max_inline=2048
> +
> +# This should create compressed inline extent
> +$XFS_IO_PROG -f -c "pwrite 0 2048" $SCRATCH_MNT/foobar > /dev/null
> +ino=$(__populate_find_inode $SCRATCH_MNT/foobar)
> +_scratch_unmount
> +
> +$BTRFS_UTIL_PROG inspect dump-tree -t 5 $SCRATCH_DEV | \
> + grep "($ino EXTENT_DATA 0" -A2 > $tmp.dump-tree
> +echo "dump tree result for ino $ino:" >> $seqres.full
> +cat $tmp.dump-tree >> $seqres.full
> +
> +grep -q "inline extent" $tmp.dump-tree || echo "no inline extent found"
> +grep -q "compression 1" $tmp.dump-tree || echo "no compressed extent found"
> +
> +echo "Silence is golden"
While here, we could also check that we are able to read exactly what
we wrote before, after evicting the page (e.g. after a call to
_scratch_cycle_mount).
Other than that, it looks ok.
Thanks.
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/246.out b/tests/btrfs/246.out
> new file mode 100644
> index 00000000..287f7983
> --- /dev/null
> +++ b/tests/btrfs/246.out
> @@ -0,0 +1,2 @@
> +QA output created by 246
> +Silence is golden
> --
> 2.31.1
>
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fstests: btrfs/246: add test case to make sure btrfs can create compressed inline extent
2021-08-25 14:24 ` Filipe Manana
@ 2021-08-25 22:45 ` Qu Wenruo
0 siblings, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2021-08-25 22:45 UTC (permalink / raw)
To: fdmanana, Qu Wenruo; +Cc: fstests, linux-btrfs
On 2021/8/25 下午10:24, Filipe Manana wrote:
> On Wed, Aug 25, 2021 at 7:19 AM Qu Wenruo <wqu@suse.com> wrote:
>>
>> Btrfs has the ability to inline small file extents into its metadata,
>> and such inlined extents can be further compressed if needed.
>>
>> The new test case is for a regression caused by commit f2165627319f
>> ("btrfs: compression: don't try to compress if we don't have enough
>> pages").
>>
>> That commit prevents btrfs from creating compressed inline extents, even
>> "-o compress,max_inline=2048" is specified, only uncompressed inline
>> extents can be created.
>>
>> The test case will use "btrfs inspect dump-tree" to verify the created
>> extent is both inlined and compressed.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>> tests/btrfs/246 | 50 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/246.out | 2 ++
>> 2 files changed, 52 insertions(+)
>> create mode 100755 tests/btrfs/246
>> create mode 100644 tests/btrfs/246.out
>>
>> diff --git a/tests/btrfs/246 b/tests/btrfs/246
>> new file mode 100755
>> index 00000000..15bb064d
>> --- /dev/null
>> +++ b/tests/btrfs/246
>> @@ -0,0 +1,50 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2021 SUSE Linux Products GmbH. All Rights Reserved.
>> +#
>> +# FS QA Test 246
>> +#
>> +# Make sure btrfs can create compressed inline extents
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick compress
>> +
>> +# Override the default cleanup function.
>> +_cleanup()
>> +{
>> + cd /
>> + rm -r -f $tmp.*
>> +}
>> +
>> +# Import common functions.
>> +. ./common/filter
>> +# For __populate_find_inode()
>> +. ./common/populate
>> +
>> +# real QA test starts here
>> +
>> +# Modify as appropriate.
>> +_supported_fs btrfs
>> +_require_scratch
>> +
>> +_scratch_mkfs > /dev/null
>> +_scratch_mount -o compress,max_inline=2048
>> +
>> +# This should create compressed inline extent
>> +$XFS_IO_PROG -f -c "pwrite 0 2048" $SCRATCH_MNT/foobar > /dev/null
>> +ino=$(__populate_find_inode $SCRATCH_MNT/foobar)
>> +_scratch_unmount
>> +
>> +$BTRFS_UTIL_PROG inspect dump-tree -t 5 $SCRATCH_DEV | \
>> + grep "($ino EXTENT_DATA 0" -A2 > $tmp.dump-tree
>> +echo "dump tree result for ino $ino:" >> $seqres.full
>> +cat $tmp.dump-tree >> $seqres.full
>> +
>> +grep -q "inline extent" $tmp.dump-tree || echo "no inline extent found"
>> +grep -q "compression 1" $tmp.dump-tree || echo "no compressed extent found"
>> +
>> +echo "Silence is golden"
>
> While here, we could also check that we are able to read exactly what
> we wrote before, after evicting the page (e.g. after a call to
> _scratch_cycle_mount).
Nice idea.
Will update the test case soon.
Thanks,
Qu
> Other than that, it looks ok.
>
> Thanks.
>
>
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/246.out b/tests/btrfs/246.out
>> new file mode 100644
>> index 00000000..287f7983
>> --- /dev/null
>> +++ b/tests/btrfs/246.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 246
>> +Silence is golden
>> --
>> 2.31.1
>>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-25 22:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 6:19 [PATCH] fstests: btrfs/246: add test case to make sure btrfs can create compressed inline extent Qu Wenruo
2021-08-25 14:24 ` Filipe Manana
2021-08-25 22:45 ` Qu Wenruo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).