btrfs: send: check for dead send root under critical section
authorFilipe Manana <fdmanana@suse.com>
Wed, 6 Nov 2024 10:32:09 +0000 (10:32 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 11 Nov 2024 13:34:23 +0000 (14:34 +0100)
commitdc058f5fda091abcdccc2487b48dbbc1cdde98d0
tree133812c25ea6567ad00d17d9c26b0a02b698e1f6
parent722d343f12a626c9aee8844f5bf19a107d9a1067
btrfs: send: check for dead send root under critical section

We're checking if the send root is dead without the protection of the
root's root_item_lock spinlock, which is what protects the root's flags.
The inverse, setting the dead flag on a root, is done under the protection
of that lock, at btrfs_delete_subvolume(). Also checking and updating the
root's send_in_progress counter is supposed to be done in the same
critical section as checking for or setting the root dead flag, so that
these operations are done atomically as a single step (which is correctly
done by btrfs_delete_subvolume()).

So fix this by checking if the send root is dead in the same critical
section that updates the send_in_progress counter, which is protected by
the root's root_item_lock spinlock.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/send.c