]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commit
btrfs: test qgroup deletion races with squota writes patches-in-queue
authorBoris Burkov <boris@bur.io>
Wed, 13 May 2026 00:43:34 +0000 (17:43 -0700)
committerZorro Lang <zlang@kernel.org>
Fri, 29 May 2026 09:57:16 +0000 (17:57 +0800)
commit26c2b701724afe41ec7e925549c883abf570b4f9
tree471ae13303f61e17d553145e145c7bf17cba7b0e
parentd65330dd7de46410342e7b7000d7bbceb903de0d
btrfs: test qgroup deletion races with squota writes

When using simple quotas, an extent's EXTENT_OWNER_REF can long outlive
the subvolume that created it, since the extent can pick up additional
references that keep it alive after the owning subvolume is deleted.

Several lifecycle bugs around the owning qgroup arise from this:

  1. Freeing an extent whose owner qgroup is gone: must not cause an
     underflow nor a transaction abort.

  2. Creating an extent in the same transaction that the owner subvolume
     is deleted: the qgroup may already be gone by the time the squota
     delta is recorded, leaving behind an EXTENT_OWNER_REF that points
     at a qgroup that never accumulated a usage delta.  Manually
     re-creating that qgroup and then freeing the extent would underflow
     it.

  3. Destroying a live subvolume's qgroup while delayed refs for newly
     allocated tree blocks have not yet flushed: rfer/excl read as 0,
     so the destroy looked safe, but the alloc delta was silently lost.

  4. Destroying the qgroup of a live subvolume whose data predates
     'btrfs quota enable --simple': pre-existing extents are not
     accounted (generation < qgroup_enable_gen), so rfer/excl stay 0
     permanently and a usage-only check happily destroys a qgroup
     belonging to a still-mounted, still-writeable subvolume.

Add four cases covering these scenarios.  On a fixed kernel all four
'qgroup destroy' (and the re-create in case 2) operations are refused
because the subvol check rejects the request; on an unfixed kernel
they would succeed and leave the filesystem with broken accounting or
trigger a transaction abort.

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Anand Jain <asj@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/349 [new file with mode: 0755]
tests/btrfs/349.out [new file with mode: 0644]