btrfs: test block group size class loading logic
PATCH v6 1/1 btrfs: test block group size class loading logic
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
---
Changelog:
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/283 | 50 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/283.out | 2 ++ 2 files changed, 52 insertions(+) create mode 100755 tests/btrfs/283 create mode 100644 tests/btrfs/283.out
tests/btrfs/283 new file +50 -0
@@ -0,0 +1,50 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 283 +# +# Test that mounting a btrfs filesystem properly loads block group size classes. +# +. ./common/preamble +_begin_fstest auto quick mount + +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
tests/btrfs/283.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 283 +Silence is golden
Signature · 1 line
2.39.1
Quoted 43 lines · Boris Burkov
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 sysfsSigned-off-by Boris Burkov <[email protected]>---
Changelog:
v6:
Actually include changes for v5 in the commit.
v5:
Instead of using_fixed_by_kernel_commit, userequire_fs_sysfsto 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-addfixed_by_kernel_commit, but for the stats patch which is required, but not a fix in the strictest sense.v2:
Drop thefixed_by_kernel_commitsince 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/283 | 50 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/283.out | 2 ++ 2 files changed, 52 insertions(+) create mode 100755 tests/btrfs/283 create mode 100644 tests/btrfs/283.outtests/btrfs/283 new file +0
-0
tests/btrfs/283 line 10
Quoted 10 lines
tests/btrfs/283 new file +10
-0@@ -0,0 +1,50 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 283 +# +# Test that mounting a btrfs filesystem properly loads block group size classes. +# +. ./common/preamble +_begin_fstest auto quick mount
I'm still curious why the 'mount' group, and I've asked for that before.
We aren't testing a new mount option, so it feels weird for me.
Otherwise, it looks fine now. Thanks.
Quoted 51 lines
tests/btrfs/283 new file +40
-0+ +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 +exittests/btrfs/283.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 283 +Silence is golden --2.39.1
Quoted 57 lines · Filipe Manana
Quoted 43 lines · Boris Burkov
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 sysfsSigned-off-by Boris Burkov <[email protected]>---
Changelog:
v6:
Actually include changes for v5 in the commit.
v5:
Instead of using_fixed_by_kernel_commit, userequire_fs_sysfsto 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-addfixed_by_kernel_commit, but for the stats patch which is required, but not a fix in the strictest sense.v2:
Drop thefixed_by_kernel_commitsince 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/283 | 50 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/283.out | 2 ++ 2 files changed, 52 insertions(+) create mode 100755 tests/btrfs/283 create mode 100644 tests/btrfs/283.outtests/btrfs/283 new file +0
-0tests/btrfs/283 line 10
Quoted 10 lines
tests/btrfs/283 new file +10
-0@@ -0,0 +1,50 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 283 +# +# Test that mounting a btrfs filesystem properly loads block group size classes. +# +. ./common/preamble +_begin_fstest auto quick mountI'm still curious why the 'mount' group, and I've asked for that before.
Quoted 1 line
We aren't testing a new mount option, so it feels weird for me.
Agree, the "mount" group looks not make sense.
The btrfs/283 has been taken in v2023.02.05. So please make a rebase.
The "fixed_by_kernel_commit xxxx" part has been added and removed several times, does this case need it or not? Or maybe you want a _wants_kernel_commit (just ask for sure) ?
Others look good to me.
Thanks,
Zorro
Quoted 55 lines
Otherwise, it looks fine now. Thanks.
Quoted 51 lines
tests/btrfs/283 new file +40
-0+ +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 +exittests/btrfs/283.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 283 +Silence is golden --2.39.1
Quoted 58 lines · Zorro Lang
Quoted 57 lines · Filipe Manana
Quoted 43 lines · Boris Burkov
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 sysfsSigned-off-by Boris Burkov <[email protected]>---
Changelog:
v6:
Actually include changes for v5 in the commit.
v5:
Instead of using_fixed_by_kernel_commit, userequire_fs_sysfsto 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-addfixed_by_kernel_commit, but for the stats patch which is required, but not a fix in the strictest sense.v2:
Drop thefixed_by_kernel_commitsince 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/283 | 50 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/283.out | 2 ++ 2 files changed, 52 insertions(+) create mode 100755 tests/btrfs/283 create mode 100644 tests/btrfs/283.outtests/btrfs/283 new file +0
-0tests/btrfs/283 line 10
Quoted 10 lines
tests/btrfs/283 new file +10
-0@@ -0,0 +1,50 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 283 +# +# Test that mounting a btrfs filesystem properly loads block group size classes. +# +. ./common/preamble +_begin_fstest auto quick mountI'm still curious why the 'mount' group, and I've asked for that before.
Quoted 3 lines
Quoted 1 line
We aren't testing a new mount option, so it feels weird for me.
Agree, the "mount" group looks not make sense.
My mistake, sorry for overlooking this. My reasoning is that it tests the behavior on a fresh mount rather than while the fs is live, but it is not specific to mounting logic. Happy to remove it.
Quoted 2 lines
The btrfs/283 has been taken in v2023.02.05. So please make a rebase.
Done. Is there any way we can try to script this process for the future with placeholders or something? It's kind of a drag to deal with in general. I'm happy to send some proposal if it's something you'd be interested in taking.
Quoted 4 lines
The "
fixed_by_kernel_commitxxxx" part has been added and removed several times, does this case need it or not? Or maybe you want a_wants_kernel_commit(just ask for sure) ?
Thanks for checking. I personally don't think it needs it. The commit it wants/needs is the commit that adds the sysfs file. I think that is adequately skipped and documented by the _require_fs_sysfs that Filipe suggested. If someone is really interested in this behavior, it is not too hard to find the kernel commit from the sysfs file.
Quoted 62 lines
Others look good to me.
Thanks,
ZorroQuoted 55 lines
Otherwise, it looks fine now. Thanks.
Quoted 51 lines
tests/btrfs/283 new file +40
-0+ +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 +exittests/btrfs/283.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 283 +Silence is golden --2.39.1
Quoted 68 lines · Boris Burkov
Quoted 58 lines · Zorro Lang
Quoted 57 lines · Filipe Manana
Quoted 43 lines · Boris Burkov
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 sysfsSigned-off-by Boris Burkov <[email protected]>---
Changelog:
v6:
Actually include changes for v5 in the commit.
v5:
Instead of using_fixed_by_kernel_commit, userequire_fs_sysfsto 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-addfixed_by_kernel_commit, but for the stats patch which is required, but not a fix in the strictest sense.v2:
Drop thefixed_by_kernel_commitsince 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/283 | 50 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/283.out | 2 ++ 2 files changed, 52 insertions(+) create mode 100755 tests/btrfs/283 create mode 100644 tests/btrfs/283.outtests/btrfs/283 new file +0
-0tests/btrfs/283 line 10
Quoted 10 lines
tests/btrfs/283 new file +10
-0@@ -0,0 +1,50 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 283 +# +# Test that mounting a btrfs filesystem properly loads block group size classes. +# +. ./common/preamble +_begin_fstest auto quick mountI'm still curious why the 'mount' group, and I've asked for that before.
Quoted 3 lines
Quoted 1 line
We aren't testing a new mount option, so it feels weird for me.
Agree, the "mount" group looks not make sense.
My mistake, sorry for overlooking this. My reasoning is that it tests the behavior on a fresh mount rather than while the fs is live, but it is not specific to mounting logic. Happy to remove it.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
The btrfs/283 has been taken in v2023.02.05. So please make a rebase.
Done. Is there any way we can try to script this process for the future with placeholders or something? It's kind of a drag to deal with in general. I'm happy to send some proposal if it's something you'd be interested in taking.
The ./new command will choose a proper number for a new case, but that number might be taken after several weeks passed. One way is: the contributor can use ./tools/mvtest to take a new number on his local develop branch, then rebase on the upstream for-next branch, then send it again.
It's easy for the new case developer, but a little hard for me to merge a taken number. I have to create a temporary branch, then remove that (already) taken case clearly, then merge the new patch, then change its number, then git cherrypick it to official branch. If the patch is big and complex, I might need to deal with more conflict (that's risk).
There's another way you can try when you create a new case, you can take a bigger enough number (e.g. 999, 900) for your new case. Darrick always would like to do that, when he send lots of new cases to me. After I merge that patch, I'll use ./tools/mvtest to give it a proper number.
If you have any better idea, feel free to send your patch.
Thanks,
Zorro
Quoted 75 lines
Quoted 5 lines
The "
fixed_by_kernel_commitxxxx" part has been added and removed several times, does this case need it or not? Or maybe you want a_wants_kernel_commit(just ask for sure) ?Thanks for checking. I personally don't think it needs it. The commit it wants/needs is the commit that adds the sysfs file. I think that is adequately skipped and documented by the
_require_fs_sysfsthat Filipe suggested. If someone is really interested in this behavior, it is not too hard to find the kernel commit from the sysfs file.Quoted 62 lines
Others look good to me.
Thanks,
ZorroQuoted 55 lines
Otherwise, it looks fine now. Thanks.
Quoted 51 lines
tests/btrfs/283 new file +40
-0+ +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 +exittests/btrfs/283.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 283 +Silence is golden --2.39.1