summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin/stackcollapse-report
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2026-11-06 17:42:42 +0000
committerDavid Sterba <dsterba@suse.com>2026-11-23 19:41:41 +0100
commit016bbc403305b3d5d61e5a1b543bd69dc7c813c3 (patch)
tree234b6b4574a94f81000fdc84ffba2fd0f220fdfd /tools/perf/scripts/python/bin/stackcollapse-report
parent9383a7fdcb27142d97e65fc76f28475018980b35 (diff)
btrfs: drop the link count of a subvolume inode when deleting the subvolume
When we delete a subvolume we don't drop the link count of the subvolume's inode. This is harmless in general, however if someone is holding an open file descriptor on the inode while and after the subvolume is deleted, the subvolume will still be listed by btrfs-progs. Example reproducer: $ cat test.sh #!/bin/bash DEV=/dev/sdi MNT=/mnt/sdi mkfs.btrfs -f $DEV mount $DEV $MNT btrfs subvolume create $MNT/sv echo "*** Setting up inotify ***" inotifywait -m $MNT/sv & sleep 1 echo "*** Setup done ***" echo "*** Deleting subvolume ***" btrfs subvolume delete $MNT/sv echo "*** Subvolume deleted ***" echo "*** Sleeping and syncing ***" sleep 30 btrfs filesystem sync $MNT echo "*** Listing subvolumes ***" btrfs subvolume list -d $MNT echo "*** Killing inotify and syncing ***" kill %1 sleep 5 btrfs filesystem sync $MNT echo "*** Listing subvolumes again ***" btrfs subvolume list -d $MNT echo "*** Done ***" umount $MNT When running this, the first subvolume listing still shows the deleted subvolume and inotify does not report the subvolume as deleted: $ ./test.sh (...) Create subvolume '/mnt/sdi/sv' *** Setting up inotify *** Setting up watches. Watches established. *** Setup done *** *** Deleting subvolume *** Delete subvolume 256 (no-commit): '/mnt/sdi/sv' /mnt/sdi/sv/ OPEN,ISDIR /mnt/sdi/sv/ CLOSE_NOWRITE,CLOSE,ISDIR *** Subvolume deleted *** *** Sleeping and syncing *** *** Listing subvolumes *** ID 256 gen 9 top level 0 path DELETED *** Killing inotify and syncing *** *** Listing subvolumes again *** *** Done *** Fix this by dropping the subvolume's inode link count when we delete a subvolume. After this, running the reproducer gives us: $ ./test.sh (...) Create subvolume '/mnt/sdi/sv' *** Setting up inotify *** Setting up watches. Watches established. *** Setup done *** *** Deleting subvolume *** Delete subvolume 256 (no-commit): '/mnt/sdi/sv' /mnt/sdi/sv/ OPEN,ISDIR /mnt/sdi/sv/ CLOSE_NOWRITE,CLOSE,ISDIR /mnt/sdi/sv/ DELETE_SELF *** Subvolume deleted *** *** Sleeping and syncing *** *** Listing subvolumes *** *** Killing inotify and syncing *** *** Listing subvolumes again *** *** Done *** The subvolume is no longer listed after deleting it while inotifywait is running and inotifywait reports the deletion. Reported-by: Alex <linuxkernel+co@alexs.space> Link: https://lore.kernel.org/linux-btrfs/18e431317f832f21-26f56778@a-workstation/ Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/bin/stackcollapse-report')
0 files changed, 0 insertions, 0 deletions