FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH] btrfs: test creating a large number of snapshots of a received subvolume
@ 2026-02-26 14:34 fdmanana
  2026-03-05 17:50 ` Boris Burkov
  0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2026-02-26 14:34 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Test that we can create a large number of snapshots of a received
subvolume without triggering a transaction abort due to leaf item
overflow. Also check that we are able to delete the snapshots and use
the last one for an incremental send/receive despite an item overflow
when updating the uuid tree to insert a BTRFS_UUID_KEY_RECEIVED_SUBVOL
item.

This exercises a bug fixed by the following kernel patch:

  "btrfs: fix transaction abort when snapshotting received subvolumes"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/345     | 73 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/345.out |  2 ++
 2 files changed, 75 insertions(+)
 create mode 100755 tests/btrfs/345
 create mode 100644 tests/btrfs/345.out

diff --git a/tests/btrfs/345 b/tests/btrfs/345
new file mode 100755
index 00000000..75cc3067
--- /dev/null
+++ b/tests/btrfs/345
@@ -0,0 +1,73 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
+#
+# FS QA Test 345
+#
+# Test that we can create a large number of snapshots of a received subvolume
+# without triggering a transaction abort due to leaf item overflow. Also check
+# that we are able to delete the snapshots and use the last one for an
+# incremental send/receive despite an item overflow when updating the uuid tree
+# to insert a BTRFS_UUID_KEY_RECEIVED_SUBVOL item.
+#
+. ./common/preamble
+_begin_fstest auto quick subvol send snapshot
+
+_require_scratch
+_require_btrfs_support_sectorsize 4096
+_require_btrfs_command "property"
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+	"btrfs: fix transaction abort when snapshotting received subvolumes"
+
+# Use a 4K node/leaf size to make the test faster.
+_scratch_mkfs -n 4K >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# Create a subvolume.
+_btrfs subvolume create $SCRATCH_MNT/sv
+touch $SCRATCH_MNT/sv/foo
+
+# Turn the subvolume to RO mode so that we can send it.
+_btrfs property set $SCRATCH_MNT/sv ro true
+
+# Send the subvolume and receive it. Our received version of the subvolume
+# (in $SCRATCH_MNT/snaps/sv) will have a non-NULL received UUID field in its
+# root item.
+mkdir $SCRATCH_MNT/snaps
+_btrfs send -f $SCRATCH_MNT/send.stream $SCRATCH_MNT/sv
+_btrfs receive -f $SCRATCH_MNT/send.stream $SCRATCH_MNT/snaps
+
+# Now snapshot the received the subvolume a lot of times and check we are able
+# to snapshot and that we don't trigger a transaction abort (will trigger a
+# warning and dump a stack trace in dmesg/syslog).
+total=$(( 1000 * LOAD_FACTOR ))
+for ((i = 1; i <= $total; i++)); do
+    _btrfs subvolume snapshot -r $SCRATCH_MNT/snaps/sv $SCRATCH_MNT/snaps/sv_$i
+done
+
+# Create a snapshot based on the last snapshot, add a file to it, and turn it
+# to RO so that we can used it for a send operation.
+last_snap="${SCRATCH_MNT}/snaps/sv_${total}"
+_btrfs subvolume snapshot $last_snap $SCRATCH_MNT/snaps/sv_last_as_parent
+echo -n "hello world" > $SCRATCH_MNT/snaps/sv_last_as_parent/bar
+_btrfs property set $SCRATCH_MNT/snaps/sv_last_as_parent ro true
+
+# Now we attempt to send and receive that snapshot, verify that it works even
+# if the creation of the snapshot $last_snap was not able to add a
+# BTRFS_UUID_KEY_RECEIVED_SUBVOL item to the uuid tree due to leaf overflow.
+_btrfs send -f $SCRATCH_MNT/inc_send.stream -p $last_snap \
+       $SCRATCH_MNT/snaps/sv_last_as_parent
+_btrfs receive -f $SCRATCH_MNT/inc_send.stream $SCRATCH_MNT/
+
+# Verify the received snapshot has the new file with the right content.
+diff $SCRATCH_MNT/snaps/sv_last_as_parent/bar $SCRATCH_MNT/sv_last_as_parent/bar
+
+# Now check that we are able to delete all the snapshots too.
+for ((i = 1; i <= $total; i++)); do
+    _btrfs subvolume delete $SCRATCH_MNT/snaps/sv_$i
+done
+
+# success, all done
+echo "Silence is golden"
+_exit 0
diff --git a/tests/btrfs/345.out b/tests/btrfs/345.out
new file mode 100644
index 00000000..11ef4e7e
--- /dev/null
+++ b/tests/btrfs/345.out
@@ -0,0 +1,2 @@
+QA output created by 345
+Silence is golden
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: test creating a large number of snapshots of a received subvolume
  2026-02-26 14:34 [PATCH] btrfs: test creating a large number of snapshots of a received subvolume fdmanana
@ 2026-03-05 17:50 ` Boris Burkov
  0 siblings, 0 replies; 2+ messages in thread
From: Boris Burkov @ 2026-03-05 17:50 UTC (permalink / raw)
  To: fdmanana; +Cc: fstests, linux-btrfs, Filipe Manana

