]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs: test block group size class loading logic
authorBoris Burkov <boris@bur.io>
Thu, 16 Feb 2023 15:47:18 +0000 (07:47 -0800)
committerZorro Lang <zlang@kernel.org>
Sat, 18 Feb 2023 05:55:27 +0000 (13:55 +0800)
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>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/285 [new file with mode: 0755]
tests/btrfs/285.out [new file with mode: 0644]

diff --git a/tests/btrfs/285 b/tests/btrfs/285
new file mode 100755 (executable)
index 0000000..56cdad5
--- /dev/null
@@ -0,0 +1,50 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 285
+#
+# 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/285.out b/tests/btrfs/285.out
new file mode 100644 (file)
index 0000000..ab12da9
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 285
+Silence is golden