diff mbox series

[v7] btrfs: test block group size class loading logic

Message ID a5d8e8988d8ea9c8ee81a96c69566a112527dccd.1676562365.git.boris@bur.io (mailing list archive)
State New, archived
Headers show
Series [v7] btrfs: test block group size class loading logic | expand

Commit Message

Boris Burkov Feb. 16, 2023, 3:47 p.m. UTC
Add a new test which checks that size classes in freshly loaded block
groups after a cycle mount match size classes before going down

Depends on the kernel patch:
btrfs: add size class stats to sysfs

Signed-off-by: Boris Burkov <boris@bur.io>
---
Changelog:
v7:
Rebase, move to btrfs/284.
Remove mount test group.
v6:
Actually include changes for v5 in the commit.
v5:
Instead of using _fixed_by_kernel_commit, use require_fs_sysfs to handle
the needed sysfs file. The test is skipped on kernels without the file
and runs correctly on new ones.
v4:
Fix dumb typo in _fixed_by_kernel_commit (left out leading underscore
copy+pasting). Re-tested happy and sad case...
v3:
Re-add fixed_by_kernel_commit, but for the stats patch which is
required, but not a fix in the strictest sense.
v2:
Drop the fixed_by_kernel_commit since the fix is not out past the btrfs
development tree, so the fix is getting rolled in to the original broken
commit. Modified the commit message to note the dependency on the new
sysfs counters.

 tests/btrfs/284     | 50 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/284.out |  2 ++
 2 files changed, 52 insertions(+)
 create mode 100755 tests/btrfs/284
 create mode 100644 tests/btrfs/284.out

Comments

Filipe Manana Feb. 16, 2023, 4:23 p.m. UTC | #1
On Thu, Feb 16, 2023 at 3:54 PM Boris Burkov <boris@bur.io> wrote:
>
> Add a new test which checks that size classes in freshly loaded block
> groups after a cycle mount match size classes before going down
>
> Depends on the kernel patch:
> btrfs: add size class stats to sysfs
>
> Signed-off-by: Boris Burkov <boris@bur.io>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good to me now, thanks.

> ---
> Changelog:
> v7:
> Rebase, move to btrfs/284.
> Remove mount test group.
> v6:
> Actually include changes for v5 in the commit.
> v5:
> Instead of using _fixed_by_kernel_commit, use require_fs_sysfs to handle
> the needed sysfs file. The test is skipped on kernels without the file
> and runs correctly on new ones.
> v4:
> Fix dumb typo in _fixed_by_kernel_commit (left out leading underscore
> copy+pasting). Re-tested happy and sad case...
> v3:
> Re-add fixed_by_kernel_commit, but for the stats patch which is
> required, but not a fix in the strictest sense.
> v2:
> Drop the fixed_by_kernel_commit since the fix is not out past the btrfs
> development tree, so the fix is getting rolled in to the original broken
> commit. Modified the commit message to note the dependency on the new
> sysfs counters.
>
>  tests/btrfs/284     | 50 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/284.out |  2 ++
>  2 files changed, 52 insertions(+)
>  create mode 100755 tests/btrfs/284
>  create mode 100644 tests/btrfs/284.out
>
> diff --git a/tests/btrfs/284 b/tests/btrfs/284
> new file mode 100755
> index 00000000..340b3cd9
> --- /dev/null
> +++ b/tests/btrfs/284
> @@ -0,0 +1,50 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.
> +#
> +# FS QA Test 284
> +#
> +# Test that mounting a btrfs filesystem properly loads block group size classes.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +sysfs_size_classes() {
> +       local uuid="$(findmnt -n -o UUID "$SCRATCH_MNT")"
> +       cat "/sys/fs/btrfs/$uuid/allocation/data/size_classes"
> +}
> +
> +_supported_fs btrfs
> +_require_scratch
> +_require_btrfs_fs_sysfs
> +_require_fs_sysfs allocation/data/size_classes
> +
> +f="$SCRATCH_MNT/f"
> +small=$((16 * 1024))
> +medium=$((1024 * 1024))
> +large=$((16 * 1024 * 1024))
> +
> +_scratch_mkfs >/dev/null
> +_scratch_mount
> +# Write files with extents in each size class
> +$XFS_IO_PROG -fc "pwrite -q 0 $small" $f.small
> +$XFS_IO_PROG -fc "pwrite -q 0 $medium" $f.medium
> +$XFS_IO_PROG -fc "pwrite -q 0 $large" $f.large
> +# Sync to force the extent allocation
> +sync
> +pre=$(sysfs_size_classes)
> +
> +# cycle mount to drop the block group cache
> +_scratch_cycle_mount
> +
> +# Another write causes us to actually load the block groups
> +$XFS_IO_PROG -fc "pwrite -q 0 $large" $f.large.2
> +sync
> +
> +post=$(sysfs_size_classes)
> +diff <(echo $pre) <(echo $post)
> +
> +echo "Silence is golden"
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/284.out b/tests/btrfs/284.out
> new file mode 100644
> index 00000000..931839fe
> --- /dev/null
> +++ b/tests/btrfs/284.out
> @@ -0,0 +1,2 @@
> +QA output created by 284
> +Silence is golden
> --
> 2.39.1
>
diff mbox series

Patch

diff --git a/tests/btrfs/284 b/tests/btrfs/284
new file mode 100755
index 00000000..340b3cd9
--- /dev/null
+++ b/tests/btrfs/284
@@ -0,0 +1,50 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.
+#
+# FS QA Test 284
+#
+# Test that mounting a btrfs filesystem properly loads block group size classes.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+sysfs_size_classes() {
+	local uuid="$(findmnt -n -o UUID "$SCRATCH_MNT")"
+	cat "/sys/fs/btrfs/$uuid/allocation/data/size_classes"
+}
+
+_supported_fs btrfs
+_require_scratch
+_require_btrfs_fs_sysfs
+_require_fs_sysfs allocation/data/size_classes
+
+f="$SCRATCH_MNT/f"
+small=$((16 * 1024))
+medium=$((1024 * 1024))
+large=$((16 * 1024 * 1024))
+
+_scratch_mkfs >/dev/null
+_scratch_mount
+# Write files with extents in each size class
+$XFS_IO_PROG -fc "pwrite -q 0 $small" $f.small
+$XFS_IO_PROG -fc "pwrite -q 0 $medium" $f.medium
+$XFS_IO_PROG -fc "pwrite -q 0 $large" $f.large
+# Sync to force the extent allocation
+sync
+pre=$(sysfs_size_classes)
+
+# cycle mount to drop the block group cache
+_scratch_cycle_mount
+
+# Another write causes us to actually load the block groups
+$XFS_IO_PROG -fc "pwrite -q 0 $large" $f.large.2
+sync
+
+post=$(sysfs_size_classes)
+diff <(echo $pre) <(echo $post)
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/284.out b/tests/btrfs/284.out
new file mode 100644
index 00000000..931839fe
--- /dev/null
+++ b/tests/btrfs/284.out
@@ -0,0 +1,2 @@ 
+QA output created by 284
+Silence is golden