On Thu, Feb 26, 2026 at 02:34:24PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Test that we can create a large number of snapshots of a received
> subvolume without triggering a transaction abort due to leaf item
> overflow. Also check that we are able to delete the snapshots and use
> the last one for an incremental send/receive despite an item overflow
> when updating the uuid tree to insert a BTRFS_UUID_KEY_RECEIVED_SUBVOL
> item.
> 
> This exercises a bug fixed by the following kernel patch:
> 
>   "btrfs: fix transaction abort when snapshotting received subvolumes"
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  tests/btrfs/345     | 73 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/345.out |  2 ++
>  2 files changed, 75 insertions(+)
>  create mode 100755 tests/btrfs/345
>  create mode 100644 tests/btrfs/345.out
> 
> diff --git a/tests/btrfs/345 b/tests/btrfs/345
> new file mode 100755
> index 00000000..75cc3067
> --- /dev/null
> +++ b/tests/btrfs/345
> @@ -0,0 +1,73 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
> +#
> +# FS QA Test 345
> +#
> +# Test that we can create a large number of snapshots of a received subvolume
> +# without triggering a transaction abort due to leaf item overflow. Also check
> +# that we are able to delete the snapshots and use the last one for an
> +# incremental send/receive despite an item overflow when updating the uuid tree
> +# to insert a BTRFS_UUID_KEY_RECEIVED_SUBVOL item.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick subvol send snapshot
> +
> +_require_scratch
> +_require_btrfs_support_sectorsize 4096
> +_require_btrfs_command "property"
> +
> +_fixed_by_kernel_commit xxxxxxxxxxxx \
> +	"btrfs: fix transaction abort when snapshotting received subvolumes"
> +
> +# Use a 4K node/leaf size to make the test faster.
> +_scratch_mkfs -n 4K >> $seqres.full 2>&1 || _fail "mkfs failed"
> +_scratch_mount
> +
> +# Create a subvolume.
> +_btrfs subvolume create $SCRATCH_MNT/sv
> +touch $SCRATCH_MNT/sv/foo
> +
> +# Turn the subvolume to RO mode so that we can send it.
> +_btrfs property set $SCRATCH_MNT/sv ro true
> +
> +# Send the subvolume and receive it. Our received version of the subvolume
> +# (in $SCRATCH_MNT/snaps/sv) will have a non-NULL received UUID field in its
> +# root item.
> +mkdir $SCRATCH_MNT/snaps
> +_btrfs send -f $SCRATCH_MNT/send.stream $SCRATCH_MNT/sv
> +_btrfs receive -f $SCRATCH_MNT/send.stream $SCRATCH_MNT/snaps
> +
> +# Now snapshot the received the subvolume a lot of times and check we are able
> +# to snapshot and that we don't trigger a transaction abort (will trigger a
> +# warning and dump a stack trace in dmesg/syslog).
> +total=$(( 1000 * LOAD_FACTOR ))
> +for ((i = 1; i <= $total; i++)); do
> +    _btrfs subvolume snapshot -r $SCRATCH_MNT/snaps/sv $SCRATCH_MNT/snaps/sv_$i
> +done
> +
> +# Create a snapshot based on the last snapshot, add a file to it, and turn it
> +# to RO so that we can used it for a send operation.
> +last_snap="${SCRATCH_MNT}/snaps/sv_${total}"
> +_btrfs subvolume snapshot $last_snap $SCRATCH_MNT/snaps/sv_last_as_parent
> +echo -n "hello world" > $SCRATCH_MNT/snaps/sv_last_as_parent/bar
> +_btrfs property set $SCRATCH_MNT/snaps/sv_last_as_parent ro true
> +
> +# Now we attempt to send and receive that snapshot, verify that it works even
> +# if the creation of the snapshot $last_snap was not able to add a
> +# BTRFS_UUID_KEY_RECEIVED_SUBVOL item to the uuid tree due to leaf overflow.
> +_btrfs send -f $SCRATCH_MNT/inc_send.stream -p $last_snap \
> +       $SCRATCH_MNT/snaps/sv_last_as_parent
> +_btrfs receive -f $SCRATCH_MNT/inc_send.stream $SCRATCH_MNT/
> +
> +# Verify the received snapshot has the new file with the right content.
> +diff $SCRATCH_MNT/snaps/sv_last_as_parent/bar $SCRATCH_MNT/sv_last_as_parent/bar
> +
> +# Now check that we are able to delete all the snapshots too.
> +for ((i = 1; i <= $total; i++)); do
> +    _btrfs subvolume delete $SCRATCH_MNT/snaps/sv_$i
> +done
> +
> +# success, all done
> +echo "Silence is golden"
> +_exit 0
> diff --git a/tests/btrfs/345.out b/tests/btrfs/345.out
> new file mode 100644
> index 00000000..11ef4e7e
> --- /dev/null
> +++ b/tests/btrfs/345.out
> @@ -0,0 +1,2 @@
> +QA output created by 345
> +Silence is golden
> -- 
> 2.47.2
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-05 17:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 14:34 [PATCH] btrfs: test creating a large number of snapshots of a received subvolume fdmanana
2026-03-05 17:50 ` Boris Burkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox