diff mbox series

btrfs: add test for btrfstune squota enable/disable

Message ID dadd378fcd6de83a566f1e587fa5d1a8337c3f6b.1720732930.git.boris@bur.io (mailing list archive)
State New, archived
Headers show
Series btrfs: add test for btrfstune squota enable/disable | expand

Commit Message

Boris Burkov July 11, 2024, 9:22 p.m. UTC
btrfstune supports enabling simple quotas on a fleshed out filesystem
(without adding owner refs) and clearing squotas entirely from a
filesystem that ran under squotas (clearing the incompat bit)

Test that these operations work on a relatively complicated filesystem
populated by fsstress while preserving fssum.

Signed-off-by: Boris Burkov <boris@bur.io>
---
 tests/btrfs/332     | 61 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/332.out |  2 ++
 2 files changed, 63 insertions(+)
 create mode 100755 tests/btrfs/332
 create mode 100644 tests/btrfs/332.out

Comments

Filipe Manana July 11, 2024, 11:30 p.m. UTC | #1
On Thu, Jul 11, 2024 at 10:23 PM Boris Burkov <boris@bur.io> wrote:
>
> btrfstune supports enabling simple quotas on a fleshed out filesystem
> (without adding owner refs) and clearing squotas entirely from a
> filesystem that ran under squotas (clearing the incompat bit)
>
> Test that these operations work on a relatively complicated filesystem
> populated by fsstress while preserving fssum.
>
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
>  tests/btrfs/332     | 61 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/332.out |  2 ++
>  2 files changed, 63 insertions(+)
>  create mode 100755 tests/btrfs/332
>  create mode 100644 tests/btrfs/332.out
>
> diff --git a/tests/btrfs/332 b/tests/btrfs/332
> new file mode 100755
> index 000000000..efc2d4ec3
> --- /dev/null
> +++ b/tests/btrfs/332
> @@ -0,0 +1,61 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.

2024

> +#
> +# FS QA Test No. btrfs/332
> +#
> +# Test tune enabling and removing squotas on a live filesystem
> +#
> +. ./common/preamble
> +_begin_fstest auto quick qgroup
> +
> +# Import common functions.
> +. ./common/filter.btrfs
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_scratch_enable_simple_quota
> +_require_no_compress
> +_require_command "$BTRFS_TUNE_PROG" btrfstune
> +_require_fssum
> +
> +_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
> +_scratch_mount
> +
> +# do some stuff
> +d1=$SCRATCH_MNT/d1
> +d2=$SCRATCH_MNT/d2
> +mkdir $d1
> +mkdir $d2
> +run_check $FSSTRESS_PROG -d $d1 -w -n 2000 $FSSTRESS_AVOID
> +fssum_pre=$($FSSUM_PROG -A $SCRATCH_MNT)
> +
> +# enable squotas
> +_scratch_unmount
> +$BTRFS_TUNE_PROG --enable-simple-quota $SCRATCH_DEV >> $seqres.full 2>&1

If this fails the test doesn't fail... it redirects both stdout and
stderr to the .full file and ignores the exit status of btrfstune.

> +$BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1

Same here, the test doesn't fail if btrfs check detects problems.

> +_scratch_mount
> +fssum_post=$($FSSUM_PROG -A $SCRATCH_MNT)
> +[ "$fssum_pre" == "$fssum_post" ] \
> +       || echo "fssum $fssum_pre does not match $fssum_post after enabling squota"
> +
> +# do some more stuff
> +run_check $FSSTRESS_PROG -d $d2 -w -n 2000 $FSSTRESS_AVOID
> +fssum_pre=$($FSSUM_PROG -A $SCRATCH_MNT)
> +_scratch_unmount
> +$BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1

Same here.

> +
> +$BTRFS_TUNE_PROG --remove-simple-quota $SCRATCH_DEV >> $seqres.full 2>&1

Same here, it ignores if the command fails.

Furthermore, --remove-simple-quota is a new option that is being added
in a patchset you just sent for btrfs-progs.
So the test should be skipped if the available btrfstune program does
not implement that option, rather than cryptically failing.

See what we do for detecting support for "btrfs" commands at
_require_btrfs_command().

> +$BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1

Same here, it's ignoring any failures rather than failing if btrfs
check finds any problems.

> +$BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep 'SIMPLE_QUOTA'

Missing a _require_btrfs_dump_super at the top.

> +$BTRFS_UTIL_PROG inspect-internal dump-tree $SCRATCH_DEV  | grep -e 'QUOTA' -e 'QGROUP'

Missing a _require_btrfs_command inspect-internal dump-tree at the top.

Thanks.

> +
> +_scratch_mount
> +fssum_post=$($FSSUM_PROG -A $SCRATCH_MNT)
> +_scratch_unmount
> +[ "$fssum_pre" == "$fssum_post" ] \
> +       || echo "fssum $fssum_pre does not match $fssum_post after disabling squota"
> +
> +echo Silence is golden
> +status=0
> +exit
> diff --git a/tests/btrfs/332.out b/tests/btrfs/332.out
> new file mode 100644
> index 000000000..adb316136
> --- /dev/null
> +++ b/tests/btrfs/332.out
> @@ -0,0 +1,2 @@
> +QA output created by 332
> +Silence is golden
> --
> 2.45.2
>
>
diff mbox series

Patch

diff --git a/tests/btrfs/332 b/tests/btrfs/332
new file mode 100755
index 000000000..efc2d4ec3
--- /dev/null
+++ b/tests/btrfs/332
@@ -0,0 +1,61 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.
+#
+# FS QA Test No. btrfs/332
+#
+# Test tune enabling and removing squotas on a live filesystem
+#
+. ./common/preamble
+_begin_fstest auto quick qgroup
+
+# Import common functions.
+. ./common/filter.btrfs
+
+# real QA test starts here
+_supported_fs btrfs
+_require_scratch_enable_simple_quota
+_require_no_compress
+_require_command "$BTRFS_TUNE_PROG" btrfstune
+_require_fssum
+
+_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# do some stuff
+d1=$SCRATCH_MNT/d1
+d2=$SCRATCH_MNT/d2
+mkdir $d1
+mkdir $d2
+run_check $FSSTRESS_PROG -d $d1 -w -n 2000 $FSSTRESS_AVOID
+fssum_pre=$($FSSUM_PROG -A $SCRATCH_MNT)
+
+# enable squotas
+_scratch_unmount
+$BTRFS_TUNE_PROG --enable-simple-quota $SCRATCH_DEV >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_mount
+fssum_post=$($FSSUM_PROG -A $SCRATCH_MNT)
+[ "$fssum_pre" == "$fssum_post" ] \
+	|| echo "fssum $fssum_pre does not match $fssum_post after enabling squota"
+
+# do some more stuff
+run_check $FSSTRESS_PROG -d $d2 -w -n 2000 $FSSTRESS_AVOID
+fssum_pre=$($FSSUM_PROG -A $SCRATCH_MNT)
+_scratch_unmount
+$BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1
+
+$BTRFS_TUNE_PROG --remove-simple-quota $SCRATCH_DEV >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG check $SCRATCH_DEV >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep 'SIMPLE_QUOTA'
+$BTRFS_UTIL_PROG inspect-internal dump-tree $SCRATCH_DEV  | grep -e 'QUOTA' -e 'QGROUP'
+
+_scratch_mount
+fssum_post=$($FSSUM_PROG -A $SCRATCH_MNT)
+_scratch_unmount
+[ "$fssum_pre" == "$fssum_post" ] \
+	|| echo "fssum $fssum_pre does not match $fssum_post after disabling squota"
+
+echo Silence is golden
+status=0
+exit
diff --git a/tests/btrfs/332.out b/tests/btrfs/332.out
new file mode 100644
index 000000000..adb316136
--- /dev/null
+++ b/tests/btrfs/332.out
@@ -0,0 +1,2 @@ 
+QA output created by 332
+Silence is golden