From: Boris Burkov <boris@bur.io>
To: fdmanana@kernel.org
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH] btrfs: test creating a large number of snapshots of a received subvolume
Date: Thu, 5 Mar 2026 09:50:18 -0800 [thread overview]
Message-ID: <20260305175018.GA1172981@zen.localdomain> (raw)
In-Reply-To: <18154871aaddf2f1887c14e63513955c79b2a712.1772106013.git.fdmanana@suse.com>
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
>
prev parent reply other threads:[~2026-03-05 17:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260305175018.GA1172981@zen.localdomain \
--to=boris@bur.io \
--cc=fdmanana@kernel.org \
--cc=fdmanana@suse.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox