* [PATCH] btrfs: add test for subvolid reuse with squota
@ 2024-07-09 17:51 Boris Burkov
2024-07-09 18:36 ` Josef Bacik
2024-07-12 16:15 ` Anand Jain
0 siblings, 2 replies; 3+ messages in thread
From: Boris Burkov @ 2024-07-09 17:51 UTC (permalink / raw)
To: kernel-team, linux-btrfs, fstests
Squotas are likely to leave qgroups that outlive deleted subvolids.
Before the kernel patch
2b8aa78cf127 ("btrfs: qgroup: fix qgroup id collision across mounts")
this would lead to a repeated subvolid which would collide on an
existing qgroup id and error out with EEXIST. In snapshot creation, this
would lead to a read only fs.
Add a test which exercises the path that could create duplicate
subvolids but with squotas enabled, which should avoid the trap.
Signed-off-by: Boris Burkov <boris@bur.io>
---
tests/btrfs/331 | 45 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/331.out | 2 ++
2 files changed, 47 insertions(+)
create mode 100755 tests/btrfs/331
create mode 100644 tests/btrfs/331.out
diff --git a/tests/btrfs/331 b/tests/btrfs/331
new file mode 100755
index 000000000..8a99d5527
--- /dev/null
+++ b/tests/btrfs/331
@@ -0,0 +1,45 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Meta Platforms, Inc. All Rights Reserved.
+#
+# FS QA Test 331
+#
+# Test that btrfs does not recycle subvolume ids across remounts in a way that
+# breaks squotas.
+#
+. ./common/preamble
+_begin_fstest auto quick qgroup snapshot
+
+_fixed_by_kernel_commit 2b8aa78cf127 \
+ "btrfs: qgroup: fix qgroup id collision across mounts"
+
+. ./common/btrfs
+_supported_fs btrfs
+_require_scratch_enable_simple_quota
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+$BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT
+
+# Create a gap in the subvolume IDs
+sv=$SCRATCH_MNT/sv
+for i in $(seq 100); do
+ $BTRFS_UTIL_PROG subvolume create $sv.$i >> $seqres.full
+done
+for i in $(seq 50 100); do
+ $BTRFS_UTIL_PROG subvolume delete $sv.$i >> $seqres.full
+done
+
+# Cycle mount triggers reading the tree_root's free objectid.
+_scratch_cycle_mount
+
+# Create snapshots that could go into the used subvolid space.
+$BTRFS_UTIL_PROG subvolume create $sv.BOOM >> $seqres.full
+for i in $(seq 10); do
+ $BTRFS_UTIL_PROG subvolume snapshot $sv.BOOM $sv.BOOM.$i >> $seqres.full
+done
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/331.out b/tests/btrfs/331.out
new file mode 100644
index 000000000..0097e61d8
--- /dev/null
+++ b/tests/btrfs/331.out
@@ -0,0 +1,2 @@
+QA output created by 331
+Silence is golden
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: add test for subvolid reuse with squota
2024-07-09 17:51 [PATCH] btrfs: add test for subvolid reuse with squota Boris Burkov
@ 2024-07-09 18:36 ` Josef Bacik
2024-07-12 16:15 ` Anand Jain
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2024-07-09 18:36 UTC (permalink / raw)
To: Boris Burkov; +Cc: kernel-team, linux-btrfs, fstests
On Tue, Jul 09, 2024 at 10:51:04AM -0700, Boris Burkov wrote:
> Squotas are likely to leave qgroups that outlive deleted subvolids.
> Before the kernel patch
> 2b8aa78cf127 ("btrfs: qgroup: fix qgroup id collision across mounts")
> this would lead to a repeated subvolid which would collide on an
> existing qgroup id and error out with EEXIST. In snapshot creation, this
> would lead to a read only fs.
>
> Add a test which exercises the path that could create duplicate
> subvolids but with squotas enabled, which should avoid the trap.
>
> Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: add test for subvolid reuse with squota
2024-07-09 17:51 [PATCH] btrfs: add test for subvolid reuse with squota Boris Burkov
2024-07-09 18:36 ` Josef Bacik
@ 2024-07-12 16:15 ` Anand Jain
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2024-07-12 16:15 UTC (permalink / raw)
To: Boris Burkov, kernel-team, linux-btrfs, fstests
On 10/07/2024 01:51, Boris Burkov wrote:
> Squotas are likely to leave qgroups that outlive deleted subvolids.
> Before the kernel patch
> 2b8aa78cf127 ("btrfs: qgroup: fix qgroup id collision across mounts")
> this would lead to a repeated subvolid which would collide on an
> existing qgroup id and error out with EEXIST. In snapshot creation, this
> would lead to a read only fs.
>
> Add a test which exercises the path that could create duplicate
> subvolids but with squotas enabled, which should avoid the trap.
>
> Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Applied.
Thanks, Anand
> ---
> tests/btrfs/331 | 45 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/331.out | 2 ++
> 2 files changed, 47 insertions(+)
> create mode 100755 tests/btrfs/331
> create mode 100644 tests/btrfs/331.out
>
> diff --git a/tests/btrfs/331 b/tests/btrfs/331
> new file mode 100755
> index 000000000..8a99d5527
> --- /dev/null
> +++ b/tests/btrfs/331
> @@ -0,0 +1,45 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Meta Platforms, Inc. All Rights Reserved.
> +#
> +# FS QA Test 331
> +#
> +# Test that btrfs does not recycle subvolume ids across remounts in a way that
> +# breaks squotas.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick qgroup snapshot
> +
> +_fixed_by_kernel_commit 2b8aa78cf127 \
> + "btrfs: qgroup: fix qgroup id collision across mounts"
> +
> +. ./common/btrfs
> +_supported_fs btrfs
> +_require_scratch_enable_simple_quota
> +
> +_scratch_mkfs >> $seqres.full
> +_scratch_mount
> +$BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT
> +
> +# Create a gap in the subvolume IDs
> +sv=$SCRATCH_MNT/sv
> +for i in $(seq 100); do
> + $BTRFS_UTIL_PROG subvolume create $sv.$i >> $seqres.full
> +done
> +for i in $(seq 50 100); do
> + $BTRFS_UTIL_PROG subvolume delete $sv.$i >> $seqres.full
> +done
> +
> +# Cycle mount triggers reading the tree_root's free objectid.
> +_scratch_cycle_mount
> +
> +# Create snapshots that could go into the used subvolid space.
> +$BTRFS_UTIL_PROG subvolume create $sv.BOOM >> $seqres.full
> +for i in $(seq 10); do
> + $BTRFS_UTIL_PROG subvolume snapshot $sv.BOOM $sv.BOOM.$i >> $seqres.full
> +done
> +
> +# success, all done
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/btrfs/331.out b/tests/btrfs/331.out
> new file mode 100644
> index 000000000..0097e61d8
> --- /dev/null
> +++ b/tests/btrfs/331.out
> @@ -0,0 +1,2 @@
> +QA output created by 331
> +Silence is golden
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-12 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-09 17:51 [PATCH] btrfs: add test for subvolid reuse with squota Boris Burkov
2024-07-09 18:36 ` Josef Bacik
2024-07-12 16:15 ` Anand Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox